├── .gitignore
├── .travis.yml
├── LICENSE.md
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ ├── curves
│ │ ├── Brighten.acv
│ │ ├── Contrast.acv
│ │ ├── Darken.acv
│ │ ├── Fade.acv
│ │ ├── Mark-Galer-Grading.acv
│ │ └── Matte.acv
│ └── fonts
│ │ ├── Aladin
│ │ ├── Aladin-Regular.ttf
│ │ └── OFL.txt
│ │ ├── Battambang
│ │ ├── Battambang-Bold.ttf
│ │ ├── Battambang-Regular.ttf
│ │ └── OFL.txt
│ │ ├── Bayon-Regular.ttf
│ │ ├── Bokor
│ │ ├── Bokor-Regular.ttf
│ │ └── OFL.txt
│ │ ├── Dangrek
│ │ ├── Dangrek-Regular.ttf
│ │ └── OFL.txt
│ │ ├── Fredoka_One
│ │ ├── FredokaOne-Regular.ttf
│ │ └── OFL.txt
│ │ ├── Fugaz_One
│ │ ├── FugazOne-Regular.ttf
│ │ └── OFL.txt
│ │ ├── Great_Vibes
│ │ ├── GreatVibes-Regular.ttf
│ │ └── OFL.txt
│ │ ├── Hanuman
│ │ ├── Hanuman-Bold.ttf
│ │ ├── Hanuman-Regular.ttf
│ │ └── OFL.txt
│ │ ├── Koulen
│ │ ├── Koulen-Regular.ttf
│ │ └── OFL.txt
│ │ ├── Lobster
│ │ ├── Lobster-Regular.ttf
│ │ └── OFL.txt
│ │ ├── PT_Serif
│ │ ├── OFL.txt
│ │ ├── PTSerif-Bold.ttf
│ │ ├── PTSerif-BoldItalic.ttf
│ │ ├── PTSerif-Regular.ttf
│ │ └── PTSerif-RegularItalic.ttf
│ │ ├── Paytone_One
│ │ ├── OFL.txt
│ │ └── PaytoneOne-Regular.ttf
│ │ ├── Preahvihear
│ │ ├── OFL.txt
│ │ └── Preahvihear-Regular.ttf
│ │ ├── Saira_Stencil_One
│ │ ├── OFL.txt
│ │ └── SairaStencilOne-Regular.ttf
│ │ └── Viga
│ │ ├── OFL.txt
│ │ └── Viga-Regular.ttf
│ ├── java
│ └── com
│ │ └── seanghay
│ │ └── studioexample
│ │ ├── AppDatabase.kt
│ │ ├── AudioEntity.kt
│ │ ├── FontFamilyAdapter.kt
│ │ ├── FontLoader.kt
│ │ ├── GenericFileProvider.kt
│ │ ├── HomeActivity.kt
│ │ ├── ImageRender.kt
│ │ ├── LittleBox.kt
│ │ ├── MainActivity.kt
│ │ ├── Mp4Composer.kt
│ │ ├── RenderActivity.kt
│ │ ├── Scene.kt
│ │ ├── SlideAdapter.kt
│ │ ├── SlideEntity.kt
│ │ ├── StoryEntity.kt
│ │ ├── TextBitmap.kt
│ │ ├── TransitionsAdapter.kt
│ │ ├── UnitUtls.kt
│ │ ├── VideoComposer.kt
│ │ ├── VideoCreate.kt
│ │ ├── adapter
│ │ └── StoryListAdapter.kt
│ │ ├── bottomsheet
│ │ ├── FilterPackDialogFragment.kt
│ │ ├── QuoteDialogFragment.kt
│ │ └── SceneOptionsBottomSheet.kt
│ │ ├── core
│ │ ├── AudioExtractor.java
│ │ ├── AudioMixer.kt
│ │ └── AudioTranscoder.kt
│ │ ├── dao
│ │ ├── AudioDao.kt
│ │ ├── MD5.kt
│ │ ├── SlideDao.kt
│ │ └── StoryDao.kt
│ │ ├── experiment
│ │ ├── ExperimentActivity.kt
│ │ ├── core
│ │ │ ├── EditorEngine.kt
│ │ │ └── ProjectionUtils.kt
│ │ ├── fragment
│ │ │ └── StudioFragment.kt
│ │ └── viewmodel
│ │ │ └── StudioViewModel.kt
│ │ ├── picasso
│ │ └── NewPicassoEngine.kt
│ │ └── sticker
│ │ ├── QuoteDesigner.kt
│ │ ├── QuoteState.kt
│ │ ├── StickerView.kt
│ │ └── gesture
│ │ ├── BaseGestureDetector.java
│ │ ├── MoveGestureDetector.java
│ │ ├── RotateGestureDetector.java
│ │ ├── ShoveGestureDetector.java
│ │ └── TwoFingerGestureDetector.java
│ └── res
│ ├── animator
│ └── appbar.xml
│ ├── drawable-v24
│ ├── ic_launcher_foreground.xml
│ └── image.jpg
│ ├── drawable
│ ├── border.xml
│ ├── check.xml
│ ├── ic_brightness_4_black_24dp.xml
│ ├── ic_check_black_24dp.xml
│ ├── ic_check_circle_black_24dp.xml
│ ├── ic_close_black_24dp.xml
│ ├── ic_delete_black_24dp.xml
│ ├── ic_disabled_check.xml
│ ├── ic_filter_hdr_black_24dp.xml
│ ├── ic_launcher_background.xml
│ ├── ic_more_vert_black_24dp.xml
│ ├── ic_pause.xml
│ ├── ic_photo_filter_black_24dp.xml
│ ├── ic_play.xml
│ ├── ic_text_fields_black_24dp.xml
│ └── togness.png
│ ├── layout
│ ├── activity_experiment.xml
│ ├── activity_home.xml
│ ├── activity_main.xml
│ ├── dialog_filters.xml
│ ├── dialog_quote.xml
│ ├── dropdown_menu_popup_item.xml
│ ├── fragment_scene_option.xml
│ ├── fragment_studio.xml
│ ├── item_story.xml
│ ├── item_transition.xml
│ └── item_video.xml
│ ├── menu
│ ├── main.xml
│ ├── more.xml
│ └── quote.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── raw
│ └── loop.wav
│ ├── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ └── provider_paths.xml
├── bintrayconfig.gradle
├── build.gradle
├── dependencies.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
├── spotless.gradle
├── spotless.license.kt
├── studio
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── seanghay
│ │ └── studio
│ │ ├── composer
│ │ ├── AudioChannel.kt
│ │ ├── AudioComposer.kt
│ │ ├── DefaultAudioComposer.kt
│ │ └── MuxerRender.kt
│ │ ├── core
│ │ ├── Studio.kt
│ │ ├── StudioDrawable.kt
│ │ ├── StudioEngine.kt
│ │ ├── StudioRenderThread.kt
│ │ └── StudioView.kt
│ │ ├── engine
│ │ └── AudioTranscoder.kt
│ │ ├── gles
│ │ ├── RenderContext.kt
│ │ ├── RenderTarget.kt
│ │ ├── VideoDecoder.kt
│ │ ├── annotation
│ │ │ ├── AttrHandle.kt
│ │ │ ├── GlContext.kt
│ │ │ └── UniformHandle.kt
│ │ ├── egl
│ │ │ ├── EglCore.kt
│ │ │ ├── EglExtensions.kt
│ │ │ ├── EglOffscreenSurface.kt
│ │ │ ├── EglSurfaceBase.kt
│ │ │ └── EglWindowSurface.kt
│ │ ├── graphics
│ │ │ ├── FrameBuffer.kt
│ │ │ ├── InputValue.kt
│ │ │ ├── Matrix4f.kt
│ │ │ ├── Vector2f.kt
│ │ │ ├── Vector3f.kt
│ │ │ ├── Vector4f.kt
│ │ │ ├── attribute
│ │ │ │ ├── Attribute.kt
│ │ │ │ └── VertexAttribute.kt
│ │ │ ├── texture
│ │ │ │ ├── BitmapTextureUniform.kt
│ │ │ │ ├── Texture.kt
│ │ │ │ ├── Texture2d.kt
│ │ │ │ ├── Texture2dUniform.kt
│ │ │ │ └── TextureUniform.kt
│ │ │ └── uniform
│ │ │ │ ├── BooleanUniform.kt
│ │ │ │ ├── Float2Uniform.kt
│ │ │ │ ├── Float3Uniform.kt
│ │ │ │ ├── Float4Uniform.kt
│ │ │ │ ├── FloatUniform.kt
│ │ │ │ ├── IntUniform.kt
│ │ │ │ ├── Mat4Uniform.kt
│ │ │ │ └── Uniform.kt
│ │ ├── kenburns
│ │ │ ├── Kenburns.kt
│ │ │ └── SimpleKenburns.kt
│ │ ├── shader
│ │ │ ├── AlphaOverlayTextureShader.kt
│ │ │ ├── ImageTextureShader.kt
│ │ │ ├── Shader.kt
│ │ │ ├── TextureShader.kt
│ │ │ └── filter
│ │ │ │ ├── BrightnessFilterShader.kt
│ │ │ │ ├── ColorMatrixFilterShader.kt
│ │ │ │ ├── CompositeShader.kt
│ │ │ │ ├── ContrastFilterShader.kt
│ │ │ │ ├── GammaFilterShader.kt
│ │ │ │ ├── GaussianBlurFilterShader.kt
│ │ │ │ ├── GrayscaleFilterShader.kt
│ │ │ │ ├── OverlayBlenderFilterShader.kt
│ │ │ │ ├── PackFilterShader.kt
│ │ │ │ ├── SaturationFilterShader.kt
│ │ │ │ ├── SepiaToneFilterShader.kt
│ │ │ │ ├── TintFilterShader.kt
│ │ │ │ ├── VibrantFilterShader.kt
│ │ │ │ ├── VignetteFilterShader.kt
│ │ │ │ ├── WarmFilterShader.kt
│ │ │ │ ├── pack
│ │ │ │ └── PackFilter.kt
│ │ │ │ └── tonecurve
│ │ │ │ ├── ToneCurve.kt
│ │ │ │ ├── ToneCurveFilterShader.kt
│ │ │ │ ├── ToneCurveUtils.kt
│ │ │ │ └── simple
│ │ │ │ └── SimpleToneCurve.kt
│ │ └── transition
│ │ │ ├── AngularTransition.kt
│ │ │ ├── AssetTransition.kt
│ │ │ ├── BounceTransition.kt
│ │ │ ├── BowTieHorizontalTransition.kt
│ │ │ ├── BowTieVerticalTransition.kt
│ │ │ ├── BurnTransition.kt
│ │ │ ├── ButterflyWaveScrawlerTransition.kt
│ │ │ ├── CannabisleafTransition.kt
│ │ │ ├── CircleCropTransition.kt
│ │ │ ├── CircleTransition.kt
│ │ │ ├── CircleopenTransition.kt
│ │ │ ├── ColorphaseTransition.kt
│ │ │ ├── ColourDistanceTransition.kt
│ │ │ ├── CrazyParametricFunTransition.kt
│ │ │ ├── CrossZoomTransition.kt
│ │ │ ├── CrosshatchTransition.kt
│ │ │ ├── CrosswarpTransition.kt
│ │ │ ├── CubeTransition.kt
│ │ │ ├── DirectionalTransition.kt
│ │ │ ├── DirectionalwarpTransition.kt
│ │ │ ├── DirectionalwipeTransition.kt
│ │ │ ├── DoomScreenTransitionTransition.kt
│ │ │ ├── DoorwayTransition.kt
│ │ │ ├── DreamyTransition.kt
│ │ │ ├── DreamyZoomTransition.kt
│ │ │ ├── FadeTransition.kt
│ │ │ ├── FadecolorTransition.kt
│ │ │ ├── FadegrayscaleTransition.kt
│ │ │ ├── FlyeyeTransition.kt
│ │ │ ├── GlitchDisplaceTransition.kt
│ │ │ ├── GlitchMemoriesTransition.kt
│ │ │ ├── HeartTransition.kt
│ │ │ ├── HexagonalizeTransition.kt
│ │ │ ├── InvertedPageCurlTransition.kt
│ │ │ ├── KaleidoscopeTransition.kt
│ │ │ ├── LinearBlurTransition.kt
│ │ │ ├── LuminanceMeltTransition.kt
│ │ │ ├── MorphTransition.kt
│ │ │ ├── MosaicTransition.kt
│ │ │ ├── MultiplyBlendTransition.kt
│ │ │ ├── PerlinTransition.kt
│ │ │ ├── PinwheelTransition.kt
│ │ │ ├── PolarFunctionTransition.kt
│ │ │ ├── PolkaDotsCurtainTransition.kt
│ │ │ ├── RadialTransition.kt
│ │ │ ├── RippleTransition.kt
│ │ │ ├── RotateScaleFadeTransition.kt
│ │ │ ├── SimpleZoomTransition.kt
│ │ │ ├── SqueezeTransition.kt
│ │ │ ├── StereoViewerTransition.kt
│ │ │ ├── SwapTransition.kt
│ │ │ ├── SwirlTransition.kt
│ │ │ ├── Transition.kt
│ │ │ ├── TransitionStore.kt
│ │ │ ├── TransitionalTextureShader.kt
│ │ │ ├── UndulatingBurnOutTransition.kt
│ │ │ ├── WaterDropTransition.kt
│ │ │ ├── WindTransition.kt
│ │ │ ├── WindowblindsTransition.kt
│ │ │ ├── WindowsliceTransition.kt
│ │ │ ├── WipeDownTransition.kt
│ │ │ ├── WipeLeftTransition.kt
│ │ │ ├── WipeRightTransition.kt
│ │ │ ├── WipeUpTransition.kt
│ │ │ └── ZoomInCirclesTransition.kt
│ │ ├── internal
│ │ └── Logger.kt
│ │ ├── mediacodec
│ │ └── TrackFormats.kt
│ │ ├── sonic
│ │ └── Sonic.java
│ │ └── utils
│ │ ├── BasicVertices.kt
│ │ ├── BitmapDiskCache.kt
│ │ ├── BitmapExtensions.kt
│ │ ├── BitmapProcessor.kt
│ │ ├── BufferExtensions.kt
│ │ ├── ColorExtensions.kt
│ │ ├── FastBlur.java
│ │ ├── GlUtils.kt
│ │ ├── MathCore.kt
│ │ └── MediaExtensions.kt
│ └── res
│ └── values
│ └── strings.xml
└── versionsPlugin.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | /.idea
14 | .externalNativeBuild
15 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | dist: trusty
3 | android:
4 | components:
5 | - tools
6 | - platform-tools
7 | - build-tools-29.0.0
8 | - android-29
9 | - extra-android-support
10 | - extra-android-m2repository
11 | - extra-google-m2repository
12 |
13 | licenses:
14 | - '.+'
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Studio (Unstable)
2 | A studio for video editor.
3 |
4 | [ ](https://travis-ci.org/seanghay/studio)
5 | [](https://opensource.org/licenses/Apache-2.0)
6 | [  ](https://bintray.com/seanghay/maven/studio/_latestVersion)
7 |
8 |
9 | ### Installation
10 |
11 | ```gradle
12 | dependencies {
13 | implementation 'com.seanghay:studio:1.0.0-alpha04'
14 | }
15 | ```
16 |
17 |
18 | > Pull requests are welcomed!
19 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 | -dontwarn com.squareup.picasso.**
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
19 |
20 |
25 |
26 |
29 |
30 |
31 |
32 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/assets/curves/Brighten.acv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/curves/Brighten.acv
--------------------------------------------------------------------------------
/app/src/main/assets/curves/Contrast.acv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/curves/Contrast.acv
--------------------------------------------------------------------------------
/app/src/main/assets/curves/Darken.acv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/curves/Darken.acv
--------------------------------------------------------------------------------
/app/src/main/assets/curves/Fade.acv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/curves/Fade.acv
--------------------------------------------------------------------------------
/app/src/main/assets/curves/Mark-Galer-Grading.acv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/curves/Mark-Galer-Grading.acv
--------------------------------------------------------------------------------
/app/src/main/assets/curves/Matte.acv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/curves/Matte.acv
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Aladin/Aladin-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Aladin/Aladin-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Battambang/Battambang-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Battambang/Battambang-Bold.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Battambang/Battambang-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Battambang/Battambang-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Bayon-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Bayon-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Bokor/Bokor-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Bokor/Bokor-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Dangrek/Dangrek-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Dangrek/Dangrek-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Fredoka_One/FredokaOne-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Fredoka_One/FredokaOne-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Fugaz_One/FugazOne-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Fugaz_One/FugazOne-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Great_Vibes/GreatVibes-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Great_Vibes/GreatVibes-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Hanuman/Hanuman-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Hanuman/Hanuman-Bold.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Hanuman/Hanuman-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Hanuman/Hanuman-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Koulen/Koulen-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Koulen/Koulen-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Lobster/Lobster-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Lobster/Lobster-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/PT_Serif/PTSerif-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/PT_Serif/PTSerif-Bold.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/PT_Serif/PTSerif-BoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/PT_Serif/PTSerif-BoldItalic.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/PT_Serif/PTSerif-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/PT_Serif/PTSerif-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/PT_Serif/PTSerif-RegularItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/PT_Serif/PTSerif-RegularItalic.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Paytone_One/PaytoneOne-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Paytone_One/PaytoneOne-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Preahvihear/Preahvihear-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Preahvihear/Preahvihear-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Saira_Stencil_One/SairaStencilOne-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Saira_Stencil_One/SairaStencilOne-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Viga/Viga-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/assets/fonts/Viga/Viga-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/AppDatabase.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample
2 |
3 | import androidx.room.Database
4 | import androidx.room.RoomDatabase
5 | import com.seanghay.studioexample.dao.AudioDao
6 | import com.seanghay.studioexample.dao.SlideDao
7 | import com.seanghay.studioexample.dao.StoryDao
8 |
9 |
10 | @Database(version = 3,
11 | exportSchema = false,
12 | entities = [SlideEntity::class, AudioEntity::class, StoryEntity::class])
13 | abstract class AppDatabase : RoomDatabase() {
14 | abstract fun slideDao(): SlideDao
15 | abstract fun audioDao(): AudioDao
16 | abstract fun storyDao(): StoryDao
17 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/AudioEntity.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 |
6 | @Entity
7 | data class AudioEntity(
8 | @PrimaryKey(autoGenerate = true)
9 | var id: Int? = null,
10 | var path: String
11 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/FontFamilyAdapter.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studioexample
17 |
18 | import android.content.Context
19 | import android.view.LayoutInflater
20 | import android.view.View
21 | import android.view.ViewGroup
22 | import android.widget.ArrayAdapter
23 | import android.widget.TextView
24 |
25 | class FontFamilyAdapter(
26 | context: Context,
27 | private var listener: FontFamilyListener?,
28 | private val items: List
29 | ) : ArrayAdapter(context, R.layout.dropdown_menu_popup_item, items) {
30 |
31 | override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
32 | val inflater = LayoutInflater.from(context)
33 | val row = convertView ?: inflater.inflate(R.layout.dropdown_menu_popup_item, parent, false)
34 | val item = items[position]
35 |
36 | with(row) {
37 | val textView = row as TextView
38 | textView.text = item.name
39 | textView.typeface = item.getTypeface(context.assets)
40 | }
41 |
42 | return row
43 | }
44 |
45 | override fun getItem(p0: Int): FontLoader.FontFamily {
46 | return items[p0]
47 | }
48 |
49 | override fun getItemId(p0: Int): Long {
50 | return p0.toLong()
51 | }
52 |
53 | override fun getCount(): Int {
54 | return items.size
55 | }
56 |
57 | interface FontFamilyListener {
58 | fun onFontFamilySelect(fontFamily: FontLoader.FontFamily)
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/GenericFileProvider.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample
2 |
3 | import androidx.core.content.FileProvider
4 |
5 | class GenericFileProvider : FileProvider()
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/RenderActivity.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample
2 |
3 | import android.opengl.GLES20.GL_COLOR_BUFFER_BIT
4 | import android.opengl.GLES20.glClear
5 | import android.opengl.GLES20.glClearColor
6 | import android.opengl.GLES20.glViewport
7 | import android.opengl.GLSurfaceView
8 | import android.os.Bundle
9 | import android.util.Log
10 | import androidx.appcompat.app.AppCompatActivity
11 | import javax.microedition.khronos.egl.EGLConfig
12 | import javax.microedition.khronos.opengles.GL10
13 |
14 |
15 | class MyRenderer : GLSurfaceView.Renderer {
16 |
17 | var lastTime = System.nanoTime()
18 | var delta = 0.0
19 | var ns = 1000000000.0 / 60.0
20 | var timer = System.currentTimeMillis()
21 | var updates = 0
22 | var frames = 0
23 |
24 |
25 | override fun onDrawFrame(gl: GL10?) {
26 | glClearColor(0f, 0f, 0f, 1f)
27 | glClear(GL_COLOR_BUFFER_BIT)
28 |
29 | val now = System.nanoTime()
30 | delta += (now - lastTime) / ns
31 | lastTime = now
32 | if (delta >= 1.0) {
33 |
34 | updates++
35 | delta--
36 | }
37 | frames++
38 |
39 | if (System.currentTimeMillis() - timer > 1000) {
40 | timer += 1000
41 | Log.d("RenderActivity", "$updates ups, $frames fps")
42 | updates = 0
43 | frames = 0
44 | }
45 |
46 | }
47 |
48 | override fun onSurfaceChanged(gl: GL10?, width: Int, height: Int) {
49 | glViewport(0, 0, width, height)
50 | }
51 |
52 |
53 | override fun onSurfaceCreated(gl: GL10?, config: EGLConfig?) {
54 |
55 | }
56 |
57 | }
58 |
59 |
60 | class RenderActivity : AppCompatActivity() {
61 | override fun onCreate(savedInstanceState: Bundle?) {
62 | super.onCreate(savedInstanceState)
63 | val renderer = MyRenderer()
64 | val surfaceView = GLSurfaceView(this)
65 | surfaceView.setEGLContextClientVersion(2)
66 | surfaceView.setRenderer(renderer)
67 | setContentView(surfaceView)
68 | }
69 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/Scene.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample
2 |
3 | import android.graphics.Bitmap
4 | import android.opengl.GLES20
5 | import android.opengl.GLUtils
6 | import com.seanghay.studio.gles.annotation.GlContext
7 | import com.seanghay.studio.gles.graphics.texture.Texture2d
8 | import com.seanghay.studio.gles.shader.filter.pack.PackFilter
9 | import com.seanghay.studio.gles.transition.FadeTransition
10 | import com.seanghay.studio.gles.transition.Transition
11 | import com.seanghay.studio.utils.BitmapProcessor
12 |
13 | class Scene(
14 | var id: String,
15 | var bitmap: Bitmap,
16 | var originalPath: String
17 | ) {
18 |
19 | var duration: Long = 4000L
20 | var transition: Transition = FadeTransition("fade", 1000L)
21 | var texture: Texture2d = Texture2d()
22 | var filter = PackFilter()
23 | var cropType: BitmapProcessor.CropType = BitmapProcessor.CropType.FILL_CENTER
24 |
25 |
26 | @GlContext
27 | fun setup() {
28 | texture.initialize()
29 | texture.use(GLES20.GL_TEXTURE_2D) {
30 | texture.configure(GLES20.GL_TEXTURE_2D)
31 | GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0)
32 | }
33 | }
34 |
35 | @GlContext
36 | fun release() {
37 |
38 | texture.release()
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/SlideEntity.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 |
6 | @Entity
7 | data class SlideEntity(
8 | var path: String,
9 | @PrimaryKey(autoGenerate = true)
10 | var id: Int? = null
11 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/StoryEntity.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 |
6 | @Entity
7 | data class StoryEntity(
8 | @PrimaryKey(autoGenerate = true)
9 | var id: Int? = null,
10 | var title: String? = null,
11 | var path: String,
12 | var createdAt: Long
13 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/UnitUtls.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample
2 |
3 | import android.content.res.Resources
4 | import android.util.TypedValue
5 | import androidx.annotation.Px
6 | import kotlin.math.roundToInt
7 |
8 |
9 | @Px
10 | fun Int.dip(resources: Resources): Int {
11 | return dipF(resources).roundToInt()
12 | }
13 |
14 | @Px
15 | fun Int.dipF(resources: Resources): Float {
16 | return toFloat().dip(resources)
17 | }
18 |
19 | @Px
20 | fun Float.dip(resources: Resources): Float {
21 | return TypedValue.applyDimension(
22 | TypedValue.COMPLEX_UNIT_DIP,
23 | this,
24 | resources.displayMetrics
25 | )
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/dao/AudioDao.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample.dao
2 |
3 | import androidx.room.*
4 | import com.seanghay.studioexample.AudioEntity
5 |
6 | @Dao
7 | interface AudioDao {
8 |
9 | @Query("Select * From AudioEntity Limit 1")
10 | fun first(): AudioEntity?
11 |
12 | @Insert(onConflict = OnConflictStrategy.IGNORE)
13 | fun save(audioEntity: AudioEntity)
14 |
15 | @Update(onConflict = OnConflictStrategy.IGNORE)
16 | fun update(audioEntity: AudioEntity)
17 |
18 | @Delete
19 | fun delete(audioEntity: AudioEntity)
20 |
21 | @Query("Delete From AudioEntity")
22 | fun deleteAll()
23 |
24 | @Transaction
25 | fun upsert(vararg audio: AudioEntity) {
26 | for (audioEntity in audio) {
27 | save(audioEntity)
28 | update(audioEntity)
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/dao/MD5.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample.dao
2 |
3 | import java.math.BigInteger
4 | import java.security.MessageDigest
5 |
6 | fun String.md5(): String {
7 | val md = MessageDigest.getInstance("MD5")
8 | return BigInteger(1, md.digest(toByteArray())).toString(16).padStart(32, '0')
9 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/dao/SlideDao.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample.dao
2 |
3 | import android.database.sqlite.SQLiteConstraintException
4 | import androidx.room.*
5 | import com.seanghay.studioexample.SlideEntity
6 |
7 | @Dao
8 | interface SlideDao {
9 |
10 | @Query("Delete From SlideEntity")
11 | fun deleteAll()
12 |
13 | @Insert(onConflict = OnConflictStrategy.IGNORE)
14 | fun insert(vararg slide: SlideEntity)
15 |
16 | @Update(onConflict = OnConflictStrategy.IGNORE)
17 | fun update(vararg slide: SlideEntity)
18 |
19 | @Query("Select * From SlideEntity")
20 | fun getAll(): List
21 |
22 | @Delete
23 | fun delete(slide: SlideEntity)
24 |
25 | @Transaction
26 | fun upsert(vararg slide: SlideEntity) {
27 | for (slideEntity in slide) {
28 | insert(slideEntity)
29 | update(slideEntity)
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/dao/StoryDao.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample.dao
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.room.*
5 | import com.seanghay.studioexample.StoryEntity
6 | import io.reactivex.Flowable
7 |
8 |
9 | @Dao
10 | interface StoryDao {
11 |
12 | @Query("Delete From StoryEntity")
13 | fun deleteAll()
14 |
15 | @Insert(onConflict = OnConflictStrategy.IGNORE)
16 | fun insert(vararg slide: StoryEntity)
17 |
18 | @Update(onConflict = OnConflictStrategy.IGNORE)
19 | fun update(vararg slide: StoryEntity)
20 |
21 | @Query("Select * From StoryEntity")
22 | fun getAll(): List
23 |
24 | @Query("Select * From StoryEntity")
25 | fun getAllFlowable(): LiveData>
26 |
27 | @Delete
28 | fun delete(slide: StoryEntity)
29 |
30 | @Transaction
31 | fun upsert(vararg slide: StoryEntity) {
32 | for (StoryEntity in slide) {
33 | insert(StoryEntity)
34 | update(StoryEntity)
35 | }
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/experiment/ExperimentActivity.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample.experiment
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import com.seanghay.studioexample.R
6 | import com.seanghay.studioexample.experiment.fragment.StudioFragment
7 |
8 |
9 | class ExperimentActivity : AppCompatActivity() {
10 |
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 | setContentView(R.layout.activity_experiment)
14 |
15 | if (savedInstanceState == null) {
16 | val fragment = StudioFragment.newInstance()
17 | supportFragmentManager.beginTransaction()
18 | .add(R.id.containerView, fragment, "studio")
19 | .setPrimaryNavigationFragment(fragment)
20 | .commitNow()
21 |
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/experiment/core/ProjectionUtils.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample.experiment.core
2 |
3 | import android.opengl.Matrix
4 |
5 |
6 | // Matrices
7 | object ProjectionUtils {
8 |
9 | fun times(result: FloatArray, a: FloatArray, b: FloatArray): FloatArray {
10 | Matrix.multiplyMM(result, 0, a, 0, b, 0)
11 | return result
12 | }
13 |
14 | fun identities(vararg elements: FloatArray) {
15 | elements.forEach {
16 | identity(it)
17 | }
18 | }
19 |
20 | fun identity(elements: FloatArray) {
21 | Matrix.setIdentityM(elements, 0)
22 | }
23 |
24 |
25 | fun applyLookAt(elements: FloatArray) {
26 | Matrix.setLookAtM(
27 | elements,
28 | 0,
29 | 0f,
30 | 0f,
31 | -3f,
32 | 0f,
33 | 0f,
34 | 0f,
35 | 0f,
36 | 1.0f,
37 | 0.0f
38 | )
39 | }
40 |
41 | fun applyAspectRatio(elements: FloatArray, ratio: Float) {
42 | Matrix.frustumM(elements, 0, -ratio, ratio, -1f, 1f, 3f, 7f)
43 | }
44 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/experiment/viewmodel/StudioViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample.experiment.viewmodel
2 |
3 | import android.net.Uri
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 |
7 | class StudioViewModel: ViewModel() {
8 |
9 | val photos = mutableListOf()
10 | val compressedPhotos = mutableListOf()
11 | val isLoading = MutableLiveData()
12 |
13 | init {
14 | isLoading.value = false
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/picasso/NewPicassoEngine.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample.picasso
2 |
3 | import android.content.Context
4 | import android.graphics.drawable.Drawable
5 | import android.net.Uri
6 | import android.widget.ImageView
7 | import com.squareup.picasso.Picasso
8 | import com.zhihu.matisse.engine.impl.PicassoEngine
9 |
10 | class NewPicassoEngine : PicassoEngine() {
11 | override fun loadImage(
12 | context: Context?,
13 | resizeX: Int,
14 | resizeY: Int,
15 | imageView: ImageView?,
16 | uri: Uri?
17 | ) {
18 | Picasso.get().load(uri).resize(resizeX, resizeY).priority(Picasso.Priority.HIGH)
19 | .centerInside().into(imageView)
20 | }
21 |
22 |
23 | override fun loadThumbnail(
24 | context: Context?,
25 | resize: Int,
26 | placeholder: Drawable?,
27 | imageView: ImageView?,
28 | uri: Uri?
29 | ) {
30 | Picasso.get().load(uri).apply {
31 | if (placeholder != null)
32 | placeholder(placeholder)
33 | }.resize(resize, resize)
34 | .centerCrop()
35 | .into(imageView)
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/seanghay/studioexample/sticker/QuoteDesigner.kt:
--------------------------------------------------------------------------------
1 | package com.seanghay.studioexample.sticker
2 |
3 | import android.graphics.Bitmap
4 | import android.graphics.PointF
5 | import android.graphics.Typeface
6 | import androidx.annotation.ColorInt
7 | import androidx.annotation.Px
8 |
9 | interface QuoteDesigner {
10 |
11 | fun getText(): CharSequence
12 | @Px
13 | fun getTextSize(): Float
14 | fun getTypeface(): Typeface
15 |
16 | @ColorInt
17 | fun getTextColor(): Int
18 | fun getTextRotation(): Float
19 | fun getScale(): Float
20 | fun getPosition(): PointF
21 |
22 | fun setText(text: CharSequence)
23 | fun setTextSize(@Px size: Float)
24 | fun setTextColor(@ColorInt textColor: Int)
25 | fun setTypeface(typeface: Typeface)
26 | fun getBitmap(): Bitmap
27 | fun updateQuote()
28 | fun setPosition(position: PointF)
29 | fun setTextRotation(angle: Float)
30 | fun setScale(scaleFactor: Float)
31 | }
--------------------------------------------------------------------------------
/app/src/main/res/animator/appbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/drawable-v24/image.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | -
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/check.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_brightness_4_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_check_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_check_circle_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_delete_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_disabled_check.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_filter_hdr_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_more_vert_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_pause.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_photo_filter_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_play.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_text_fields_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/togness.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/drawable/togness.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_experiment.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dropdown_menu_popup_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_story.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
19 |
20 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_transition.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/more.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/quote.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/raw/loop.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/app/src/main/res/raw/loop.wav
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #23374d
4 | #23374d
5 | #1089ff
6 | #0E73D6
7 | #000
8 | @color/colorAccent
9 | @android:color/white
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Studio
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/provider_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/bintrayconfig.gradle:
--------------------------------------------------------------------------------
1 | // Set default
2 | ext.modulePackageId = ""
3 |
4 | if (!project.rootProject.file('local.properties').exists()) {
5 | println "Not applying bintrayconfig.gradle"
6 | return
7 | }
8 | apply plugin: 'com.novoda.bintray-release'
9 |
10 | def getBintrayUserAndKey() {
11 | Properties properties = new Properties()
12 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
13 | return [
14 | properties.getProperty("bintray.user"),
15 | properties.getProperty("bintray.apikey")
16 | ]
17 | }
18 |
19 | if (versions == null || versions.publishVersion == null) {
20 | throw new IllegalStateException("Unable to reference publishVersion")
21 | }
22 |
23 | task checkBintrayConfig {
24 | doLast {
25 | def (user, key) = getBintrayUserAndKey()
26 | if (user == null || user.isEmpty() ||
27 | key == null || key.isEmpty()) {
28 | throw new IllegalStateException("Must specify Bintray user/API key in your local.properties.")
29 | }
30 | }
31 | }
32 |
33 | afterEvaluate {
34 | bintrayUpload.dependsOn checkBintrayConfig
35 | }
36 |
37 | def (user, key) = getBintrayUserAndKey()
38 | publish {
39 | bintrayUser = user
40 | bintrayKey = key
41 | userOrg = 'seanghay'
42 | groupId = 'com.seanghay'
43 | artifactId = 'studio'
44 | publishVersion = versions.publishVersion
45 | desc = 'A studio for video editor.'
46 | website = 'https://github.com/seanghay/studio'
47 | dryRun = false
48 | }
49 |
50 | ext.modulePackageId = publish.groupId + '.' + publish.artifactId
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | apply from: './dependencies.gradle'
2 | apply from: './versionsPlugin.gradle'
3 |
4 |
5 | buildscript {
6 | apply from: './dependencies.gradle'
7 |
8 | repositories {
9 | google()
10 | jcenter()
11 |
12 | }
13 | dependencies {
14 | classpath 'com.android.tools.build:gradle:' + versions.gradlePlugin
15 | classpath "com.diffplug.spotless:spotless-plugin-gradle:" + versions.spotlessPlugin
16 | classpath 'com.novoda:bintray-release:' + versions.bintrayRelease
17 | classpath 'com.github.ben-manes:gradle-versions-plugin:' + versions.versionsPlugin
18 | classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:' + versions.kotlin
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | google()
25 | jcenter()
26 | maven { url "https://jitpack.io" }
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/dependencies.gradle:
--------------------------------------------------------------------------------
1 | ext.versions = [
2 | minSdk : 21,
3 | compileSdk : 29,
4 | buildTools : '29.0.0',
5 | publishVersion : '1.0.1',
6 | publishVersionCode: 22,
7 |
8 | gradlePlugin : '3.5.1',
9 | spotlessPlugin : '3.24.3',
10 | versionsPlugin : '0.25.0',
11 | bintrayRelease : '0.9.1',
12 |
13 | kotlin : '1.3.61',
14 | androidx : '1.1.0',
15 | constraintLayout : '1.1.3',
16 | recyclerView : '1.0.0',
17 | material : '1.1.0-beta01',
18 |
19 | // Unit testing
20 | junit : '4.12',
21 | mockito : '3.1.0',
22 | mockitoKotlin : '2.1.0',
23 | truth : '1.0'
24 | ]
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seanghay/studio/40344013111ecd72c508b75775123b7daddc7fab/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Aug 21 10:40:29 ICT 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':studio'
2 |
--------------------------------------------------------------------------------
/spotless.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.diffplug.gradle.spotless"
2 |
3 | spotless {
4 | java {
5 | target "**/*.java"
6 | trimTrailingWhitespace()
7 | removeUnusedImports()
8 | googleJavaFormat()
9 | endWithNewline()
10 | }
11 | kotlin {
12 | target "**/*.kt"
13 | ktlint().userData(['indent_size': '2', 'continuation_indent_size': '2'])
14 | licenseHeaderFile '../spotless.license.kt'
15 | trimTrailingWhitespace()
16 | endWithNewline()
17 | }
18 | }
--------------------------------------------------------------------------------
/spotless.license.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
--------------------------------------------------------------------------------
/studio/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/studio/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply from: '../dependencies.gradle'
5 | apply from: '../bintrayconfig.gradle'
6 |
7 | android {
8 | compileSdkVersion versions.compileSdk
9 | defaultConfig {
10 | buildToolsVersion versions.buildTools
11 | minSdkVersion versions.minSdk
12 | targetSdkVersion versions.compileSdk
13 | versionCode versions.publishVersionCode
14 | versionName versions.publishVersion
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | compileOptions {
25 | sourceCompatibility = '1.8'
26 | targetCompatibility = '1.8'
27 | }
28 |
29 | lintOptions {
30 | abortOnError false
31 | }
32 |
33 | sourceSets {
34 | main.res.srcDirs = [
35 | 'src/main/res',
36 | 'src/main/res-public'
37 | ]
38 | }
39 | }
40 |
41 | dependencies {
42 | implementation fileTree(dir: 'libs', include: ['*.jar'])
43 | implementation "androidx.appcompat:appcompat:$versions.androidx"
44 | implementation "androidx.core:core-ktx:$versions.androidx"
45 |
46 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:" + versions.kotlin
47 | implementation 'com.google.android.exoplayer:exoplayer-core:2.10.5'
48 | api 'androidx.lifecycle:lifecycle-common-java8:2.1.0'
49 |
50 | implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
51 | implementation 'io.reactivex.rxjava2:rxjava:2.2.13'
52 | implementation "io.reactivex.rxjava2:rxkotlin:2.4.0"
53 |
54 | testImplementation 'junit:junit:4.12'
55 | androidTestImplementation 'androidx.test:runner:1.2.0'
56 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
57 | }
58 |
59 |
60 | apply from: '../spotless.gradle'
--------------------------------------------------------------------------------
/studio/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/studio/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/composer/AudioComposer.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.composer
17 |
18 | interface AudioComposer {
19 | fun setup()
20 | fun stepPipeline(): Boolean
21 | fun getWrittenPresentationTimeUs(): Long
22 | fun isFinished(): Boolean
23 | fun release()
24 | }
25 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/core/StudioDrawable.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.core
17 |
18 | import com.seanghay.studio.gles.RenderContext
19 |
20 | interface StudioDrawable : RenderContext {
21 |
22 | fun onSetup()
23 | fun renderAtProgress(progress: Float)
24 |
25 | override fun onCreated() {
26 | onSetup()
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/core/StudioRenderThread.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.core
17 |
18 | import android.graphics.SurfaceTexture
19 | import com.seanghay.studio.gles.egl.EglCore
20 | import com.seanghay.studio.gles.egl.EglWindowSurface
21 |
22 | class StudioRenderThread(private val surfaceTexture: SurfaceTexture) : Thread() {
23 |
24 | private val eglCore = EglCore()
25 | private lateinit var windowSurface: EglWindowSurface
26 | private var isRunning = true
27 | var drawable: StudioDrawable? = null
28 |
29 | var height: Int = -1
30 | var width: Int = -1
31 |
32 | private fun setup() {
33 | eglCore.setup()
34 | windowSurface = EglWindowSurface(eglCore, surfaceTexture)
35 | }
36 |
37 | fun recreate() {
38 | windowSurface.recreate(eglCore)
39 | }
40 |
41 | private fun swapBuffers() {
42 | windowSurface.swapBuffers()
43 | }
44 |
45 | private fun makeCurrent() {
46 | windowSurface.makeCurrent()
47 | }
48 |
49 | private fun release() {
50 | windowSurface.release()
51 | eglCore.release()
52 | }
53 |
54 | private fun drawFrame(): Boolean {
55 | return drawable?.onDraw() ?: false
56 | }
57 |
58 | override fun run() {
59 | setup()
60 | makeCurrent()
61 | drawable?.onSetup()
62 |
63 | while (isRunning && !interrupted()) {
64 | makeCurrent()
65 | if (drawFrame())
66 | swapBuffers()
67 | }
68 |
69 | release()
70 | }
71 |
72 | fun getEglCore(): EglCore = eglCore
73 |
74 | fun quit() {
75 | isRunning = false
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/core/StudioView.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.core
17 |
18 | import android.content.Context
19 | import android.util.AttributeSet
20 | import android.view.TextureView
21 | import java.io.File
22 |
23 | class StudioView : TextureView {
24 |
25 | private val studioEngine = StudioEngine()
26 |
27 | constructor(context: Context) : super(context)
28 | constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
29 | constructor(context: Context, attributeSet: AttributeSet, defStyle: Int) : super(
30 | context,
31 | attributeSet,
32 | defStyle
33 | )
34 |
35 | init {
36 | surfaceTextureListener = studioEngine
37 | }
38 |
39 | fun setFiles(files: List) {
40 | studioEngine.files = files
41 | studioEngine.begin()
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/RenderContext.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles
17 |
18 | import android.util.Size
19 |
20 | // Renderer
21 | interface RenderContext {
22 | fun onCreated()
23 | fun onDraw(): Boolean // SwapBuffer
24 | fun onSizeChanged(size: Size)
25 | }
26 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/RenderTarget.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles
17 |
18 | import android.content.Context
19 | import android.util.Size
20 | import com.seanghay.studio.gles.egl.EglCore
21 |
22 | // Previews
23 | interface RenderTarget {
24 | fun initialize(eglCore: EglCore)
25 | fun swapBuffers()
26 | fun makeCurrent()
27 | fun release()
28 | fun context(): Context
29 | fun getViewport(): Size
30 | }
31 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/annotation/AttrHandle.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.annotation
17 |
18 | /**
19 | * Everything that annotated with this is Attribute location in a shader
20 | */
21 | annotation class AttrHandle
22 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/annotation/GlContext.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.annotation
17 |
18 | /**
19 | * Everything that annotated with this must be call in GL Context
20 | */
21 | annotation class GlContext
22 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/annotation/UniformHandle.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.annotation
17 |
18 | /**
19 | * Everything that annotated with this is Uniform location in a shader
20 | */
21 | annotation class UniformHandle
22 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/egl/EglExtensions.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.egl
17 |
18 | import android.opengl.EGL14
19 | import android.opengl.GLES20
20 |
21 | /**
22 | * Error checking for OpenGL
23 | * @param message this will show up when it throw an exception
24 | * @param block a callback for OpenGL calls
25 | */
26 |
27 | inline fun glScope(message: String = "", block: (() -> T)): T {
28 | return block().also {
29 | var error: Int = GLES20.glGetError()
30 | while (error != GLES20.GL_NO_ERROR) {
31 | val errorMessage = error
32 | error = GLES20.glGetError()
33 | throw RuntimeException("GL Error: $message\n 0x${errorMessage.toString(16)}")
34 | }
35 | }
36 | }
37 |
38 | /**
39 | * Error checking for EGL
40 | * @param message this will show up when it throw an exception
41 | * @param block callback for EGL calls
42 | */
43 | inline fun eglScope(message: String = "", block: (() -> T)): T {
44 | return block().also {
45 | val error = EGL14.eglGetError()
46 | if (error != EGL14.EGL_SUCCESS) {
47 | throw RuntimeException("$message: EGL Error: 0x${error.toString(16)}")
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/egl/EglOffscreenSurface.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.egl
17 |
18 | class EglOffscreenSurface(
19 | eglCore: EglCore,
20 | width: Int,
21 | height: Int
22 | ) : EglSurfaceBase(eglCore) {
23 |
24 | init {
25 | createOffscreenSurface(width, height)
26 | }
27 |
28 | fun release() {
29 | releaseEglSurface()
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/egl/EglWindowSurface.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.egl
17 |
18 | import android.graphics.SurfaceTexture
19 | import android.view.Surface
20 |
21 | class EglWindowSurface : EglSurfaceBase {
22 |
23 | private var surface: Surface? = null
24 | private var releaseSurface = false
25 |
26 | constructor(
27 | eglCore: EglCore,
28 | surface: Surface?,
29 | releaseSurface: Boolean
30 | ) : super(eglCore) {
31 | createWindowSurface(surface)
32 | this.surface = surface
33 | this.releaseSurface = releaseSurface
34 | }
35 |
36 | constructor(eglCore: EglCore, surfaceTexture: SurfaceTexture) :
37 | super(eglCore) {
38 | createWindowSurface(surfaceTexture)
39 | }
40 |
41 | fun release() {
42 | releaseEglSurface()
43 | if (surface != null) {
44 | if (releaseSurface) surface?.release()
45 | surface = null
46 | }
47 | }
48 |
49 | fun recreate(newEglCore: EglCore) {
50 | if (surface == null)
51 | throw RuntimeException("Not yet implemented for surface texture")
52 |
53 | eglCore = newEglCore
54 | createWindowSurface(surface)
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/InputValue.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics
17 |
18 | import com.seanghay.studio.gles.annotation.GlContext
19 |
20 | abstract class InputValue(var name: String) {
21 |
22 | protected var cachedValue: T? = null
23 | protected var program: Int = -1
24 | protected var _location: Int = -1
25 |
26 | protected abstract fun loadLocation(): Int
27 |
28 | @GlContext
29 | @Throws(RuntimeException::class)
30 | open fun initialize(p: Int) {
31 | if (p == -1) throw RuntimeException("Invalid program")
32 | this.program = p
33 |
34 | _location = loadLocation()
35 | rationalChecks()
36 | }
37 |
38 | @Throws(RuntimeException::class)
39 | protected abstract fun rationalChecks()
40 |
41 | @GlContext
42 | abstract fun setValue(value: T)
43 |
44 | @GlContext
45 | abstract fun getValue(): T
46 |
47 | @Throws(RuntimeException::class)
48 | fun getLocation(): Int {
49 | rationalChecks()
50 | return _location
51 | }
52 |
53 | fun cachedValue(): T = cachedValue ?: throw RuntimeException("cachedValue was null")
54 | }
55 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/Matrix4f.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics
17 |
18 | import android.opengl.Matrix
19 |
20 | fun mat4(elements: FloatArray) = Matrix4f(elements)
21 | fun mat4() = Matrix4f()
22 |
23 | data class Matrix4f(var elements: FloatArray = FloatArray(4 * 4)) :
24 | Iterator by elements.iterator() {
25 |
26 | init {
27 | Matrix.setIdentityM(elements, 0)
28 | }
29 |
30 | operator fun get(index: Int) = elements[index]
31 |
32 | operator fun set(index: Int, value: Float) {
33 | elements[index] = value
34 | }
35 |
36 | operator fun times(mat4: Matrix4f): Matrix4f {
37 | val result = Matrix4f()
38 | Matrix.multiplyMM(
39 | result.elements, 0, elements,
40 | 0, mat4.elements, 0
41 | )
42 | return result
43 | }
44 |
45 | override fun equals(other: Any?): Boolean {
46 | if (this === other) return true
47 | if (javaClass != other?.javaClass) return false
48 |
49 | other as Matrix4f
50 |
51 | if (!elements.contentEquals(other.elements)) return false
52 |
53 | return true
54 | }
55 |
56 | override fun hashCode(): Int {
57 | return elements.contentHashCode()
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/Vector2f.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics
17 |
18 | internal fun vec2(x: Float, y: Float) = Vector2f(x, y)
19 | internal fun vec2(x: Float) = Vector2f(x, x)
20 | internal fun vec2() = Vector2f()
21 |
22 | data class Vector2f(
23 | var x: Float = 0f,
24 | var y: Float = 0f
25 | ) {
26 |
27 | val values get() = floatArrayOf(x, y)
28 |
29 | // TODO: Add transformations Add, Sub, Multiply, Divide
30 |
31 | companion object {
32 | fun valueOf(vararg values: Float): Vector2f {
33 | return Vector2f(values[0], values[1])
34 | }
35 |
36 | fun fromArray(values: FloatArray): Vector2f {
37 | return Vector2f(values[0], values[1])
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/Vector3f.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics
17 |
18 | internal fun vec3(x: Float, y: Float, z: Float) = Vector3f(x, y, z)
19 | internal fun vec3(x: Float) = Vector3f(x, x, x)
20 | internal fun vec3(vec2: Vector2f, z: Float) = Vector3f(vec2.x, vec2.y, z)
21 | internal fun vec3() = Vector3f()
22 |
23 | data class Vector3f(
24 | var x: Float = 0f,
25 | var y: Float = 0f,
26 | var z: Float = 0f
27 | ) {
28 |
29 | val values get() = floatArrayOf(x, y, z)
30 |
31 | // TODO: Add transformations Add, Sub, Multiply, Divide
32 |
33 | companion object {
34 | fun valueOf(vararg values: Float): Vector3f {
35 | return Vector3f(values[0], values[1], values[2])
36 | }
37 |
38 | fun fromArray(values: FloatArray): Vector3f {
39 | return Vector3f(values[0], values[1], values[2])
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/Vector4f.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics
17 |
18 | internal fun vec4(x: Float, y: Float, z: Float, a: Float) = Vector4f(x, y, z, a)
19 | internal fun vec4(x: Float) = Vector4f(x, x, x, x)
20 | internal fun vec4(vec3: Vector2f, z: Float, a: Float) = Vector4f(vec3.x, vec3.y, z, a)
21 | internal fun vec4(vec3: Vector3f, a: Float) = Vector4f(vec3.x, vec3.y, vec3.z, a)
22 | internal fun vec4() = Vector4f()
23 |
24 | data class Vector4f(
25 | var x: Float = 0f,
26 | var y: Float = 0f,
27 | var z: Float = 0f,
28 | var a: Float = 0f
29 | ) {
30 |
31 | var values
32 | get() = floatArrayOf(x, y, z, a)
33 | set(value) {
34 | x = value[0]
35 | y = value[1]
36 | z = value[2]
37 | a = value[3]
38 | }
39 |
40 | // TODO: Add transformations Add, Sub, Multiply, Divide
41 |
42 | companion object {
43 | fun valueOf(vararg values: Float): Vector4f {
44 | return Vector4f(values[0], values[1], values[2], values[3])
45 | }
46 |
47 | fun fromArray(values: FloatArray): Vector4f {
48 | return Vector4f(values[0], values[1], values[2], values[3])
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/attribute/Attribute.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.attribute
17 |
18 | import android.opengl.GLES20
19 | import com.seanghay.studio.gles.graphics.InputValue
20 |
21 | abstract class Attribute(name: String) : InputValue(name) {
22 |
23 | override fun loadLocation(): Int {
24 | return GLES20.glGetAttribLocation(program, name)
25 | }
26 |
27 | override fun rationalChecks() {
28 | if (program == -1) throw RuntimeException("Invalid program")
29 | if (_location == -1) throw RuntimeException("Attribute name: $name is not found!")
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/texture/BitmapTextureUniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.texture
17 |
18 | import android.graphics.Bitmap
19 | import android.opengl.GLUtils
20 |
21 | class BitmapTextureUniform(
22 | name: String,
23 | private val bitmap: Bitmap,
24 | texture2d: Texture2d = Texture2d()
25 | ) : Texture2dUniform(name, texture2d) {
26 |
27 | override fun configure() {
28 | super.configure()
29 | GLUtils.texImage2D(textureTarget, 0, bitmap, 0)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/texture/Texture.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.texture
17 |
18 | import android.opengl.GLES20
19 | import com.seanghay.studio.gles.annotation.GlContext
20 |
21 | open class Texture(var id: Int = NO_TEXTURE) {
22 |
23 | @GlContext
24 | open fun initialize(force: Boolean = false) {
25 | if (id == NO_TEXTURE || force) {
26 | createTexture()
27 | }
28 | }
29 |
30 | @GlContext
31 | open fun createTexture() {
32 | val args = IntArray(1)
33 | GLES20.glGenTextures(args.size, args, 0)
34 | id = args[0]
35 | }
36 |
37 | @GlContext
38 | open fun enable(textureTarget: Int) {
39 | GLES20.glBindTexture(textureTarget, id)
40 | }
41 |
42 | @GlContext
43 | open fun disable(textureTarget: Int) {
44 | GLES20.glBindTexture(textureTarget, 0)
45 | }
46 |
47 | inline fun use(textureTarget: Int, block: () -> Unit) {
48 | enable(textureTarget)
49 | block()
50 | disable(textureTarget)
51 | }
52 |
53 | fun release() {
54 | if (id == NO_TEXTURE) return
55 | val args = intArrayOf(id)
56 | GLES20.glDeleteTextures(1, args, 0)
57 | }
58 |
59 | companion object {
60 | const val NO_TEXTURE = -1
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/texture/Texture2d.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.texture
17 |
18 | import android.opengl.GLES20
19 |
20 | open class Texture2d : Texture() {
21 |
22 | override fun createTexture() {
23 | super.createTexture()
24 | }
25 |
26 | open fun configure(textureTarget: Int) {
27 | GLES20.glTexParameteri(
28 | textureTarget,
29 | GLES20.GL_TEXTURE_MIN_FILTER,
30 | GLES20.GL_LINEAR
31 | )
32 | GLES20.glTexParameteri(
33 | textureTarget,
34 | GLES20.GL_TEXTURE_MAG_FILTER,
35 | GLES20.GL_LINEAR
36 | )
37 | GLES20.glTexParameteri(
38 | textureTarget,
39 | GLES20.GL_TEXTURE_WRAP_S,
40 | GLES20.GL_CLAMP_TO_EDGE
41 | )
42 | GLES20.glTexParameteri(
43 | textureTarget,
44 | GLES20.GL_TEXTURE_WRAP_T,
45 | GLES20.GL_CLAMP_TO_EDGE
46 | )
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/texture/Texture2dUniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.texture
17 |
18 | import android.opengl.GLES20
19 |
20 | open class Texture2dUniform(name: String, var texture2d: Texture2d) :
21 | TextureUniform(name, texture2d) {
22 |
23 | override var textureTarget: Int = GLES20.GL_TEXTURE_2D
24 |
25 | override fun configure() {
26 | texture2d.configure(textureTarget)
27 | }
28 |
29 | override fun setValue(value: Int) {
30 | rationalChecks()
31 | GLES20.glUniform1i(_location, value)
32 | }
33 |
34 | override fun getValue(): Int {
35 | val args = IntArray(1)
36 | GLES20.glGetUniformiv(program, _location, args, 0)
37 | return args[0]
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/texture/TextureUniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.texture
17 |
18 | import android.opengl.GLES20
19 | import com.seanghay.studio.gles.graphics.uniform.Uniform
20 |
21 | abstract class TextureUniform(name: String, var texture: Texture) : Uniform(name) {
22 |
23 | abstract var textureTarget: Int
24 |
25 | private var id: Int
26 | get() = texture.id
27 | set(value) {
28 | texture.id = value
29 | }
30 |
31 | abstract fun configure()
32 |
33 | override fun initialize(p: Int) {
34 | super.initialize(p)
35 | texture.initialize()
36 | enable()
37 | configure()
38 | disable()
39 | }
40 |
41 | open fun setTextureToSlot(textureSlot: Int = GLES20.GL_TEXTURE0) {
42 | GLES20.glActiveTexture(textureSlot)
43 | enable()
44 | setValue(textureSlot - GLES20.GL_TEXTURE0)
45 | }
46 |
47 | fun enable() {
48 | rationalChecks()
49 | texture.enable(textureTarget)
50 | }
51 |
52 | fun disable() {
53 | texture.disable(textureTarget)
54 | }
55 |
56 | inline fun use(block: T.() -> Unit) {
57 | enable()
58 | if (this is T) block(this)
59 | disable()
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/uniform/BooleanUniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.uniform
17 |
18 | import android.opengl.GLES20
19 |
20 | class BooleanUniform(name: String) : Uniform(name) {
21 |
22 | override fun setValue(value: Boolean) {
23 | rationalChecks()
24 | GLES20.glUniform1i(
25 | getLocation(),
26 | if (value) GLES20.GL_TRUE else GLES20.GL_FALSE
27 | )
28 | }
29 |
30 | override fun getValue(): Boolean {
31 | rationalChecks()
32 | val args = IntArray(1)
33 | GLES20.glGetUniformiv(program, getLocation(), args, 0)
34 | return args[0] == GLES20.GL_TRUE
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/uniform/Float2Uniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.uniform
17 |
18 | import android.opengl.GLES20.glGetUniformfv
19 | import android.opengl.GLES20.glUniform2f
20 | import com.seanghay.studio.gles.graphics.Vector2f
21 |
22 | fun uniform2f(name: String) = Float2Uniform(name)
23 |
24 | class Float2Uniform(name: String) : Uniform(name) {
25 |
26 | override fun setValue(value: Vector2f) {
27 | rationalChecks()
28 | glUniform2f(getLocation(), value.x, value.y)
29 | cachedValue = value
30 | }
31 |
32 | override fun getValue(): Vector2f {
33 | rationalChecks()
34 | val args = FloatArray(2)
35 | glGetUniformfv(program, getLocation(), args, 0)
36 | return Vector2f.fromArray(args)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/uniform/Float3Uniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.uniform
17 |
18 | import android.opengl.GLES20.glGetUniformfv
19 | import android.opengl.GLES20.glUniform3f
20 | import com.seanghay.studio.gles.graphics.Vector3f
21 |
22 | fun uniform3f(name: String) = Float3Uniform(name)
23 |
24 | class Float3Uniform(name: String) : Uniform(name) {
25 |
26 | override fun setValue(value: Vector3f) {
27 | rationalChecks()
28 | glUniform3f(getLocation(), value.x, value.y, value.z)
29 | cachedValue = value
30 | }
31 |
32 | override fun getValue(): Vector3f {
33 | rationalChecks()
34 | val args = FloatArray(3)
35 | glGetUniformfv(program, getLocation(), args, 0)
36 | return Vector3f.fromArray(args)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/uniform/Float4Uniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.uniform
17 |
18 | import android.opengl.GLES20.glGetUniformfv
19 | import android.opengl.GLES20.glUniform4f
20 | import com.seanghay.studio.gles.graphics.Vector4f
21 |
22 | fun uniform4f(name: String) = Float4Uniform(name)
23 |
24 | class Float4Uniform(name: String) : Uniform(name) {
25 |
26 | override fun setValue(value: Vector4f) {
27 | rationalChecks()
28 | glUniform4f(getLocation(), value.x, value.y, value.z, value.a)
29 | cachedValue = value
30 | }
31 |
32 | override fun getValue(): Vector4f {
33 | rationalChecks()
34 | val args = FloatArray(4)
35 | glGetUniformfv(program, getLocation(), args, 0)
36 | return Vector4f.fromArray(args)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/uniform/FloatUniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.uniform
17 |
18 | import android.opengl.GLES20
19 |
20 | fun uniform1f(name: String) = FloatUniform(name)
21 |
22 | class FloatUniform(name: String) : Uniform(name) {
23 |
24 | override fun setValue(value: Float) {
25 | rationalChecks()
26 | if (cachedValue == value) return
27 | GLES20.glUniform1f(getLocation(), value)
28 | cachedValue = value
29 | }
30 |
31 | override fun getValue(): Float {
32 | rationalChecks()
33 | val args = FloatArray(1)
34 | GLES20.glGetUniformfv(program, getLocation(), args, 0)
35 | return args[0]
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/uniform/IntUniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.uniform
17 |
18 | import android.opengl.GLES20
19 |
20 | internal fun uniform1i(name: String) = IntUniform(name)
21 |
22 | class IntUniform(name: String) : Uniform(name) {
23 |
24 | override fun setValue(value: Int) {
25 | rationalChecks()
26 | GLES20.glUniform1i(getLocation(), value)
27 | }
28 |
29 | override fun getValue(): Int {
30 | rationalChecks()
31 | val args = IntArray(1)
32 | GLES20.glGetUniformiv(program, getLocation(), args, 0)
33 | return args[0]
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/uniform/Mat4Uniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.uniform
17 |
18 | import android.opengl.GLES20.glGetUniformfv
19 | import android.opengl.GLES20.glUniformMatrix4fv
20 | import com.seanghay.studio.gles.graphics.Matrix4f
21 |
22 | fun uniformMat4(name: String) = Mat4Uniform(name)
23 |
24 | class Mat4Uniform(name: String) : Uniform(name) {
25 |
26 | override fun setValue(value: Matrix4f) {
27 | rationalChecks()
28 | glUniformMatrix4fv(getLocation(), 1, false, value.elements, 0)
29 | cachedValue = value
30 | }
31 |
32 | override fun getValue(): Matrix4f {
33 | rationalChecks()
34 | val args = FloatArray(4 * 4)
35 | glGetUniformfv(program, getLocation(), args, 0)
36 | return Matrix4f(args)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/graphics/uniform/Uniform.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.graphics.uniform
17 |
18 | import android.opengl.GLES20
19 | import com.seanghay.studio.gles.graphics.InputValue
20 |
21 | abstract class Uniform(name: String) : InputValue(name) {
22 |
23 | // Sometimes, uniforms don't need to be existed.
24 | var isOptional = false
25 |
26 | override fun loadLocation(): Int {
27 | return GLES20.glGetUniformLocation(program, name)
28 | }
29 |
30 | override fun rationalChecks() {
31 | if (program == -1) throw RuntimeException("Invalid program")
32 | if (_location == -1 && !isOptional)
33 | throw RuntimeException("Uniform name: $name is not found! Did you Initialize it yet?")
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/kenburns/Kenburns.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.kenburns
17 |
18 | interface Kenburns {
19 | fun flip()
20 | fun getValue(progress: Float): Float
21 | }
22 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/kenburns/SimpleKenburns.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.kenburns
17 |
18 | import android.view.animation.Interpolator
19 | import android.view.animation.LinearInterpolator
20 | import androidx.annotation.FloatRange
21 | import com.seanghay.studio.utils.smoothStep
22 |
23 | class SimpleKenburns(
24 | open var scaleFrom: Float = 1f,
25 | open var scaleTo: Float = 1f,
26 | open var interpolator: Interpolator = LinearInterpolator()
27 | ) : Kenburns {
28 |
29 | override fun flip() {
30 | val tmp = scaleFrom
31 | scaleFrom = scaleTo
32 | scaleTo = tmp
33 | }
34 |
35 | override fun getValue(@FloatRange(from = 0.0, to = 1.0) progress: Float): Float {
36 | val interpolation = interpolator.getInterpolation(progress).smoothStep(0f, 1f)
37 | // Scale down to a value
38 | return if (scaleFrom >= scaleTo) scaleTo + (scaleFrom - scaleTo) * (1f - interpolation)
39 | // Scale up to a value
40 | else scaleFrom + (scaleTo - scaleFrom) * interpolation
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/ImageTextureShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader
17 |
18 | import android.graphics.Bitmap
19 | import com.seanghay.studio.gles.graphics.texture.BitmapTextureUniform
20 | import com.seanghay.studio.gles.graphics.texture.Texture2dUniform
21 |
22 | open class ImageTextureShader(var bitmap: Bitmap) : TextureShader() {
23 |
24 | var texture2d: Texture2dUniform = BitmapTextureUniform("texture", bitmap).autoInit()
25 |
26 | open fun draw() {
27 | draw(texture2d.texture)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/BrightnessFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.FloatUniform
19 | import com.seanghay.studio.gles.shader.TextureShader
20 |
21 | class BrightnessFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
22 |
23 | var brightness: Float = 0f
24 |
25 | val brightnessUniform: FloatUniform = FloatUniform("brightness").autoInit()
26 |
27 | override fun beforeDrawVertices() {
28 | brightnessUniform.setValue(brightness)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val FRAGMENT_SHADER = """
34 | precision mediump float;
35 |
36 | uniform sampler2D texture;
37 | uniform float brightness;
38 |
39 | varying vec2 texCoord;
40 |
41 | void main() {
42 | vec4 textureColor = texture2D(texture, texCoord);
43 |
44 | textureColor.rgb += vec3(brightness);
45 |
46 | gl_FragColor = textureColor;
47 | }
48 |
49 | """
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/ColorMatrixFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.graphics.mat4
19 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
20 | import com.seanghay.studio.gles.graphics.uniform.uniformMat4
21 | import com.seanghay.studio.gles.shader.TextureShader
22 |
23 | open class ColorMatrixFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
24 |
25 | var colorMatrix = mat4()
26 |
27 | var intensity = 1.0f
28 |
29 | var colorMatrixUniform = uniformMat4("colorMatrix").autoInit()
30 | var intensityUniform = uniform1f("intensity").autoInit()
31 |
32 | override fun beforeDrawVertices() {
33 | super.beforeDrawVertices()
34 | colorMatrixUniform.setValue(colorMatrix)
35 | intensityUniform.setValue(intensity)
36 | }
37 |
38 | companion object {
39 | // language=glsl
40 | const val FRAGMENT_SHADER = """
41 |
42 | precision mediump float;
43 |
44 | uniform sampler2D texture;
45 | uniform mat4 colorMatrix;
46 | uniform float intensity;
47 |
48 | varying vec2 texCoord;
49 |
50 | void main() {
51 | vec4 textureColor = texture2D(texture, texCoord);
52 | vec4 outputColor = textureColor * colorMatrix;
53 |
54 | gl_FragColor = (intensity * outputColor) + ((1.0 - intensity) * textureColor);
55 | }
56 |
57 | """
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/ContrastFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.FloatUniform
19 | import com.seanghay.studio.gles.shader.TextureShader
20 |
21 | class ContrastFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
22 |
23 | var contrast: Float = 1.0f
24 |
25 | val contrastUniform: FloatUniform = FloatUniform("contrast").autoInit()
26 |
27 | override fun beforeDrawVertices() {
28 | contrastUniform.setValue(contrast)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val FRAGMENT_SHADER = """
34 | precision mediump float;
35 |
36 | uniform sampler2D texture;
37 | uniform float contrast;
38 |
39 | varying vec2 texCoord;
40 |
41 | void main() {
42 | vec4 textureColor = texture2D(texture, texCoord);
43 | gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureColor.w);
44 | }
45 |
46 | """
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/GammaFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 | import com.seanghay.studio.gles.shader.TextureShader
20 |
21 | class GammaFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
22 |
23 | var gamma = 1f
24 | var gammaUniform = uniform1f("gamma").autoInit()
25 |
26 | override fun beforeDrawVertices() {
27 | super.beforeDrawVertices()
28 | gammaUniform.setValue(gamma)
29 | }
30 |
31 | companion object {
32 |
33 | // language=glsl
34 | const val FRAGMENT_SHADER = """
35 | precision mediump float;
36 |
37 | uniform sampler2D texture;
38 | uniform float gamma;
39 |
40 | varying vec2 texCoord;
41 |
42 | void main() {
43 | vec4 textureColor = texture2D(texture, texCoord);
44 | gl_FragColor = vec4(pow(textureColor.rgb, vec3(gamma)), textureColor.w);
45 | }
46 |
47 | """
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/GrayscaleFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.shader.TextureShader
19 |
20 | class GrayscaleFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
21 | companion object {
22 | // language=glsl
23 | const val FRAGMENT_SHADER = """
24 | precision mediump float;
25 | const vec3 W = vec3(0.2125, 0.7154, 0.0721);
26 | uniform sampler2D texture;
27 | varying vec2 texCoord;
28 |
29 | void main() {
30 | vec4 textureColor = texture2D(texture, texCoord);
31 | float luminance = dot(textureColor.rgb, W);
32 | gl_FragColor = vec4(vec3(luminance), textureColor.a);
33 | }
34 | """
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/OverlayBlenderFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform4f
19 | import com.seanghay.studio.gles.graphics.vec4
20 | import com.seanghay.studio.gles.shader.TextureShader
21 | import com.seanghay.studio.utils.colorArray
22 |
23 | class OverlayBlenderFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
24 |
25 | var color = vec4(0.0f, 0.0f, 0.0f, 0.0f)
26 |
27 | var colorUniform = uniform4f("overlayColor").autoInit()
28 |
29 | fun setColor(color: Int) {
30 | this.color.values = color.colorArray
31 | }
32 |
33 | override fun beforeDrawVertices() {
34 | super.beforeDrawVertices()
35 | colorUniform.setValue(color)
36 | }
37 |
38 | companion object {
39 |
40 | // language=glsl
41 | const val FRAGMENT_SHADER = """
42 | precision mediump float;
43 |
44 | uniform sampler2D texture;
45 | uniform vec4 overlayColor;
46 |
47 | varying vec2 texCoord;
48 |
49 | void main() {
50 | vec4 textureColor = texture2D(texture, texCoord);
51 | gl_FragColor = textureColor + overlayColor;
52 | }
53 |
54 | """
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/SaturationFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.FloatUniform
19 | import com.seanghay.studio.gles.shader.TextureShader
20 |
21 | class SaturationFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
22 |
23 | var saturation: Float = 1.0f
24 |
25 | val saturationUniform: FloatUniform = FloatUniform("saturation").autoInit()
26 |
27 | override fun beforeDrawVertices() {
28 | saturationUniform.setValue(saturation)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val FRAGMENT_SHADER = """
34 | precision mediump float;
35 |
36 | const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
37 |
38 | uniform sampler2D texture;
39 | uniform float saturation;
40 |
41 | varying vec2 texCoord;
42 |
43 | void main() {
44 | vec4 textureColor = texture2D(texture, texCoord);
45 | float luminance = dot(textureColor.rgb, luminanceWeighting);
46 | vec3 greyScaleColor = vec3(luminance);
47 | gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);
48 | }
49 |
50 | """
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/SepiaToneFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | class SepiaToneFilterShader : ColorMatrixFilterShader() {
19 |
20 | init {
21 | colorMatrix.elements = floatArrayOf(
22 | 0.3588f, 0.7044f, 0.1368f, 0.0f,
23 | 0.2990f, 0.5870f, 0.1140f, 0.0f,
24 | 0.2392f, 0.4696f, 0.0912f, 0.0f,
25 | 0f, 0f, 0f, 1.0f
26 | )
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/TintFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 | import com.seanghay.studio.gles.shader.TextureShader
20 |
21 | class TintFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
22 |
23 | var tint = 0f
24 | var tintUniform = uniform1f("tint").autoInit()
25 |
26 | override fun beforeDrawVertices() {
27 | super.beforeDrawVertices()
28 | tintUniform.setValue(tint)
29 | }
30 |
31 | companion object {
32 |
33 | // language=glsl
34 | const val FRAGMENT_SHADER = """
35 | precision mediump float;
36 |
37 | uniform sampler2D texture;
38 | uniform float tint;
39 | varying vec2 texCoord;
40 |
41 | void main() {
42 | vec4 textureColor = texture2D(texture, texCoord);
43 | textureColor.g += tint;
44 | gl_FragColor = textureColor;
45 | }
46 |
47 | """
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/VibrantFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 | import com.seanghay.studio.gles.shader.TextureShader
20 |
21 | class VibrantFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
22 |
23 | var vibrant = 0f
24 |
25 | var vibrantUniform = uniform1f("vibrant").autoInit()
26 |
27 | override fun beforeDrawVertices() {
28 | super.beforeDrawVertices()
29 | vibrantUniform.setValue(vibrant)
30 | }
31 |
32 | companion object {
33 |
34 | // language=glsl
35 | const val FRAGMENT_SHADER = """
36 | precision mediump float;
37 |
38 | uniform sampler2D texture;
39 | uniform float vibrant;
40 | varying vec2 texCoord;
41 |
42 | void main() {
43 | vec4 textureColor = texture2D(texture, texCoord);
44 |
45 | float mx = max(max(textureColor.r, textureColor.g), textureColor.b);
46 | float average = (textureColor.r + textureColor.g + textureColor.b) / 3.0;
47 | float amt = (mx - average) * (-vibrant * 3.0);
48 |
49 | textureColor.rgb = mix(textureColor.rgb, vec3(mx), amt);
50 |
51 | gl_FragColor = textureColor;
52 | }
53 |
54 | """
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/shader/filter/WarmFilterShader.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.shader.filter
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.FloatUniform
19 | import com.seanghay.studio.gles.shader.TextureShader
20 |
21 | class WarmFilterShader : TextureShader(fragmentShaderSource = FRAGMENT_SHADER) {
22 |
23 | var warmth: Float = 0f
24 |
25 | val warmUniform: FloatUniform = FloatUniform("warmth").autoInit()
26 |
27 | override fun beforeDrawVertices() {
28 | warmUniform.setValue(warmth)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val FRAGMENT_SHADER = """
34 | precision mediump float;
35 |
36 | uniform sampler2D texture;
37 | uniform float warmth;
38 |
39 | varying vec2 texCoord;
40 |
41 | void main() {
42 | vec4 textureColor = texture2D(texture, texCoord);
43 |
44 | textureColor.r += warmth;
45 | textureColor.b -= warmth;
46 |
47 | gl_FragColor = textureColor;
48 | }
49 | """
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/AngularTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class AngularTransition : Transition("angular", SOURCE, 1000L) {
21 |
22 | open var startingAngle: Float = 90f
23 | open var startingAngleUniform = uniform1f("startingAngle").autoInit()
24 |
25 | override fun onUpdateUniforms() {
26 | super.onUpdateUniforms()
27 |
28 | startingAngleUniform.setValue(startingAngle)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val SOURCE = """
34 | // Author: Fernando Kuteken
35 | // License: MIT
36 |
37 | #define PI 3.141592653589
38 |
39 | uniform float startingAngle; // = 90;
40 |
41 | vec4 transition (vec2 uv) {
42 |
43 | float offset = startingAngle * PI / 180.0;
44 | float angle = atan(uv.y - 0.5, uv.x - 0.5) + offset;
45 | float normalizedAngle = (angle + PI) / (2.0 * PI);
46 |
47 | normalizedAngle = normalizedAngle - floor(normalizedAngle);
48 |
49 | return mix(
50 | getFromColor(uv),
51 | getToColor(uv),
52 | step(normalizedAngle, progress)
53 | );
54 | }
55 |
56 | """
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/AssetTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import android.content.Context
19 |
20 | open class AssetTransition(
21 | private val context: Context,
22 | private val filename: String,
23 | name: String
24 | ) : Transition(name, "", 1000) {
25 |
26 | init {
27 | source = readTextFromAsset()
28 | }
29 |
30 | private fun readTextFromAsset(): String {
31 | return context.assets.open(filename).readBytes().toString(Charsets.UTF_8)
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/BurnTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.Vector3f
19 | import com.seanghay.studio.gles.graphics.uniform.uniform3f
20 |
21 | open class BurnTransition : Transition("burn", SOURCE, 1000L) {
22 |
23 | open var color: Vector3f = Vector3f(0.9f, 0.4f, 0.2f)
24 | open var colorUniform = uniform3f("color").autoInit()
25 |
26 | override fun onUpdateUniforms() {
27 | super.onUpdateUniforms()
28 |
29 | colorUniform.setValue(color)
30 | }
31 |
32 | companion object {
33 | // language=glsl
34 | const val SOURCE = """
35 | // author: gre
36 | // License: MIT
37 | uniform vec3 color /* = vec3(0.9, 0.4, 0.2) */;
38 | vec4 transition (vec2 uv) {
39 | return mix(
40 | getFromColor(uv) + vec4(progress*color, 1.0),
41 | getToColor(uv) + vec4((1.0-progress)*color, 1.0),
42 | progress
43 | );
44 | }
45 |
46 | """
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/CannabisleafTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class CannabisleafTransition : Transition("cannabisleaf", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // Author: @Flexi23
24 | // License: MIT
25 |
26 | // inspired by http://www.wolframalpha.com/input/?i=cannabis+curve
27 |
28 | vec4 transition (vec2 uv) {
29 | if(progress == 0.0){
30 | return getFromColor(uv);
31 | }
32 | vec2 leaf_uv = (uv - vec2(0.5))/10./pow(progress,3.5);
33 | leaf_uv.y += 0.35;
34 | float r = 0.18;
35 | float o = atan(leaf_uv.y, leaf_uv.x);
36 | return mix(getFromColor(uv), getToColor(uv), 1.-step(1. - length(leaf_uv)+r*(1.+sin(o))*(1.+0.9 * cos(8.*o))*(1.+0.1*cos(24.*o))*(0.9+0.05*cos(200.*o)), 1.));
37 | }
38 |
39 | """
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/CircleCropTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.Vector4f
19 | import com.seanghay.studio.gles.graphics.uniform.uniform4f
20 |
21 | open class CircleCropTransition : Transition("circle-crop", SOURCE, 1000L) {
22 |
23 | open var bgcolor: Vector4f = Vector4f(0f, 0f, 0f, 1f)
24 | open var bgcolorUniform = uniform4f("bgcolor").autoInit()
25 |
26 | override fun onUpdateUniforms() {
27 | super.onUpdateUniforms()
28 |
29 | bgcolorUniform.setValue(bgcolor)
30 | }
31 |
32 | companion object {
33 | // language=glsl
34 | const val SOURCE = """
35 | // License: MIT
36 | // Author: fkuteken
37 | // ported by gre from https://gist.github.com/fkuteken/f63e3009c1143950dee9063c3b83fb88
38 |
39 | uniform vec4 bgcolor; // = vec4(0.0, 0.0, 0.0, 1.0)
40 |
41 |
42 | vec4 transition(vec2 p) {
43 | vec2 ratio2 = vec2(1.0, 1.0 / ratio);
44 | float s = pow(2.0 * abs(progress - 0.5), 3.0);
45 |
46 | float dist = length((vec2(p) - 0.5) * ratio2);
47 | return mix(
48 | progress < 0.5 ? getFromColor(p) : getToColor(p), // branching is ok here as we statically depend on progress uniform (branching won't change over pixels)
49 | bgcolor,
50 | step(s, dist)
51 | );
52 | }
53 |
54 | """
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/CircleTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.Vector2f
19 | import com.seanghay.studio.gles.graphics.Vector3f
20 | import com.seanghay.studio.gles.graphics.uniform.uniform2f
21 | import com.seanghay.studio.gles.graphics.uniform.uniform3f
22 |
23 | open class CircleTransition : Transition("circle", SOURCE, 1000L) {
24 |
25 | open var center: Vector2f = Vector2f(0.5f, 0.5f)
26 | open var centerUniform = uniform2f("center").autoInit()
27 | open var backColor: Vector3f = Vector3f(0.1f, 0.1f, 0.1f)
28 | open var backColorUniform = uniform3f("backColor").autoInit()
29 |
30 | override fun onUpdateUniforms() {
31 | super.onUpdateUniforms()
32 |
33 | centerUniform.setValue(center)
34 | backColorUniform.setValue(backColor)
35 | }
36 |
37 | companion object {
38 | // language=glsl
39 | const val SOURCE = """
40 | // Author: Fernando Kuteken
41 | // License: MIT
42 |
43 | uniform vec2 center; // = vec2(0.5, 0.5);
44 | uniform vec3 backColor; // = vec3(0.1, 0.1, 0.1);
45 |
46 | vec4 transition (vec2 uv) {
47 |
48 | float distance = length(uv - center);
49 | float radius = sqrt(8.0) * abs(progress - 0.5);
50 |
51 | if (distance > radius) {
52 | return vec4(backColor, 1.0);
53 | }
54 | else {
55 | if (progress < 0.5) return getFromColor(uv);
56 | else return getToColor(uv);
57 | }
58 | }
59 |
60 | """
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/CircleopenTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.BooleanUniform
19 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
20 |
21 | open class CircleopenTransition : Transition("circleopen", SOURCE, 1000L) {
22 |
23 | open var smoothness: Float = 0.3f
24 | open var smoothnessUniform = uniform1f("smoothness").autoInit()
25 | open var opening: Boolean = true
26 | open var openingUniform = BooleanUniform("opening").autoInit()
27 |
28 | override fun onUpdateUniforms() {
29 | super.onUpdateUniforms()
30 |
31 | smoothnessUniform.setValue(smoothness)
32 | openingUniform.setValue(opening)
33 | }
34 |
35 | companion object {
36 | // language=glsl
37 | const val SOURCE = """
38 | // author: gre
39 | // License: MIT
40 | uniform float smoothness; // = 0.3
41 | uniform bool opening; // = true
42 |
43 | const vec2 center = vec2(0.5, 0.5);
44 | const float SQRT_2 = 1.414213562373;
45 |
46 | vec4 transition (vec2 uv) {
47 | float x = opening ? progress : 1.-progress;
48 | float m = smoothstep(-smoothness, 0.0, SQRT_2*distance(center, uv) - x*(1.+smoothness));
49 | return mix(getFromColor(uv), getToColor(uv), opening ? 1.-m : m);
50 | }
51 |
52 | """
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/ColorphaseTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.Vector4f
19 | import com.seanghay.studio.gles.graphics.uniform.uniform4f
20 |
21 | open class ColorphaseTransition : Transition("colorphase", SOURCE, 1000L) {
22 |
23 | open var fromStep: Vector4f = Vector4f(0f, 0.2f, 0.4f, 0f)
24 | open var fromStepUniform = uniform4f("fromStep").autoInit()
25 | open var toStep: Vector4f = Vector4f(0.6f, 0.8f, 1f, 1f)
26 | open var toStepUniform = uniform4f("toStep").autoInit()
27 |
28 | override fun onUpdateUniforms() {
29 | super.onUpdateUniforms()
30 |
31 | fromStepUniform.setValue(fromStep)
32 | toStepUniform.setValue(toStep)
33 | }
34 |
35 | companion object {
36 | // language=glsl
37 | const val SOURCE = """
38 | // Author: gre
39 | // License: MIT
40 |
41 | // Usage: fromStep and toStep must be in [0.0, 1.0] range
42 | // and all(fromStep) must be < all(toStep)
43 |
44 | uniform vec4 fromStep; // = vec4(0.0, 0.2, 0.4, 0.0)
45 | uniform vec4 toStep; // = vec4(0.6, 0.8, 1.0, 1.0)
46 |
47 | vec4 transition (vec2 uv) {
48 | vec4 a = getFromColor(uv);
49 | vec4 b = getToColor(uv);
50 | return mix(a, b, smoothstep(fromStep, toStep, vec4(progress)));
51 | }
52 |
53 | """
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/ColourDistanceTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class ColourDistanceTransition : Transition("colour-distance", SOURCE, 1000L) {
21 |
22 | open var power: Float = 5f
23 | open var powerUniform = uniform1f("power").autoInit()
24 |
25 | override fun onUpdateUniforms() {
26 | super.onUpdateUniforms()
27 |
28 | powerUniform.setValue(power)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val SOURCE = """
34 | // License: MIT
35 | // Author: P-Seebauer
36 | // ported by gre from https://gist.github.com/P-Seebauer/2a5fa2f77c883dd661f9
37 |
38 | uniform float power; // = 5.0
39 |
40 | vec4 transition(vec2 p) {
41 | vec4 fTex = getFromColor(p);
42 | vec4 tTex = getToColor(p);
43 | float m = step(distance(fTex, tTex), progress);
44 | return mix(
45 | mix(fTex, tTex, m),
46 | tTex,
47 | pow(progress, power)
48 | );
49 | }
50 |
51 | """
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/CrosswarpTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class CrosswarpTransition : Transition("crosswarp", SOURCE, 2000) {
19 | companion object {
20 | // language=glsl
21 | const val SOURCE = """
22 | vec4 transition(vec2 p) {
23 | float x = progress;
24 | x=smoothstep(.0,1.0,(x*2.0+p.x-1.0));
25 | return mix(getFromColor((p-.5)*(1.-x)+.5), getToColor((p-.5)*x+.5), x);
26 | }
27 |
28 | """
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/DirectionalTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.Vector2f
19 | import com.seanghay.studio.gles.graphics.uniform.uniform2f
20 |
21 | open class DirectionalTransition : Transition("directional", SOURCE, 1000L) {
22 |
23 | open var direction: Vector2f = Vector2f(0f, 1f)
24 | open var directionUniform = uniform2f("direction").autoInit()
25 |
26 | override fun onUpdateUniforms() {
27 | super.onUpdateUniforms()
28 |
29 | directionUniform.setValue(direction)
30 | }
31 |
32 | companion object {
33 | // language=glsl
34 | const val SOURCE = """
35 | // Author: Gaëtan Renaudeau
36 | // License: MIT
37 |
38 | uniform vec2 direction; // = vec2(0.0, 1.0)
39 |
40 | vec4 transition (vec2 uv) {
41 | vec2 p = uv + progress * sign(direction);
42 | vec2 f = fract(p);
43 | return mix(
44 | getToColor(f),
45 | getFromColor(f),
46 | step(0.0, p.y) * step(p.y, 1.0) * step(0.0, p.x) * step(p.x, 1.0)
47 | );
48 | }
49 |
50 | """
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/DirectionalwarpTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.Vector2f
19 | import com.seanghay.studio.gles.graphics.uniform.uniform2f
20 |
21 | open class DirectionalwarpTransition : Transition("directionalwarp", SOURCE, 1000L) {
22 |
23 | open var direction: Vector2f = Vector2f(-1f, 1f)
24 | open var directionUniform = uniform2f("direction").autoInit()
25 |
26 | override fun onUpdateUniforms() {
27 | super.onUpdateUniforms()
28 |
29 | directionUniform.setValue(direction)
30 | }
31 |
32 | companion object {
33 | // language=glsl
34 | const val SOURCE = """
35 | // Author: pschroen
36 | // License: MIT
37 |
38 | uniform vec2 direction; // = vec2(-1.0, 1.0)
39 |
40 | const float smoothness = 0.5;
41 | const vec2 center = vec2(0.5, 0.5);
42 |
43 | vec4 transition (vec2 uv) {
44 | vec2 v = normalize(direction);
45 | v /= abs(v.x) + abs(v.y);
46 | float d = v.x * center.x + v.y * center.y;
47 | float m = 1.0 - smoothstep(-smoothness, 0.0, v.x * uv.x + v.y * uv.y - (d - 0.5 + progress * (1.0 + smoothness)));
48 | return mix(getFromColor((uv - 0.5) * (1.0 - m) + 0.5), getToColor((uv - 0.5) * m + 0.5), m);
49 | }
50 |
51 | """
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/DirectionalwipeTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.Vector2f
19 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
20 | import com.seanghay.studio.gles.graphics.uniform.uniform2f
21 |
22 | open class DirectionalwipeTransition : Transition("directionalwipe", SOURCE, 1000L) {
23 |
24 | open var direction: Vector2f = Vector2f(1f, -1f)
25 | open var directionUniform = uniform2f("direction").autoInit()
26 | open var smoothness: Float = 0.5f
27 | open var smoothnessUniform = uniform1f("smoothness").autoInit()
28 |
29 | override fun onUpdateUniforms() {
30 | super.onUpdateUniforms()
31 |
32 | directionUniform.setValue(direction)
33 | smoothnessUniform.setValue(smoothness)
34 | }
35 |
36 | companion object {
37 | // language=glsl
38 | const val SOURCE = """
39 | // Author: gre
40 | // License: MIT
41 |
42 | uniform vec2 direction; // = vec2(1.0, -1.0)
43 | uniform float smoothness; // = 0.5
44 |
45 | const vec2 center = vec2(0.5, 0.5);
46 |
47 | vec4 transition (vec2 uv) {
48 | vec2 v = normalize(direction);
49 | v /= abs(v.x)+abs(v.y);
50 | float d = v.x * center.x + v.y * center.y;
51 | float m =
52 | (1.0-step(progress, 0.0)) * // there is something wrong with our formula that makes m not equals 0.0 with progress is 0.0
53 | (1.0 - smoothstep(-smoothness, 0.0, v.x * uv.x + v.y * uv.y - (d-0.5+progress*(1.+smoothness))));
54 | return mix(getFromColor(uv), getToColor(uv), m);
55 | }
56 |
57 | """
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/DreamyTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class DreamyTransition : Transition("dreamy", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // Author: mikolalysenko
24 | // License: MIT
25 |
26 | vec2 offset(float progress, float x, float theta) {
27 | float phase = progress*progress + progress + theta;
28 | float shifty = 0.03*progress*cos(10.0*(progress+x));
29 | return vec2(0, shifty);
30 | }
31 | vec4 transition(vec2 p) {
32 | return mix(getFromColor(p + offset(progress, p.x, 0.0)), getToColor(p + offset(1.0-progress, p.x, 3.14)), progress);
33 | }
34 |
35 | """
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/FadeTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class FadeTransition(name: String, duration: Long) : Transition(
19 | name, SOURCE, duration
20 | ) {
21 |
22 | companion object {
23 | // language=glsl
24 | const val SOURCE = """
25 | vec4 transition(vec2 uv) {
26 | return mix(
27 | getFromColor(uv),
28 | getToColor(uv),
29 | progress);
30 | }
31 | """
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/FadecolorTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.Vector3f
19 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
20 | import com.seanghay.studio.gles.graphics.uniform.uniform3f
21 |
22 | open class FadecolorTransition : Transition("fadecolor", SOURCE, 1000L) {
23 |
24 | open var color: Vector3f = Vector3f(0f, 0f, 0f)
25 | open var colorUniform = uniform3f("color").autoInit()
26 | open var colorPhase: Float = 0.4f
27 | open var colorPhaseUniform = uniform1f("colorPhase").autoInit()
28 |
29 | override fun onUpdateUniforms() {
30 | super.onUpdateUniforms()
31 |
32 | colorUniform.setValue(color)
33 | colorPhaseUniform.setValue(colorPhase)
34 | }
35 |
36 | companion object {
37 | // language=glsl
38 | const val SOURCE = """
39 | // author: gre
40 | // License: MIT
41 | uniform vec3 color;// = vec3(0.0)
42 | uniform float colorPhase/* = 0.4 */; // if 0.0, there is no black phase, if 0.9, the black phase is very important
43 | vec4 transition (vec2 uv) {
44 | return mix(
45 | mix(vec4(color, 1.0), getFromColor(uv), smoothstep(1.0-colorPhase, 0.0, progress)),
46 | mix(vec4(color, 1.0), getToColor(uv), smoothstep( colorPhase, 1.0, progress)),
47 | progress);
48 | }
49 |
50 | """
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/FadegrayscaleTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class FadegrayscaleTransition : Transition("fadegrayscale", SOURCE, 1000L) {
21 |
22 | open var intensity: Float = 0.3f
23 | open var intensityUniform = uniform1f("intensity").autoInit()
24 |
25 | override fun onUpdateUniforms() {
26 | super.onUpdateUniforms()
27 |
28 | intensityUniform.setValue(intensity)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val SOURCE = """
34 | // Author: gre
35 | // License: MIT
36 |
37 | uniform float intensity; // = 0.3; // if 0.0, the image directly turn grayscale, if 0.9, the grayscale transition phase is very important
38 |
39 | vec3 grayscale (vec3 color) {
40 | return vec3(0.2126*color.r + 0.7152*color.g + 0.0722*color.b);
41 | }
42 |
43 | vec4 transition (vec2 uv) {
44 | vec4 fc = getFromColor(uv);
45 | vec4 tc = getToColor(uv);
46 | return mix(
47 | mix(vec4(grayscale(fc.rgb), 1.0), fc, smoothstep(1.0-intensity, 0.0, progress)),
48 | mix(vec4(grayscale(tc.rgb), 1.0), tc, smoothstep( intensity, 1.0, progress)),
49 | progress);
50 | }
51 |
52 | """
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/FlyeyeTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class FlyeyeTransition : Transition("flyeye", SOURCE, 1000L) {
21 |
22 | open var size: Float = 0.04f
23 | open var sizeUniform = uniform1f("size").autoInit()
24 | open var zoom: Float = 50f
25 | open var zoomUniform = uniform1f("zoom").autoInit()
26 | open var colorSeparation: Float = 0.3f
27 | open var colorSeparationUniform = uniform1f("colorSeparation").autoInit()
28 |
29 | override fun onUpdateUniforms() {
30 | super.onUpdateUniforms()
31 |
32 | sizeUniform.setValue(size)
33 | zoomUniform.setValue(zoom)
34 | colorSeparationUniform.setValue(colorSeparation)
35 | }
36 |
37 | companion object {
38 | // language=glsl
39 | const val SOURCE = """
40 | // Author: gre
41 | // License: MIT
42 | uniform float size; // = 0.04
43 | uniform float zoom; // = 50.0
44 | uniform float colorSeparation; // = 0.3
45 |
46 | vec4 transition(vec2 p) {
47 | float inv = 1. - progress;
48 | vec2 disp = size*vec2(cos(zoom*p.x), sin(zoom*p.y));
49 | vec4 texTo = getToColor(p + inv*disp);
50 | vec4 texFrom = vec4(
51 | getFromColor(p + progress*disp*(1.0 - colorSeparation)).r,
52 | getFromColor(p + progress*disp).g,
53 | getFromColor(p + progress*disp*(1.0 + colorSeparation)).b,
54 | 1.0);
55 | return texTo*progress + texFrom*inv;
56 | }
57 |
58 | """
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/GlitchMemoriesTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class GlitchMemoriesTransition : Transition("glitch-memories", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // author: Gunnar Roth
24 | // based on work from natewave
25 | // license: MIT
26 | vec4 transition(vec2 p) {
27 | vec2 block = floor(p.xy / vec2(16));
28 | vec2 uv_noise = block / vec2(64);
29 | uv_noise += floor(vec2(progress) * vec2(1200.0, 3500.0)) / vec2(64);
30 | vec2 dist = progress > 0.0 ? (fract(uv_noise) - 0.5) * 0.3 *(1.0 -progress) : vec2(0.0);
31 | vec2 red = p + dist * 0.2;
32 | vec2 green = p + dist * .3;
33 | vec2 blue = p + dist * .5;
34 |
35 | return vec4(mix(getFromColor(red), getToColor(red), progress).r,mix(getFromColor(green), getToColor(green), progress).g,mix(getFromColor(blue), getToColor(blue), progress).b,1.0);
36 | }
37 |
38 |
39 | """
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/HeartTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class HeartTransition : Transition("heart", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // Author: gre
24 | // License: MIT
25 |
26 | float inHeart (vec2 p, vec2 center, float size) {
27 | if (size==0.0) return 0.0;
28 | vec2 o = (p-center)/(1.6*size);
29 | float a = o.x*o.x+o.y*o.y-0.3;
30 | return step(a*a*a, o.x*o.x*o.y*o.y*o.y);
31 | }
32 | vec4 transition (vec2 uv) {
33 | return mix(
34 | getFromColor(uv),
35 | getToColor(uv),
36 | inHeart(uv, vec2(0.5, 0.4), progress)
37 | );
38 | }
39 |
40 | """
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/KaleidoscopeTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class KaleidoscopeTransition : Transition("kaleidoscope", SOURCE, 1000L) {
21 |
22 | open var speed: Float = 1f
23 | open var speedUniform = uniform1f("speed").autoInit()
24 | open var angle: Float = 1f
25 | open var angleUniform = uniform1f("angle").autoInit()
26 | open var power: Float = 1.5f
27 | open var powerUniform = uniform1f("power").autoInit()
28 |
29 | override fun onUpdateUniforms() {
30 | super.onUpdateUniforms()
31 |
32 | speedUniform.setValue(speed)
33 | angleUniform.setValue(angle)
34 | powerUniform.setValue(power)
35 | }
36 |
37 | companion object {
38 | // language=glsl
39 | const val SOURCE = """
40 | // Author: nwoeanhinnogaehr
41 | // License: MIT
42 |
43 | uniform float speed; // = 1.0;
44 | uniform float angle; // = 1.0;
45 | uniform float power; // = 1.5;
46 |
47 | vec4 transition(vec2 uv) {
48 | vec2 p = uv.xy / vec2(1.0).xy;
49 | vec2 q = p;
50 | float t = pow(progress, power)*speed;
51 | p = p -0.5;
52 | for (int i = 0; i < 7; i++) {
53 | p = vec2(sin(t)*p.x + cos(t)*p.y, sin(t)*p.y - cos(t)*p.x);
54 | t += angle;
55 | p = abs(mod(p, 2.0) - 1.0);
56 | }
57 | abs(mod(p, 1.0));
58 | return mix(
59 | mix(getFromColor(q), getToColor(q), progress),
60 | mix(getFromColor(p), getToColor(p), progress), 1.0 - 2.0*abs(progress - 0.5));
61 | }
62 |
63 | """
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/LinearBlurTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | // TODO: Should be remove, because it's not good perf.
21 | open class LinearBlurTransition : Transition("linear-blur", SOURCE, 1000L) {
22 |
23 | open var intensity: Float = 0.1f
24 | open var intensityUniform = uniform1f("intensity").autoInit()
25 |
26 | override fun onUpdateUniforms() {
27 | super.onUpdateUniforms()
28 |
29 | intensityUniform.setValue(intensity)
30 | }
31 |
32 | companion object {
33 | // language=glsl
34 | const val SOURCE = """
35 | // author: gre
36 | // license: MIT
37 | uniform float intensity; // = 0.1
38 | const int passes = 6;
39 |
40 | vec4 transition(vec2 uv) {
41 | vec4 c1 = vec4(0.0);
42 | vec4 c2 = vec4(0.0);
43 |
44 | float disp = intensity*(0.5-distance(0.5, progress));
45 | for (int xi=0; xi radius * progress)
50 | return getFromColor(uv);
51 | else
52 | return getToColor(uv);
53 | }
54 |
55 | """
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/PolkaDotsCurtainTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.Vector2f
19 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
20 | import com.seanghay.studio.gles.graphics.uniform.uniform2f
21 |
22 | open class PolkaDotsCurtainTransition : Transition("polka-dots-curtain", SOURCE, 1000L) {
23 |
24 | open var dots: Float = 20f
25 | open var dotsUniform = uniform1f("dots").autoInit()
26 | open var center: Vector2f = Vector2f(0f, 0f)
27 | open var centerUniform = uniform2f("center").autoInit()
28 |
29 | override fun onUpdateUniforms() {
30 | super.onUpdateUniforms()
31 |
32 | dotsUniform.setValue(dots)
33 | centerUniform.setValue(center)
34 | }
35 |
36 | companion object {
37 | // language=glsl
38 | const val SOURCE = """
39 | // author: bobylito
40 | // license: MIT
41 | const float SQRT_2 = 1.414213562373;
42 | uniform float dots;// = 20.0;
43 | uniform vec2 center;// = vec2(0, 0);
44 |
45 | vec4 transition(vec2 uv) {
46 | bool nextImage = distance(fract(uv * dots), vec2(0.5, 0.5)) < ( progress / distance(uv, center));
47 | return nextImage ? getToColor(uv) : getFromColor(uv);
48 | }
49 |
50 | """
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/RadialTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class RadialTransition : Transition("radial", SOURCE, 1000L) {
21 |
22 | open var smoothness: Float = 1f
23 | open var smoothnessUniform = uniform1f("smoothness").autoInit()
24 |
25 | override fun onUpdateUniforms() {
26 | super.onUpdateUniforms()
27 |
28 | smoothnessUniform.setValue(smoothness)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val SOURCE = """
34 | // License: MIT
35 | // Author: Xaychru
36 | // ported by gre from https://gist.github.com/Xaychru/ce1d48f0ce00bb379750
37 |
38 | uniform float smoothness; // = 1.0
39 |
40 | const float PI = 3.141592653589;
41 |
42 | vec4 transition(vec2 p) {
43 | vec2 rp = p*2.-1.;
44 | return mix(
45 | getToColor(p),
46 | getFromColor(p),
47 | smoothstep(0., smoothness, atan(rp.y,rp.x) - (progress-.5) * PI * 2.5)
48 | );
49 | }
50 |
51 | """
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/RippleTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class RippleTransition : Transition("ripple", SOURCE, 2000) {
21 |
22 | var speed = 50.0f
23 | var amplitude = 100.0f
24 |
25 | private val amplitudeUniform = uniform1f("amplitude")
26 | .autoInit()
27 |
28 | private val speedUniform = uniform1f("speed")
29 | .autoInit()
30 |
31 | override fun onUpdateUniforms() {
32 | super.onUpdateUniforms()
33 |
34 | amplitudeUniform.setValue(amplitude)
35 | speedUniform.setValue(speed)
36 | }
37 |
38 | companion object {
39 | // language=glsl
40 | const val SOURCE = """
41 | uniform float amplitude; // = 100.0
42 | uniform float speed; // = 50.0
43 |
44 | vec4 transition (vec2 uv) {
45 | vec2 dir = uv - vec2(.5);
46 | float dist = length(dir);
47 | vec2 offset = dir * (sin(progress * dist * amplitude - progress * speed) + .5) / 30.;
48 | return mix(
49 | getFromColor(uv + offset),
50 | getToColor(uv),
51 | smoothstep(0.2, 1.0, progress)
52 | );
53 | }
54 | """
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/SimpleZoomTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class SimpleZoomTransition : Transition("simple-zoom", SOURCE, 1000L) {
21 |
22 | open var zoomQuickness: Float = 0.8f
23 | open var zoomQuicknessUniform = uniform1f("zoom_quickness").autoInit()
24 |
25 | override fun onUpdateUniforms() {
26 | super.onUpdateUniforms()
27 |
28 | zoomQuicknessUniform.setValue(zoomQuickness)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val SOURCE = """
34 | // Author: 0gust1
35 | // License: MIT
36 |
37 | uniform float zoom_quickness; // = 0.8
38 |
39 |
40 | vec2 zoom(vec2 uv, float amount) {
41 | return 0.5 + ((uv - 0.5) * (1.0-amount));
42 | }
43 |
44 | vec4 transition (vec2 uv) {
45 | float nQuick = clamp(zoom_quickness,0.2,1.0);
46 |
47 | return mix(
48 | getFromColor(zoom(uv, smoothstep(0.0, nQuick, progress))),
49 | getToColor(uv),
50 | smoothstep(nQuick-0.2, 1.0, progress)
51 | );
52 | }
53 | """
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/SqueezeTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class SqueezeTransition : Transition("squeeze", SOURCE, 1000L) {
21 |
22 | open var colorSeparation: Float = 0.04f
23 | open var colorSeparationUniform = uniform1f("colorSeparation").autoInit()
24 |
25 | override fun onUpdateUniforms() {
26 | super.onUpdateUniforms()
27 |
28 | colorSeparationUniform.setValue(colorSeparation)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val SOURCE = """
34 | // Author: gre
35 | // License: MIT
36 |
37 | uniform float colorSeparation; // = 0.04
38 |
39 | vec4 transition (vec2 uv) {
40 | float y = 0.5 + (uv.y-0.5) / (1.0-progress);
41 | if (y < 0.0 || y > 1.0) {
42 | return getToColor(uv);
43 | }
44 | else {
45 | vec2 fp = vec2(uv.x, y);
46 | vec2 off = progress * vec2(0.0, colorSeparation);
47 | vec4 c = getFromColor(fp);
48 | vec4 cn = getFromColor(fp - off);
49 | vec4 cp = getFromColor(fp + off);
50 | return vec4(cn.r, c.g, cp.b, c.a);
51 | }
52 | }
53 |
54 | """
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/SwirlTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class SwirlTransition : Transition("swirl", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // License: MIT
24 | // Author: Sergey Kosarevsky
25 | // ( http://www.linderdaum.com )
26 | // ported by gre from https://gist.github.com/corporateshark/cacfedb8cca0f5ce3f7c
27 |
28 | vec4 transition(vec2 UV)
29 | {
30 | float Radius = 1.0;
31 |
32 | float T = progress;
33 |
34 | UV -= vec2( 0.5, 0.5 );
35 |
36 | float Dist = length(UV);
37 |
38 | if ( Dist < Radius )
39 | {
40 | float Percent = (Radius - Dist) / Radius;
41 | float A = ( T <= 0.5 ) ? mix( 0.0, 1.0, T/0.5 ) : mix( 1.0, 0.0, (T-0.5)/0.5 );
42 | float Theta = Percent * Percent * A * 8.0 * 3.14159;
43 | float S = sin( Theta );
44 | float C = cos( Theta );
45 | UV = vec2( dot(UV, vec2(C, -S)), dot(UV, vec2(S, C)) );
46 | }
47 | UV += vec2( 0.5, 0.5 );
48 |
49 | vec4 C0 = getFromColor(UV);
50 | vec4 C1 = getToColor(UV);
51 |
52 | return mix( C0, C1, T );
53 | }
54 |
55 | """
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/Transition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.Uniform
19 |
20 | abstract class Transition(
21 | var name: String,
22 | var source: String,
23 | var duration: Long
24 | ) {
25 |
26 | val uniforms = arrayListOf>()
27 | protected fun > U.autoInit(): U {
28 | uniforms.add(this)
29 | return this
30 | }
31 |
32 | open fun onUpdateUniforms() {}
33 | }
34 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/WaterDropTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class WaterDropTransition : Transition("water-drop", SOURCE, 1000L) {
21 |
22 | open var amplitude: Float = 30f
23 | open var amplitudeUniform = uniform1f("amplitude").autoInit()
24 | open var speed: Float = 30f
25 | open var speedUniform = uniform1f("speed").autoInit()
26 |
27 | override fun onUpdateUniforms() {
28 | super.onUpdateUniforms()
29 |
30 | amplitudeUniform.setValue(amplitude)
31 | speedUniform.setValue(speed)
32 | }
33 |
34 | companion object {
35 | // language=glsl
36 | const val SOURCE = """
37 | // author: Paweł Płóciennik
38 | // license: MIT
39 | uniform float amplitude; // = 30
40 | uniform float speed; // = 30
41 |
42 | vec4 transition(vec2 p) {
43 | vec2 dir = p - vec2(.5);
44 | float dist = length(dir);
45 |
46 | if (dist > progress) {
47 | return mix(getFromColor( p), getToColor( p), progress);
48 | } else {
49 | vec2 offset = dir * sin(dist * amplitude - progress * speed);
50 | return mix(getFromColor( p + offset), getToColor( p), progress);
51 | }
52 | }
53 |
54 | """
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/WindTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class WindTransition : Transition("wind", SOURCE, 1000L) {
21 |
22 | open var size: Float = 0.2f
23 | open var sizeUniform = uniform1f("size").autoInit()
24 |
25 | override fun onUpdateUniforms() {
26 | super.onUpdateUniforms()
27 |
28 | sizeUniform.setValue(size)
29 | }
30 |
31 | companion object {
32 | // language=glsl
33 | const val SOURCE = """
34 | // Author: gre
35 | // License: MIT
36 |
37 | // Custom parameters
38 | uniform float size; // = 0.2
39 |
40 | float rand (vec2 co) {
41 | return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
42 | }
43 |
44 | vec4 transition (vec2 uv) {
45 | float r = rand(vec2(0, uv.y));
46 | float m = smoothstep(0.0, -size, uv.x*(1.0-size) + size*r - (progress * (1.0 + size)));
47 | return mix(
48 | getFromColor(uv),
49 | getToColor(uv),
50 | m
51 | );
52 | }
53 |
54 | """
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/WindowblindsTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class WindowblindsTransition : Transition("windowblinds", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // Author: Fabien Benetou
24 | // License: MIT
25 |
26 | vec4 transition (vec2 uv) {
27 | float t = progress;
28 |
29 | if (mod(floor(uv.y*100.*progress),2.)==0.)
30 | t*=2.-.5;
31 |
32 | return mix(
33 | getFromColor(uv),
34 | getToColor(uv),
35 | mix(t, progress, smoothstep(0.8, 1.0, progress))
36 | );
37 | }
38 |
39 | """
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/WindowsliceTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | import com.seanghay.studio.gles.graphics.uniform.uniform1f
19 |
20 | open class WindowsliceTransition : Transition("windowslice", SOURCE, 1000L) {
21 |
22 | open var count: Float = 10f
23 | open var countUniform = uniform1f("count").autoInit()
24 | open var smoothness: Float = 0.5f
25 | open var smoothnessUniform = uniform1f("smoothness").autoInit()
26 |
27 | override fun onUpdateUniforms() {
28 | super.onUpdateUniforms()
29 |
30 | countUniform.setValue(count)
31 | smoothnessUniform.setValue(smoothness)
32 | }
33 |
34 | companion object {
35 | // language=glsl
36 | const val SOURCE = """
37 | // Author: gre
38 | // License: MIT
39 |
40 | uniform float count; // = 10.0
41 | uniform float smoothness; // = 0.5
42 |
43 | vec4 transition (vec2 p) {
44 | float pr = smoothstep(-smoothness, 0.0, p.x - progress * (1.0 + smoothness));
45 | float s = step(pr, fract(count * p.x));
46 | return mix(getFromColor(p), getToColor(p), s);
47 | }
48 |
49 | """
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/WipeDownTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class WipeDownTransition : Transition("wipe-down", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // Author: Jake Nelson
24 | // License: MIT
25 |
26 | vec4 transition(vec2 uv) {
27 | vec2 p=uv.xy/vec2(1.0).xy;
28 | vec4 a=getFromColor(p);
29 | vec4 b=getToColor(p);
30 | return mix(a, b, step(1.0-p.y,progress));
31 | }
32 |
33 | """
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/WipeLeftTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class WipeLeftTransition : Transition("wipe-left", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // Author: Jake Nelson
24 | // License: MIT
25 |
26 | vec4 transition(vec2 uv) {
27 | vec2 p=uv.xy/vec2(1.0).xy;
28 | vec4 a=getFromColor(p);
29 | vec4 b=getToColor(p);
30 | return mix(a, b, step(1.0-p.x,progress));
31 | }
32 |
33 | """
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/WipeRightTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class WipeRightTransition : Transition("wipe-right", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // Author: Jake Nelson
24 | // License: MIT
25 |
26 | vec4 transition(vec2 uv) {
27 | vec2 p=uv.xy/vec2(1.0).xy;
28 | vec4 a=getFromColor(p);
29 | vec4 b=getToColor(p);
30 | return mix(a, b, step(0.0+p.x,progress));
31 | }
32 |
33 | """
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/WipeUpTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class WipeUpTransition : Transition("wipe-up", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // Author: Jake Nelson
24 | // License: MIT
25 |
26 | vec4 transition(vec2 uv) {
27 | vec2 p=uv.xy/vec2(1.0).xy;
28 | vec4 a=getFromColor(p);
29 | vec4 b=getToColor(p);
30 | return mix(a, b, step(0.0+p.y,progress));
31 | }
32 |
33 | """
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/gles/transition/ZoomInCirclesTransition.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.gles.transition
17 |
18 | open class ZoomInCirclesTransition : Transition("zoom-in-circles", SOURCE, 1000L) {
19 |
20 | companion object {
21 | // language=glsl
22 | const val SOURCE = """
23 | // License: MIT
24 | // Author: dycm8009
25 | // ported by gre from https://gist.github.com/dycm8009/948e99b1800e81ad909a
26 |
27 | vec2 zoom(vec2 uv, float amount) {
28 | return 0.5 + ((uv - 0.5) * amount);
29 | }
30 |
31 |
32 |
33 | vec4 transition(vec2 uv) {
34 | vec2 ratio2 = vec2(1.0, 1.0 / ratio);
35 |
36 | // TODO: some timing are hardcoded but should be one or many parameters
37 | // TODO: should also be able to configure how much circles
38 | // TODO: if() branching should be avoided when possible, prefer use of step() & other functions
39 | vec2 r = 2.0 * ((vec2(uv.xy) - 0.5) * ratio2);
40 | float pro = progress / 0.8;
41 | float z = pro * 0.2;
42 | float t = 0.0;
43 | if (pro > 1.0) {
44 | z = 0.2 + (pro - 1.0) * 5.;
45 | t = clamp((progress - 0.8) / 0.07, 0.0, 1.0);
46 | }
47 | if (length(r) < 0.5+z) {
48 | // uv = zoom(uv, 0.9 - 0.1 * pro);
49 | }
50 | else if (length(r) < 0.8+z*1.5) {
51 | uv = zoom(uv, 1.0 - 0.15 * pro);
52 | t = t * 0.5;
53 | }
54 | else if (length(r) < 1.2+z*2.5) {
55 | uv = zoom(uv, 1.0 - 0.2 * pro);
56 | t = t * 0.2;
57 | }
58 | else {
59 | uv = zoom(uv, 1.0 - 0.25 * pro);
60 | }
61 | return mix(getFromColor(uv), getToColor(uv), t);
62 | }
63 |
64 | """
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/mediacodec/TrackFormats.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.mediacodec
17 |
18 | import android.media.MediaCodecInfo
19 | import android.media.MediaFormat
20 |
21 | object TrackFormats {
22 |
23 | @JvmStatic
24 | fun createVideoFormat(
25 | width: Int,
26 | height: Int,
27 | bitrate: Int
28 | ): MediaFormat {
29 | val format = MediaFormat.createVideoFormat(MediaFormat.MIMETYPE_VIDEO_AVC, width, height)
30 | format.setInteger(MediaFormat.KEY_BIT_RATE, bitrate)
31 | return format
32 | }
33 |
34 | @JvmStatic
35 | fun createAudioFormat(
36 | sampleRate: Int,
37 | bitrate: Int,
38 | channelCount: Int
39 | ): MediaFormat {
40 | val format =
41 | MediaFormat.createAudioFormat(MediaFormat.MIMETYPE_AUDIO_AAC, sampleRate, channelCount)
42 | format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 1024 * 9)
43 | format.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_AUDIO_AAC)
44 | format.setInteger(MediaFormat.KEY_BIT_RATE, bitrate)
45 | format.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectHE)
46 | return format
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/utils/BasicVertices.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.utils
17 |
18 | object BasicVertices {
19 |
20 | val RECT_STRIP = floatArrayOf(
21 | -1.0f, -1.0f, 0f,
22 | 1.0f, -1.0f, 0f,
23 | -1.0f, 1.0f, 0f,
24 | 1.0f, 1.0f, 0f
25 | )
26 |
27 | val RECT_STRIP_TEXTURE = floatArrayOf(
28 | 0.0f, 1.0f,
29 | 1.0f, 1.0f,
30 | 0.0f, 0.0f,
31 | 1.0f, 0.0f
32 | )
33 |
34 | val FULL_RECTANGLE = floatArrayOf(
35 | -1f, -1f, 0f,
36 | -1f, 1f, 0f,
37 | 1f, 1f, 0f,
38 |
39 | -1f, -1f, 0f,
40 | 1f, 1f, 0f,
41 | 1f, -1f, 0f
42 | )
43 |
44 | val NORMAL_TEXTURE_COORDINATES = floatArrayOf(
45 | 0f, 0f,
46 | 0f, 1f,
47 | 1f, 1f,
48 |
49 | 0f, 0f,
50 | 1f, 1f,
51 | 1f, 0f
52 | )
53 | }
54 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/utils/BitmapExtensions.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.utils
17 |
18 | import android.graphics.Bitmap
19 | import android.graphics.BitmapFactory
20 | import java.io.ByteArrayOutputStream
21 |
22 | fun Bitmap.use(willRecycle: Boolean = true, block: Bitmap.() -> R): R {
23 | return block().also {
24 | if (willRecycle) recycle()
25 | }
26 | }
27 |
28 | fun Bitmap.compressQuality(quality: Int): Bitmap {
29 | return ByteArrayOutputStream().use {
30 | compress(Bitmap.CompressFormat.JPEG, quality, it)
31 | val byteArray = it.toByteArray()
32 | BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size)
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/utils/BufferExtensions.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.utils
17 |
18 | import com.seanghay.studio.utils.GlUtils.FLOAT_SIZE_BYTES
19 | import java.nio.ByteBuffer
20 | import java.nio.ByteOrder
21 | import java.nio.FloatBuffer
22 | import java.nio.IntBuffer
23 |
24 | internal fun ByteArray.toByteBuffer(): ByteBuffer {
25 | return ByteBuffer.allocateDirect(size * FLOAT_SIZE_BYTES)
26 | .order(ByteOrder.nativeOrder())
27 | .put(this).also { it.position(0) }
28 | }
29 |
30 | internal fun FloatArray.toFloatBuffer(): FloatBuffer {
31 | return ByteBuffer.allocateDirect(size * FLOAT_SIZE_BYTES)
32 | .order(ByteOrder.nativeOrder())
33 | .asFloatBuffer()
34 | .put(this).also { it.position(0) }
35 | }
36 |
37 | internal fun IntArray.toIntBuffer(): IntBuffer {
38 | return ByteBuffer.allocateDirect(size * FLOAT_SIZE_BYTES)
39 | .order(ByteOrder.nativeOrder()).asIntBuffer()
40 | .put(this).also { it.position(0) }
41 | }
42 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/utils/ColorExtensions.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.utils
17 |
18 | import android.graphics.Color
19 |
20 | val Int.colorArray: FloatArray
21 | get() {
22 | return floatArrayOf(
23 | Color.red(this) / 255f,
24 | Color.green(this) / 255f,
25 | Color.blue(this) / 255f,
26 | Color.alpha(this) / 255f
27 | )
28 | }
29 |
--------------------------------------------------------------------------------
/studio/src/main/java/com/seanghay/studio/utils/MathCore.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Designed and developed by Seanghay Yath (@seanghay)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.seanghay.studio.utils
17 |
18 | import kotlin.math.PI
19 | import kotlin.math.max
20 | import kotlin.math.min
21 |
22 | /**
23 | * Constraint output value from input value.
24 | * @param a Minimum output value
25 | * @param b Maximum output value
26 | */
27 | fun Float.clamp(a: Float, b: Float): Float {
28 | return (min(b, max(a, this)))
29 | }
30 |
31 | fun Float.smoothStep(edge0: Float, edge1: Float): Float {
32 | val x = ((this - edge0) / (edge1 - edge0)).clamp(0f, 1f)
33 | return (x * x * (3f - 2f * x))
34 | }
35 |
36 | /**
37 | * Linear Interpolate between two values
38 | * @param start Start value
39 | * @param end End value
40 | * @receiver a float range value between 0f..1f
41 | */
42 | fun Float.lerp(start: Float, end: Float): Float {
43 | return (1 - this) * start + this * end
44 | }
45 |
46 | fun Float.toRadians(): Float {
47 | return this * PI.toFloat() / 180f
48 | }
49 |
--------------------------------------------------------------------------------
/studio/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Studio
3 |
4 |
--------------------------------------------------------------------------------
/versionsPlugin.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.github.ben-manes.versions"
2 |
3 | dependencyUpdates.resolutionStrategy {
4 | componentSelection { rules ->
5 | rules.all { ComponentSelection selection ->
6 | boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
7 | selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
8 | }
9 | if (rejected) {
10 | selection.reject('Not stable')
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------