├── .gitignore ├── Assets ├── 1.gif └── 2.gif ├── LICENSE ├── MTTransitions.podspec ├── MTTransitionsDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── MTTransitionsDemo.xcscheme ├── MTTransitionsDemo.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── MTTransitionsDemo ├── AppDelegate.swift ├── Helper │ └── GIFGenerator.swift ├── Resources │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 7.jpg │ ├── 8.jpg │ ├── 9.jpg │ ├── audio1.mp3 │ ├── audio2.mp3 │ ├── clip1.mp4 │ ├── clip2.mp4 │ ├── clip3.mp4 │ ├── cut1.mp4 │ ├── cut2.mp4 │ ├── cut3.mp4 │ ├── wallpaper01.jpg │ └── wallpaper02.jpg ├── Samples │ ├── CreateVideoFromImagesViewController.swift │ ├── ImageTransitionSampleViewController.swift │ ├── LabelTransitionSampleViewController.swift │ ├── MultipleVideoTransitionsViewController.swift │ ├── PickImageTransitionViewController.swift │ ├── PresentAViewController.swift │ ├── PresentBViewController.swift │ ├── PushAViewController.swift │ ├── PushBViewController.swift │ ├── TransitionsPickerViewController.swift │ ├── VideoTransitionSampleViewController.swift │ └── WallpaperViewController.swift ├── Supporting Files │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ └── ItunesArtwork@2x.png │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ └── Info.plist └── ViewController.swift ├── Package.swift ├── Podfile ├── Podfile.lock ├── Pods ├── Local Podspecs │ └── MTTransitions.podspec.json ├── Manifest.lock ├── MetalPetal │ ├── Frameworks │ │ └── MetalPetal │ │ │ ├── Filters │ │ │ ├── Filter.swift │ │ │ ├── MTIAlphaPremultiplicationFilter.h │ │ │ ├── MTIAlphaPremultiplicationFilter.m │ │ │ ├── MTIBlendFilter.h │ │ │ ├── MTIBlendFilter.m │ │ │ ├── MTIBlendWithMaskFilter.h │ │ │ ├── MTIBlendWithMaskFilter.m │ │ │ ├── MTIBulgeDistortionFilter.h │ │ │ ├── MTIBulgeDistortionFilter.m │ │ │ ├── MTICLAHEFilter.h │ │ │ ├── MTICLAHEFilter.m │ │ │ ├── MTIChromaKeyBlendFilter.h │ │ │ ├── MTIChromaKeyBlendFilter.m │ │ │ ├── MTIColorHalftoneFilter.h │ │ │ ├── MTIColorHalftoneFilter.m │ │ │ ├── MTIColorLookupFilter.h │ │ │ ├── MTIColorLookupFilter.m │ │ │ ├── MTIColorMatrixFilter.h │ │ │ ├── MTIColorMatrixFilter.m │ │ │ ├── MTICropFilter.h │ │ │ ├── MTICropFilter.m │ │ │ ├── MTIDotScreenFilter.h │ │ │ ├── MTIDotScreenFilter.m │ │ │ ├── MTIFilter.h │ │ │ ├── MTIFilter.m │ │ │ ├── MTIHexagonalBokehBlurFilter.h │ │ │ ├── MTIHexagonalBokehBlurFilter.m │ │ │ ├── MTIHighPassSkinSmoothingFilter.h │ │ │ ├── MTIHighPassSkinSmoothingFilter.m │ │ │ ├── MTIImage+Filters.h │ │ │ ├── MTIImage+Filters.m │ │ │ ├── MTIMPSBoxBlurFilter.h │ │ │ ├── MTIMPSBoxBlurFilter.m │ │ │ ├── MTIMPSConvolutionFilter.h │ │ │ ├── MTIMPSConvolutionFilter.m │ │ │ ├── MTIMPSDefinitionFilter.h │ │ │ ├── MTIMPSDefinitionFilter.m │ │ │ ├── MTIMPSGaussianBlurFilter.h │ │ │ ├── MTIMPSGaussianBlurFilter.m │ │ │ ├── MTIMPSHistogramFilter.h │ │ │ ├── MTIMPSHistogramFilter.m │ │ │ ├── MTIMPSSobelFilter.h │ │ │ ├── MTIMPSSobelFilter.m │ │ │ ├── MTIMPSUnsharpMaskFilter.h │ │ │ ├── MTIMPSUnsharpMaskFilter.m │ │ │ ├── MTIMultilayerCompositingFilter.h │ │ │ ├── MTIMultilayerCompositingFilter.m │ │ │ ├── MTIPixellateFilter.h │ │ │ ├── MTIPixellateFilter.m │ │ │ ├── MTIRGBColorSpaceConversionFilter.h │ │ │ ├── MTIRGBColorSpaceConversionFilter.m │ │ │ ├── MTIRGBColorSpaceConversionFilter.swift │ │ │ ├── MTIRGBToneCurveFilter.h │ │ │ ├── MTIRGBToneCurveFilter.m │ │ │ ├── MTIRoundCornerFilter.h │ │ │ ├── MTIRoundCornerFilter.m │ │ │ ├── MTITransformFilter.h │ │ │ ├── MTITransformFilter.m │ │ │ ├── MTIUnaryImageRenderingFilter.h │ │ │ ├── MTIUnaryImageRenderingFilter.m │ │ │ ├── MTIVibranceFilter.h │ │ │ ├── MTIVibranceFilter.m │ │ │ └── MultilayerCompositingFilter.swift │ │ │ ├── Kernels │ │ │ ├── MTIComputePipelineKernel.h │ │ │ ├── MTIComputePipelineKernel.m │ │ │ ├── MTIComputePipelineKernel.swift │ │ │ ├── MTIKernel.h │ │ │ ├── MTIMPSKernel.h │ │ │ ├── MTIMPSKernel.m │ │ │ ├── MTIMultilayerCompositeKernel.h │ │ │ ├── MTIMultilayerCompositeKernel.m │ │ │ ├── MTIRenderCommand.h │ │ │ ├── MTIRenderCommand.m │ │ │ ├── MTIRenderPipelineKernel.h │ │ │ └── MTIRenderPipelineKernel.m │ │ │ ├── MTIAlphaType.h │ │ │ ├── MTIAlphaType.m │ │ │ ├── MTIAlphaType.swift │ │ │ ├── MTIBlendFormulaSupport.h │ │ │ ├── MTIBlendFormulaSupport.mm │ │ │ ├── MTIBlendModes.h │ │ │ ├── MTIBlendModes.m │ │ │ ├── MTIBuffer.h │ │ │ ├── MTIBuffer.m │ │ │ ├── MTICVMetalIOSurfaceBridge.h │ │ │ ├── MTICVMetalIOSurfaceBridge.m │ │ │ ├── MTICVMetalTextureBridging.h │ │ │ ├── MTICVMetalTextureCache.h │ │ │ ├── MTICVMetalTextureCache.m │ │ │ ├── MTICVPixelBufferPool.h │ │ │ ├── MTICVPixelBufferPool.m │ │ │ ├── MTICVPixelBufferPromise.h │ │ │ ├── MTICVPixelBufferPromise.m │ │ │ ├── MTICVPixelBufferRendering.h │ │ │ ├── MTICVPixelBufferRendering.m │ │ │ ├── MTIColor.h │ │ │ ├── MTIColor.m │ │ │ ├── MTIColor.swift │ │ │ ├── MTIColorMatrix.h │ │ │ ├── MTIColorMatrix.m │ │ │ ├── MTIColorMatrix.swift │ │ │ ├── MTIComputePipeline.h │ │ │ ├── MTIComputePipeline.m │ │ │ ├── MTIContext+Internal.h │ │ │ ├── MTIContext+Rendering.h │ │ │ ├── MTIContext+Rendering.m │ │ │ ├── MTIContext.h │ │ │ ├── MTIContext.m │ │ │ ├── MTIContext.swift │ │ │ ├── MTICoreImageExtension.swift │ │ │ ├── MTICoreImageRendering.h │ │ │ ├── MTICoreImageRendering.m │ │ │ ├── MTICorner.h │ │ │ ├── MTICorner.swift │ │ │ ├── MTICropRegion.swift │ │ │ ├── MTIDataBuffer.swift │ │ │ ├── MTIDefer.h │ │ │ ├── MTIDefer.m │ │ │ ├── MTIDrawableRendering.h │ │ │ ├── MTIDrawableRendering.m │ │ │ ├── MTIError.h │ │ │ ├── MTIError.m │ │ │ ├── MTIError.swift │ │ │ ├── MTIFunctionArgumentsEncoder.h │ │ │ ├── MTIFunctionArgumentsEncoder.m │ │ │ ├── MTIFunctionDescriptor.h │ │ │ ├── MTIFunctionDescriptor.m │ │ │ ├── MTIFunctionDescriptor.swift │ │ │ ├── MTIGeometry.h │ │ │ ├── MTIGeometry.m │ │ │ ├── MTIGeometryUtilities.h │ │ │ ├── MTIGeometryUtilities.m │ │ │ ├── MTIHasher.h │ │ │ ├── MTIImage+Promise.h │ │ │ ├── MTIImage.h │ │ │ ├── MTIImage.m │ │ │ ├── MTIImage.swift │ │ │ ├── MTIImageOrientation.h │ │ │ ├── MTIImageOrientation.m │ │ │ ├── MTIImagePromise.h │ │ │ ├── MTIImagePromise.m │ │ │ ├── MTIImagePromiseDebug.h │ │ │ ├── MTIImagePromiseDebug.m │ │ │ ├── MTIImageProperties.h │ │ │ ├── MTIImageProperties.m │ │ │ ├── MTIImageRenderingContext+Internal.h │ │ │ ├── MTIImageRenderingContext.h │ │ │ ├── MTIImageRenderingContext.mm │ │ │ ├── MTILayer.h │ │ │ ├── MTILayer.m │ │ │ ├── MTILibrarySource.h │ │ │ ├── MTILibrarySource.m │ │ │ ├── MTILock.h │ │ │ ├── MTILock.m │ │ │ ├── MTIMask.h │ │ │ ├── MTIMask.m │ │ │ ├── MTIMemoryWarningObserver.h │ │ │ ├── MTIMemoryWarningObserver.m │ │ │ ├── MTIPixelFormat.h │ │ │ ├── MTIPixelFormat.m │ │ │ ├── MTIPixelFormat.swift │ │ │ ├── MTIPrint.h │ │ │ ├── MTIRenderGraphOptimization.h │ │ │ ├── MTIRenderGraphOptimization.m │ │ │ ├── MTIRenderPassOutputDescriptor.h │ │ │ ├── MTIRenderPassOutputDescriptor.m │ │ │ ├── MTIRenderPipeline.h │ │ │ ├── MTIRenderPipeline.m │ │ │ ├── MTIRenderTask.h │ │ │ ├── MTIRenderTask.m │ │ │ ├── MTISIMDArgumentEncoder.swift │ │ │ ├── MTISamplerDescriptor.h │ │ │ ├── MTISamplerDescriptor.m │ │ │ ├── MTITextureDescriptor.h │ │ │ ├── MTITextureDescriptor.m │ │ │ ├── MTITextureDimensions.h │ │ │ ├── MTITextureDimensions.swift │ │ │ ├── MTITextureLoader.h │ │ │ ├── MTITextureLoader.m │ │ │ ├── MTITexturePool.h │ │ │ ├── MTITexturePool.mm │ │ │ ├── MTITransform.h │ │ │ ├── MTITransform.m │ │ │ ├── MTIVector+SIMD.h │ │ │ ├── MTIVector+SIMD.m │ │ │ ├── MTIVector.h │ │ │ ├── MTIVector.m │ │ │ ├── MTIVector.swift │ │ │ ├── MTIVertex.h │ │ │ ├── MTIVertex.m │ │ │ ├── MTIVertex.swift │ │ │ ├── MTIVideoComposition.swift │ │ │ ├── MTIWeakToStrongObjectsMapTable.h │ │ │ ├── MTIWeakToStrongObjectsMapTable.m │ │ │ ├── MetalPetal.h │ │ │ ├── MetalPetal.modulemap │ │ │ ├── MetalPetal.swift │ │ │ ├── SceneKit │ │ │ ├── MTISCNSceneRenderer.h │ │ │ └── MTISCNSceneRenderer.m │ │ │ ├── Shaders │ │ │ ├── BlendingShaders.metal │ │ │ ├── CLAHE.metal │ │ │ ├── ColorConversionShaders.metal │ │ │ ├── Halftone.metal │ │ │ ├── HighPassSkinSmoothing.metal │ │ │ ├── LensBlur.metal │ │ │ ├── MTIShaderFunctionConstants.h │ │ │ ├── MTIShaderLib.h │ │ │ ├── MultilayerCompositeShaders.metal │ │ │ └── Shaders.metal │ │ │ ├── SpriteKit │ │ │ ├── MTISKSceneRenderer.h │ │ │ └── MTISKSceneRenderer.m │ │ │ └── UI │ │ │ ├── MTIImageView.h │ │ │ ├── MTIImageView.m │ │ │ ├── MTIImageViewProtocol.swift │ │ │ ├── MTIThreadSafeImageView.h │ │ │ └── MTIThreadSafeImageView.m │ ├── LICENSE │ └── README.md ├── Pods.xcodeproj │ └── project.pbxproj └── Target Support Files │ ├── MTTransitions │ ├── MTTransitions-Info.plist │ ├── MTTransitions-dummy.m │ ├── MTTransitions-prefix.pch │ ├── MTTransitions-umbrella.h │ ├── MTTransitions.debug.xcconfig │ ├── MTTransitions.modulemap │ ├── MTTransitions.release.xcconfig │ └── MTTransitions.xcconfig │ ├── MetalPetal │ ├── MetalPetal-Info.plist │ ├── MetalPetal-dummy.m │ ├── MetalPetal-prefix.pch │ ├── MetalPetal.debug.xcconfig │ ├── MetalPetal.modulemap │ ├── MetalPetal.release.xcconfig │ └── MetalPetal.xcconfig │ └── Pods-MTTransitionsDemo │ ├── Pods-MTTransitionsDemo-Info.plist │ ├── Pods-MTTransitionsDemo-acknowledgements.markdown │ ├── Pods-MTTransitionsDemo-acknowledgements.plist │ ├── Pods-MTTransitionsDemo-dummy.m │ ├── Pods-MTTransitionsDemo-frameworks-Debug-input-files.xcfilelist │ ├── Pods-MTTransitionsDemo-frameworks-Debug-output-files.xcfilelist │ ├── Pods-MTTransitionsDemo-frameworks-Release-input-files.xcfilelist │ ├── Pods-MTTransitionsDemo-frameworks-Release-output-files.xcfilelist │ ├── Pods-MTTransitionsDemo-frameworks.sh │ ├── Pods-MTTransitionsDemo-umbrella.h │ ├── Pods-MTTransitionsDemo.debug.xcconfig │ ├── Pods-MTTransitionsDemo.modulemap │ └── Pods-MTTransitionsDemo.release.xcconfig ├── README.md └── Source ├── Assets.bundle ├── Root.plist ├── bilinear-lateral.png ├── conical-asym.png ├── conical-sym.png ├── displacementMap.jpg ├── en.lproj │ └── Root.strings ├── linear-sawtooth-lateral-4.png ├── radial-tri-lateral-4.png ├── spiral-1.png ├── spiral-2.png ├── spiral-3.png └── square.png ├── CALayer+Extensions.swift ├── MTMovieMaker.swift ├── MTTransition+Effect.swift ├── MTTransition+UIView.swift ├── MTTransition.swift ├── MTVideoCompositionInstruction.swift ├── MTVideoCompositor.swift ├── MTVideoExporter.swift ├── MTVideoTransition.swift ├── MTVideoTransitionRenderer.swift ├── MTViewControllerTransition.swift ├── Transitions ├── MTAngularTransition.metal ├── MTAngularTransition.swift ├── MTBookFlipTransition.metal ├── MTBookFlipTransition.swift ├── MTBounceTransition.metal ├── MTBounceTransition.swift ├── MTBowTieHorizontalTransition.metal ├── MTBowTieHorizontalTransition.swift ├── MTBowTieVerticalTransition.metal ├── MTBowTieVerticalTransition.swift ├── MTBurnTransition.metal ├── MTBurnTransition.swift ├── MTButterflyWaveScrawlerTransition.metal ├── MTButterflyWaveScrawlerTransition.swift ├── MTCannabisleafTransition.metal ├── MTCannabisleafTransition.swift ├── MTCircleCropTransition.metal ├── MTCircleCropTransition.swift ├── MTCircleOpenTransition.metal ├── MTCircleOpenTransition.swift ├── MTCircleTransition.metal ├── MTCircleTransition.swift ├── MTColorPhaseTransition.metal ├── MTColorPhaseTransition.swift ├── MTColourDistanceTransition.metal ├── MTColourDistanceTransition.swift ├── MTCoordFromInTransition.metal ├── MTCoordFromInTransition.swift ├── MTCrazyParametricFunTransition.metal ├── MTCrazyParametricFunTransition.swift ├── MTCrossHatchTransition.metal ├── MTCrossHatchTransition.swift ├── MTCrossWarpTransition.metal ├── MTCrossWarpTransition.swift ├── MTCrossZoomTransition.metal ├── MTCrossZoomTransition.swift ├── MTCubeTransition.metal ├── MTCubeTransition.swift ├── MTDirectionalEasingTransition.metal ├── MTDirectionalEasingTransition.swift ├── MTDirectionalTransition.metal ├── MTDirectionalTransition.swift ├── MTDirectionalWarpTransition.metal ├── MTDirectionalWarpTransition.swift ├── MTDirectionalWipeTransition.metal ├── MTDirectionalWipeTransition.swift ├── MTDisplacementTransition.metal ├── MTDisplacementTransition.swift ├── MTDissolveTransition.metal ├── MTDissolveTransition.swift ├── MTDoomScreenTransition.metal ├── MTDoomScreenTransition.swift ├── MTDoorwayTransition.metal ├── MTDoorwayTransition.swift ├── MTDreamyTransition.metal ├── MTDreamyTransition.swift ├── MTDreamyZoomTransition.metal ├── MTDreamyZoomTransition.swift ├── MTFadeColorTransition.metal ├── MTFadeColorTransition.swift ├── MTFadeInWipeLeftTransition.metal ├── MTFadeInWipeLeftTransition.swift ├── MTFadeInWipeUpTransition.metal ├── MTFadeInWipeUpTransition.swift ├── MTFadeTransition.metal ├── MTFadeTransition.swift ├── MTFadegrayscaleTransition.metal ├── MTFadegrayscaleTransition.swift ├── MTFlyeyeTransition.metal ├── MTFlyeyeTransition.swift ├── MTGlitchDisplaceTransition.metal ├── MTGlitchDisplaceTransition.swift ├── MTGlitchMemoriesTransition.metal ├── MTGlitchMemoriesTransition.swift ├── MTGridFlipTransition.metal ├── MTGridFlipTransition.swift ├── MTHeartTransition.metal ├── MTHeartTransition.swift ├── MTHexagonalizeTransition.metal ├── MTHexagonalizeTransition.swift ├── MTInvertedPageCurlTransition.metal ├── MTInvertedPageCurlTransition.swift ├── MTKaleidoScopeTransition.metal ├── MTKaleidoScopeTransition.swift ├── MTLeftRightTransition.metal ├── MTLeftRightTransition.swift ├── MTLinearBlurTransition.metal ├── MTLinearBlurTransition.swift ├── MTLissajousTilesTransition.metal ├── MTLissajousTilesTransition.swift ├── MTLumaTransition.metal ├── MTLumaTransition.swift ├── MTLuminanceMeltTransition.metal ├── MTLuminanceMeltTransition.swift ├── MTMorphTransition.metal ├── MTMorphTransition.swift ├── MTMosaicTransition.metal ├── MTMosaicTransition.swift ├── MTMosaicYueDevTransition.metal ├── MTMosaicYueDevTransition.swift ├── MTMultiplyBlendTransition.metal ├── MTMultiplyBlendTransition.swift ├── MTNoneTransition.swift ├── MTOverexposureTransition.metal ├── MTOverexposureTransition.swift ├── MTParametricGlitchTransition.metal ├── MTParametricGlitchTransition.swift ├── MTPerlinTransition.metal ├── MTPerlinTransition.swift ├── MTPinwheelTransition.metal ├── MTPinwheelTransition.swift ├── MTPixelizeTransition.metal ├── MTPixelizeTransition.swift ├── MTPolarFunctionTransition.metal ├── MTPolarFunctionTransition.swift ├── MTPolkaDotsCurtainTransition.metal ├── MTPolkaDotsCurtainTransition.swift ├── MTPowerKaleidoTransition.metal ├── MTPowerKaleidoTransition.swift ├── MTRadialTransition.metal ├── MTRadialTransition.swift ├── MTRandomNoisexTransition.metal ├── MTRandomNoisexTransition.swift ├── MTRandomSquaresTransition.metal ├── MTRandomSquaresTransition.swift ├── MTRippleTransition.metal ├── MTRippleTransition.swift ├── MTRotateScaleFadeTransition.metal ├── MTRotateScaleFadeTransition.swift ├── MTRotateTransition.metal ├── MTRotateTransition.swift ├── MTScaleInTransition.metal ├── MTScaleInTransition.swift ├── MTSimpleZoomTransition.metal ├── MTSimpleZoomTransition.swift ├── MTSquaresWireTransition.metal ├── MTSquaresWireTransition.swift ├── MTSqueezeTransition.metal ├── MTSqueezeTransition.swift ├── MTStarWipeTransition.metal ├── MTStarWipeTransition.swift ├── MTStaticFadeTransition.metal ├── MTStaticFadeTransition.swift ├── MTStereoViewerTransition.metal ├── MTStereoViewerTransition.swift ├── MTSwapTransition.metal ├── MTSwapTransition.swift ├── MTSwirlTransition.metal ├── MTSwirlTransition.swift ├── MTTVStaticTransition.metal ├── MTTVStaticTransition.swift ├── MTTangentMotionBlurTransition.metal ├── MTTangentMotionBlurTransition.swift ├── MTTopBottomTransition.metal ├── MTTopBottomTransition.swift ├── MTTransitionLib.h ├── MTUndulatingBurnOutTransition.metal ├── MTUndulatingBurnOutTransition.swift ├── MTWaterDropTransition.metal ├── MTWaterDropTransition.swift ├── MTWindTransition.metal ├── MTWindTransition.swift ├── MTWindowBlindsTransition.metal ├── MTWindowBlindsTransition.swift ├── MTWindowSliceTransition.metal ├── MTWindowSliceTransition.swift ├── MTWipeDownTransition.metal ├── MTWipeDownTransition.swift ├── MTWipeLeftTransition.metal ├── MTWipeLeftTransition.swift ├── MTWipeRightTransition.metal ├── MTWipeRightTransition.swift ├── MTWipeUpTransition.metal ├── MTWipeUpTransition.swift ├── MTZoomInCirclesTransition.metal └── MTZoomInCirclesTransition.swift └── UIImage+Extensions.swift /Assets/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Assets/1.gif -------------------------------------------------------------------------------- /Assets/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Assets/2.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MTTransitions.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'MTTransitions' 3 | s.version = '1.6.6' 4 | s.license = 'MIT' 5 | s.requires_arc = true 6 | s.source = { :git => 'https://github.com/alexiscn/MTTransitions.git', :tag => s.version.to_s } 7 | 8 | s.summary = 'MTTransitions' 9 | s.homepage = 'https://github.com/alexiscn/MTTransitions' 10 | s.license = { :type => 'MIT' } 11 | s.author = { 'alexiscn' => 'shuifengxu@gmail.com' } 12 | s.platform = :ios 13 | s.swift_version = '5.0' 14 | s.source_files = 'Source/**/*.{swift,metal,h}' 15 | s.resource = 'Source/**/Assets.bundle' 16 | s.ios.deployment_target = '11.0' 17 | s.xcconfig = { 'MTL_HEADER_SEARCH_PATHS' => '${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal/MetalPetal.framework/Headers'} 18 | 19 | s.weak_frameworks = 'MetalKit' 20 | 21 | s.dependency 'MetalPetal' 22 | s.dependency 'MetalPetal/Swift' 23 | 24 | end 25 | -------------------------------------------------------------------------------- /MTTransitionsDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MTTransitionsDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MTTransitionsDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /MTTransitionsDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/1.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/2.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/3.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/4.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/5.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/6.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/7.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/8.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/9.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/audio1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/audio1.mp3 -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/audio2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/audio2.mp3 -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/clip1.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/clip1.mp4 -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/clip2.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/clip2.mp4 -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/clip3.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/clip3.mp4 -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/cut1.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/cut1.mp4 -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/cut2.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/cut2.mp4 -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/cut3.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/cut3.mp4 -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/wallpaper01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/wallpaper01.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Resources/wallpaper02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Resources/wallpaper02.jpg -------------------------------------------------------------------------------- /MTTransitionsDemo/Samples/PresentBViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PresentBViewController.swift 3 | // MTTransitionsDemo 4 | // 5 | // Created by alexiscn on 2020/3/21. 6 | // Copyright © 2020 alexiscn. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class PresentBViewController: WallpaperViewController { 12 | 13 | override var wallpaper: String { return "wallpaper02.jpg" } 14 | 15 | private var dismissButton: UIButton! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | dismissButton = UIButton(type: .system) 21 | dismissButton.setTitle("Dismiss", for: .normal) 22 | dismissButton.addTarget(self, action: #selector(handleActionButtonClicked), for: .touchUpInside) 23 | view.addSubview(dismissButton) 24 | 25 | dismissButton.translatesAutoresizingMaskIntoConstraints = false 26 | NSLayoutConstraint.activate([ 27 | dismissButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor), 28 | dismissButton.centerYAnchor.constraint(equalTo: self.view.centerYAnchor) 29 | ]) 30 | } 31 | 32 | @objc private func handleActionButtonClicked() { 33 | dismiss(animated: true, completion: nil) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MTTransitionsDemo/Samples/PushAViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PushAViewController.swift 3 | // MTTransitionsDemo 4 | // 5 | // Created by alexiscn on 2020/3/21. 6 | // Copyright © 2020 alexiscn. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MTTransitions 11 | 12 | class PushAViewController: WallpaperViewController { 13 | 14 | private let transition = MTViewControllerTransition(effect: .displacement) 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | let actionButton = UIBarButtonItem(title: "Push", style: .plain, target: self, action: #selector(handleActionButtonClicked)) 20 | navigationItem.rightBarButtonItem = actionButton 21 | } 22 | 23 | @objc private func handleActionButtonClicked() { 24 | let vc = PushBViewController() 25 | navigationController?.delegate = self 26 | navigationController?.pushViewController(vc, animated: true) 27 | } 28 | } 29 | 30 | extension PushAViewController: UINavigationControllerDelegate { 31 | 32 | func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { 33 | if operation == .push { 34 | return transition 35 | } 36 | return nil 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /MTTransitionsDemo/Samples/PushBViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PushBViewController.swift 3 | // MTTransitionsDemo 4 | // 5 | // Created by alexiscn on 2020/3/21. 6 | // Copyright © 2020 alexiscn. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class PushBViewController: WallpaperViewController { 12 | 13 | override var wallpaper: String { return "wallpaper02.jpg" } 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/MTTransitionsDemo/Supporting Files/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png -------------------------------------------------------------------------------- /MTTransitionsDemo/Supporting Files/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.1 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "MTTransitions", 7 | platforms: [.iOS(.v11)], 8 | products: [.library(name: "MTTransitions", 9 | targets: ["MTTransitions"]), 10 | ], 11 | dependencies: [ 12 | // Dependencies declare other packages that this package depends on. 13 | .package(url: "https://github.com/MetalPetal/MetalPetal", from: "1.24.0"), 14 | ], 15 | targets: [ 16 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 17 | // Targets can depend on other targets in this package, and on products in packages which this package depends on. 18 | .target(name: "MTTransitions", 19 | dependencies: ["MetalPetal"], 20 | path: "Source") 21 | ], 22 | swiftLanguageVersions: [.v5] 23 | ) 24 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform:ios, '11.0' 2 | use_frameworks! 3 | 4 | target 'MTTransitionsDemo' do 5 | pod 'MTTransitions', :path => '.' 6 | end 7 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MetalPetal (1.23.0): 3 | - MetalPetal/Core (= 1.23.0) 4 | - MetalPetal/Core (1.23.0) 5 | - MetalPetal/Swift (1.23.0): 6 | - MetalPetal/Core 7 | - MTTransitions (1.6.6): 8 | - MetalPetal 9 | - MetalPetal/Swift 10 | 11 | DEPENDENCIES: 12 | - MTTransitions (from `.`) 13 | 14 | SPEC REPOS: 15 | trunk: 16 | - MetalPetal 17 | 18 | EXTERNAL SOURCES: 19 | MTTransitions: 20 | :path: "." 21 | 22 | SPEC CHECKSUMS: 23 | MetalPetal: 006266db17a9bc070039828e356fb87bd4696cfa 24 | MTTransitions: 75682a7e03f257fd228f0c1e890c620d935923e7 25 | 26 | PODFILE CHECKSUM: cd0bc42ffb43535af6ea50b27fff755caa97ca66 27 | 28 | COCOAPODS: 1.16.2 29 | -------------------------------------------------------------------------------- /Pods/Local Podspecs/MTTransitions.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MTTransitions", 3 | "version": "1.6.6", 4 | "license": { 5 | "type": "MIT" 6 | }, 7 | "requires_arc": true, 8 | "source": { 9 | "git": "https://github.com/alexiscn/MTTransitions.git", 10 | "tag": "1.6.6" 11 | }, 12 | "summary": "MTTransitions", 13 | "homepage": "https://github.com/alexiscn/MTTransitions", 14 | "authors": { 15 | "alexiscn": "shuifengxu@gmail.com" 16 | }, 17 | "platforms": { 18 | "ios": "11.0" 19 | }, 20 | "swift_versions": "5.0", 21 | "source_files": "Source/**/*.{swift,metal,h}", 22 | "resources": "Source/**/Assets.bundle", 23 | "xcconfig": { 24 | "MTL_HEADER_SEARCH_PATHS": "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal/MetalPetal.framework/Headers" 25 | }, 26 | "weak_frameworks": "MetalKit", 27 | "dependencies": { 28 | "MetalPetal": [ 29 | 30 | ], 31 | "MetalPetal/Swift": [ 32 | 33 | ] 34 | }, 35 | "swift_version": "5.0" 36 | } 37 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MetalPetal (1.23.0): 3 | - MetalPetal/Core (= 1.23.0) 4 | - MetalPetal/Core (1.23.0) 5 | - MetalPetal/Swift (1.23.0): 6 | - MetalPetal/Core 7 | - MTTransitions (1.6.6): 8 | - MetalPetal 9 | - MetalPetal/Swift 10 | 11 | DEPENDENCIES: 12 | - MTTransitions (from `.`) 13 | 14 | SPEC REPOS: 15 | trunk: 16 | - MetalPetal 17 | 18 | EXTERNAL SOURCES: 19 | MTTransitions: 20 | :path: "." 21 | 22 | SPEC CHECKSUMS: 23 | MetalPetal: 006266db17a9bc070039828e356fb87bd4696cfa 24 | MTTransitions: 75682a7e03f257fd228f0c1e890c620d935923e7 25 | 26 | PODFILE CHECKSUM: cd0bc42ffb43535af6ea50b27fff755caa97ca66 27 | 28 | COCOAPODS: 1.16.2 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIAlphaPremultiplicationFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUnpremultiplyAlphaFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 30/09/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIFilter.h" 12 | #endif 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @class MTIRenderPipelineKernel; 17 | 18 | __attribute__((objc_subclassing_restricted)) 19 | @interface MTIUnpremultiplyAlphaFilter : NSObject 20 | 21 | @property (nonatomic, class, strong, readonly) MTIRenderPipelineKernel *kernel; 22 | 23 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image; 24 | 25 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image outputPixelFormat:(MTLPixelFormat)pixelFormat; 26 | 27 | @end 28 | 29 | __attribute__((objc_subclassing_restricted)) 30 | @interface MTIPremultiplyAlphaFilter : NSObject 31 | 32 | @property (nonatomic, class, strong, readonly) MTIRenderPipelineKernel *kernel; 33 | 34 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image; 35 | 36 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image outputPixelFormat:(MTLPixelFormat)pixelFormat; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBlendFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIBlendFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 12/10/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #import 11 | #import 12 | #else 13 | #import "MTIFilter.h" 14 | #import "MTIBlendModes.h" 15 | #import "MTIAlphaType.h" 16 | #endif 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | __attribute__((objc_subclassing_restricted)) 21 | @interface MTIBlendFilter : NSObject 22 | 23 | - (instancetype)init NS_UNAVAILABLE; 24 | 25 | + (instancetype)new NS_UNAVAILABLE; 26 | 27 | @property (nonatomic,copy,readonly) MTIBlendMode blendMode; 28 | 29 | - (instancetype)initWithBlendMode:(MTIBlendMode)mode; 30 | 31 | @property (nonatomic,strong,nullable) MTIImage *inputBackgroundImage; 32 | 33 | @property (nonatomic,strong,nullable) MTIImage *inputImage; 34 | 35 | /// Specifies the intensity (in the range [0, 1]) of the operation. 36 | @property (nonatomic) float intensity; 37 | 38 | /// Specifies the alpha type of output image. If `.alphaIsOne` is assigned, the alpha channel of the output image will be set to 1. The default value for this property is `.nonPremultiplied`. 39 | @property (nonatomic) MTIAlphaType outputAlphaType; 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBlendWithMaskFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMaskBlendFilter.h 3 | // MetalPetal 4 | // 5 | // Created by 杨乃川 on 2017/10/26. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIFilter.h" 12 | #endif 13 | 14 | @class MTIMask; 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | __attribute__((objc_subclassing_restricted)) 19 | @interface MTIBlendWithMaskFilter: NSObject 20 | 21 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 22 | 23 | @property (nonatomic, strong, nullable) MTIImage *inputBackgroundImage; 24 | 25 | @property (nonatomic, strong, nullable) MTIMask *inputMask; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBulgeDistortionFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIBulgeDistortionFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/2/14. 6 | // 7 | 8 | #import 9 | #if __has_include() 10 | #import 11 | #else 12 | #import "MTIUnaryImageRenderingFilter.h" 13 | #endif 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | __attribute__((objc_subclassing_restricted)) 18 | @interface MTIBulgeDistortionFilter : MTIUnaryImageRenderingFilter 19 | 20 | /// Specifies the center of the distortion in pixels. 21 | @property (nonatomic) simd_float2 center; 22 | 23 | /// Specifies the radius of the distortion in pixels. 24 | @property (nonatomic) float radius; 25 | 26 | /// Specifies the scale of the distortion, 0 being no-change. 27 | @property (nonatomic) float scale; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END 32 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBulgeDistortionFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIBulgeDistortionFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/2/14. 6 | // 7 | 8 | #import "MTIBulgeDistortionFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | #import "MTIVector+SIMD.h" 11 | 12 | @implementation MTIBulgeDistortionFilter 13 | 14 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 15 | return [[MTIFunctionDescriptor alloc] initWithName:@"bulgeDistortion"]; 16 | } 17 | 18 | - (NSDictionary *)parameters { 19 | return @{@"center": [MTIVector vectorWithFloat2:_center], 20 | @"radius": @(_radius), 21 | @"scale": @(_scale)}; 22 | } 23 | 24 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 25 | return MTIAlphaTypeHandlingRule.passthroughAlphaTypeHandlingRule; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTICLAHEFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICLAHEFilter.h 3 | // Pods 4 | // 5 | // Created by YuAo on 13/10/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIFilter.h" 12 | #endif 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | struct MTICLAHESize { 17 | NSUInteger width, height; 18 | }; 19 | typedef struct MTICLAHESize MTICLAHESize; 20 | 21 | FOUNDATION_EXPORT MTICLAHESize MTICLAHESizeMake(NSUInteger width, NSUInteger height) NS_SWIFT_UNAVAILABLE("Use MTICLAHESize.init instead."); 22 | 23 | /// Performs Contrast Limited Adaptive Histogram Equalization. https://github.com/YuAo/Accelerated-CLAHE 24 | __attribute__((objc_subclassing_restricted)) 25 | @interface MTICLAHEFilter : NSObject 26 | 27 | @property (nonatomic) float clipLimit; 28 | 29 | @property (nonatomic) MTICLAHESize tileGridSize; 30 | 31 | @end 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIChromaKeyBlendFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIChromaKeyBlendFilter.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 29/12/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #import 11 | #else 12 | #import "MTIFilter.h" 13 | #import "MTIColor.h" 14 | #endif 15 | 16 | __attribute__((objc_subclassing_restricted)) 17 | @interface MTIChromaKeyBlendFilter : NSObject 18 | 19 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 20 | 21 | @property (nonatomic, strong, nullable) MTIImage *inputBackgroundImage; 22 | 23 | @property (nonatomic) float thresholdSensitivity; 24 | 25 | @property (nonatomic) float smoothing; 26 | 27 | @property (nonatomic) MTIColor color; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIColorHalftoneFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColorHalftoneFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 17/01/2018. 6 | // 7 | 8 | #import 9 | #if __has_include() 10 | #import 11 | #else 12 | #import "MTIUnaryImageRenderingFilter.h" 13 | #endif 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | __attribute__((objc_subclassing_restricted)) 18 | @interface MTIColorHalftoneFilter : MTIUnaryImageRenderingFilter 19 | 20 | /// Specifies the scale of the operation, i.e. the size for the pixels in the resulting image. 21 | @property (nonatomic) float scale; 22 | 23 | /// Specifies the angles of the r, g, b channel. 24 | @property (nonatomic) simd_float4 angles; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIColorHalftoneFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColorHalftoneFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 17/01/2018. 6 | // 7 | 8 | #import "MTIColorHalftoneFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | #import "MTIVector+SIMD.h" 11 | 12 | @implementation MTIColorHalftoneFilter 13 | 14 | - (instancetype)init { 15 | if (self = [super init]) { 16 | _scale = 20; 17 | _angles = simd_make_float4(M_PI_4, M_PI_4, M_PI_4, 0); 18 | } 19 | return self; 20 | } 21 | 22 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 23 | return [[MTIFunctionDescriptor alloc] initWithName:@"colorHalftone"]; 24 | } 25 | 26 | - (NSDictionary *)parameters { 27 | BOOL allAnglesAreEqual = NO; 28 | if (self.angles.x == self.angles.y && self.angles.y == self.angles.z) { 29 | allAnglesAreEqual = YES; 30 | } 31 | return @{@"scale": @(MAX(self.scale, 1.0f)), 32 | @"angles": [MTIVector vectorWithFloat4:self.angles], 33 | @"singleAngleMode": @(allAnglesAreEqual)}; 34 | } 35 | 36 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 37 | return MTIAlphaTypeHandlingRule.generalAlphaTypeHandlingRule; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIDotScreenFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIDotScreenFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 18/01/2018. 6 | // 7 | 8 | #import 9 | #if __has_include() 10 | #import 11 | #else 12 | #import "MTIUnaryImageRenderingFilter.h" 13 | #endif 14 | 15 | __attribute__((objc_subclassing_restricted)) 16 | @interface MTIDotScreenFilter : MTIUnaryImageRenderingFilter 17 | 18 | /// Specifies the angle of the effect. 19 | @property (nonatomic) float angle; 20 | 21 | /// Specifies the scale of the operation, i.e. the size for the pixels in the resulting image. 22 | @property (nonatomic) float scale; 23 | 24 | @property (nonatomic) simd_float3 grayColorTransform; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIDotScreenFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIDotScreenFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 18/01/2018. 6 | // 7 | 8 | #import "MTIDotScreenFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | #import "MTIVector+SIMD.h" 11 | #import "MTIColor.h" 12 | 13 | @implementation MTIDotScreenFilter 14 | 15 | - (instancetype)init { 16 | if (self = [super init]) { 17 | _angle = M_PI_4; 18 | _scale = 12.0; 19 | _grayColorTransform = MTIGrayColorTransformDefault; 20 | } 21 | return self; 22 | } 23 | 24 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 25 | return [[MTIFunctionDescriptor alloc] initWithName:@"dotScreen"]; 26 | } 27 | 28 | - (NSDictionary *)parameters { 29 | return @{@"angle": @(self.angle), 30 | @"scale": @(MAX(self.scale, 1.0f)), 31 | @"grayColorTransform": [MTIVector vectorWithFloat3:self.grayColorTransform]}; 32 | } 33 | 34 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 35 | return MTIAlphaTypeHandlingRule.generalAlphaTypeHandlingRule; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFilter.h 3 | // Pods 4 | // 5 | // Created by YuAo on 25/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | FOUNDATION_EXPORT NSString * const MTIFilterPassthroughVertexFunctionName; 15 | FOUNDATION_EXPORT NSString * const MTIFilterPassthroughFragmentFunctionName; 16 | 17 | FOUNDATION_EXPORT NSString * const MTIFilterUnpremultiplyAlphaFragmentFunctionName; 18 | FOUNDATION_EXPORT NSString * const MTIFilterUnpremultiplyAlphaWithSRGBToLinearRGBFragmentFunctionName; 19 | FOUNDATION_EXPORT NSString * const MTIFilterPremultiplyAlphaFragmentFunctionName; 20 | 21 | FOUNDATION_EXPORT NSString * const MTIFilterColorMatrixFragmentFunctionName; 22 | 23 | @class MTIImage; 24 | 25 | @protocol MTIFilter 26 | 27 | @property (nonatomic) MTLPixelFormat outputPixelFormat; //Default: MTIPixelFormatUnspecified aka MTLPixelFormatInvalid 28 | 29 | @property (nonatomic, readonly, nullable) MTIImage *outputImage; 30 | 31 | @end 32 | 33 | @protocol MTIUnaryFilter 34 | 35 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFilter.m 3 | // Pods 4 | // 5 | // Created by YuAo on 25/06/2017. 6 | // 7 | // 8 | 9 | #import "MTIFilter.h" 10 | #import "MTIVertex.h" 11 | #import "MTIImage.h" 12 | #import "MTIFunctionDescriptor.h" 13 | 14 | NSString * const MTIFilterPassthroughVertexFunctionName = @"passthroughVertex"; 15 | NSString * const MTIFilterPassthroughFragmentFunctionName = @"passthrough"; 16 | 17 | NSString * const MTIFilterUnpremultiplyAlphaFragmentFunctionName = @"unpremultiplyAlpha"; 18 | NSString * const MTIFilterUnpremultiplyAlphaWithSRGBToLinearRGBFragmentFunctionName = @"unpremultiplyAlphaWithSRGBToLinearRGB"; 19 | NSString * const MTIFilterPremultiplyAlphaFragmentFunctionName = @"premultiplyAlpha"; 20 | 21 | NSString * const MTIFilterColorMatrixFragmentFunctionName = @"colorMatrixProjection"; 22 | 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIHexagonalBokehBlurFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIHexagonalBokehBlurFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 13/10/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIFilter.h" 12 | #endif 13 | 14 | @class MTIMask; 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | /// An implementation of lens blur (bokeh) based on `Siggraph 2011 - Advances in Real-Time Rendering` 19 | /// https://colinbarrebrisebois.com/2017/04/18/hexagonal-bokeh-blur-revisited/ 20 | 21 | __attribute__((objc_subclassing_restricted)) 22 | @interface MTIHexagonalBokehBlurFilter : NSObject 23 | 24 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 25 | @property (nonatomic, strong, nullable) MTIMask *inputMask; 26 | 27 | @property (nonatomic) float radius; 28 | @property (nonatomic) float brightness; 29 | @property (nonatomic) float angle; 30 | 31 | @end 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIHighPassSkinSmoothingFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIHighPassSkinSmoothingFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 15/01/2018. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIFilter.h" 12 | #endif 13 | 14 | @class MTIVector; 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | __attribute__((objc_subclassing_restricted)) 19 | @interface MTIHighPassSkinSmoothingFilter : NSObject 20 | 21 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 22 | 23 | @property (nonatomic) float amount; 24 | 25 | @property (nonatomic) float radius; 26 | 27 | @property (nonatomic, copy, null_resettable) NSArray *toneCurveControlPoints; 28 | 29 | + (BOOL)isSupportedOnDevice:(id)device; 30 | 31 | @end 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIImage+Filters.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImage+Filters.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 30/09/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #import 11 | #else 12 | #import "MTIFilter.h" 13 | #import "MTIImage.h" 14 | #endif 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | @interface MTIImage (Filters) 19 | 20 | - (MTIImage *)imageByUnpremultiplyingAlpha; 21 | 22 | - (MTIImage *)imageByPremultiplyingAlpha; 23 | 24 | - (MTIImage *)imageByUnpremultiplyingAlphaWithPixelFormat:(MTLPixelFormat)pixelFormat NS_SWIFT_NAME(unpremultiplyingAlpha(outputPixelFormat:)); 25 | 26 | - (MTIImage *)imageByPremultiplyingAlphaWithPixelFormat:(MTLPixelFormat)pixelFormat NS_SWIFT_NAME(premultiplyingAlpha(outputPixelFormat:)); 27 | 28 | - (MTIImage *)imageByApplyingCGOrientation:(CGImagePropertyOrientation)orientation NS_SWIFT_NAME(oriented(_:)); 29 | 30 | - (MTIImage *)imageByApplyingCGOrientation:(CGImagePropertyOrientation)orientation outputPixelFormat:(MTLPixelFormat)pixelFormat NS_SWIFT_NAME(oriented(_:outputPixelFormat:)); 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSBoxBlurFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSBoxBlurFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 18/01/2018. 6 | // 7 | #import 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIFilter.h" 12 | #endif 13 | 14 | __attribute__((objc_subclassing_restricted)) 15 | @interface MTIMPSBoxBlurFilter : NSObject 16 | 17 | @property (nonatomic) simd_int2 size; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSDefinitionFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSDefinitionFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/8/21. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIFilter.h" 12 | #endif 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | __attribute__((objc_subclassing_restricted)) 17 | @interface MTIMPSDefinitionFilter : NSObject 18 | 19 | @property (nonatomic) float intensity; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSGaussianBlurFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSGaussianBlurFilter.h 3 | // Pods 4 | // 5 | // Created by YuAo on 03/08/2017. 6 | // 7 | // 8 | 9 | #if __has_include() 10 | #import 11 | #else 12 | #import "MTIFilter.h" 13 | #endif 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | __attribute__((objc_subclassing_restricted)) 18 | @interface MTIMPSGaussianBlurFilter : NSObject 19 | 20 | @property (nonatomic) float radius; 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSHistogramFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSHistogramFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/6/11. 6 | // 7 | 8 | #import 9 | #import 10 | #if __has_include() 11 | #import 12 | #else 13 | #import "MTIFilter.h" 14 | #endif 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | typedef NS_OPTIONS(NSUInteger, MTIHistogramType) { 19 | MTIHistogramTypeLuminance = 1 << 0, 20 | MTIHistogramTypeRGB = 1 << 1 21 | }; 22 | 23 | __attribute__((objc_subclassing_restricted)) 24 | @interface MTIMPSHistogramFilter : NSObject 25 | 26 | - (void)setOutputPixelFormat:(MTLPixelFormat)outputPixelFormat NS_UNAVAILABLE; 27 | 28 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 29 | 30 | @property (nonatomic) float scaleFactor; //Unimplemented 31 | 32 | @property (nonatomic) MTIHistogramType type; //Unimplemented 33 | 34 | @end 35 | 36 | __attribute__((objc_subclassing_restricted)) 37 | @interface MTIHistogramDisplayFilter: NSObject 38 | 39 | @property (nonatomic) CGSize outputSize; 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSSobelFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSSobelFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 11/12/2017. 6 | // 7 | 8 | #import 9 | #if __has_include() 10 | #import 11 | #else 12 | #import "MTIFilter.h" 13 | #endif 14 | 15 | typedef NS_ENUM(NSUInteger, MTIMPSSobelColorMode) { 16 | MTIMPSSobelColorModeAuto, 17 | MTIMPSSobelColorModeGrayscale, 18 | MTIMPSSobelColorModeGrayscaleInverted 19 | }; 20 | 21 | __attribute__((objc_subclassing_restricted)) 22 | @interface MTIMPSSobelFilter : NSObject 23 | 24 | @property (nonatomic, readonly) simd_float3 grayColorTransform; 25 | 26 | - (instancetype)initWithGrayColorTransform:(simd_float3)grayColorTransform NS_DESIGNATED_INITIALIZER; 27 | 28 | @property (nonatomic) MTIMPSSobelColorMode colorMode; 29 | 30 | @end 31 | 32 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSUnsharpMaskFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUSMSharpenFilter.h 3 | // MetalPetal 4 | // 5 | // Created by yi chen on 2018/2/7. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIFilter.h" 12 | #endif 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | __attribute__((objc_subclassing_restricted)) 17 | @interface MTIMPSUnsharpMaskFilter : NSObject 18 | 19 | @property (nonatomic) float scale; //(0, 1]. Default is 0.5. 20 | @property (nonatomic) float radius; 21 | @property (nonatomic) float threshold; //[0, 1). Default is 0. 22 | 23 | @end 24 | 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMultilayerCompositingFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMultilayerCompositingFilter.h 3 | // Pods 4 | // 5 | // Created by YuAo on 27/09/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #import 11 | #else 12 | #import "MTIFilter.h" 13 | #import "MTIAlphaType.h" 14 | #endif 15 | 16 | @class MTILayer; 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | /// A filter that allows you to compose multiple `MTILayer` objects onto a background image. A `MTIMultilayerCompositingFilter` object skips the actual rendering when its `layers.count` is zero. 21 | __attribute__((objc_subclassing_restricted)) 22 | @interface MTIMultilayerCompositingFilter : NSObject 23 | 24 | @property (nonatomic, strong, nullable) MTIImage *inputBackgroundImage; 25 | 26 | @property (nonatomic, copy) NSArray *layers; 27 | 28 | @property (nonatomic) NSUInteger rasterSampleCount; 29 | 30 | /// Specifies the alpha type of output image. If `.alphaIsOne` is assigned, the alpha channel of the output image will be set to 1. The default value for this property is `.nonPremultiplied`. 31 | @property (nonatomic) MTIAlphaType outputAlphaType; 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIPixellateFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPixellateFilter.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 08/01/2018. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIUnaryImageRenderingFilter.h" 12 | #endif 13 | 14 | __attribute__((objc_subclassing_restricted)) 15 | @interface MTIPixellateFilter : MTIUnaryImageRenderingFilter 16 | 17 | /// Specifies the scale of the operation, i.e. the size for the pixels in the resulting image. 18 | @property (nonatomic) CGSize scale; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIPixellateFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPixellateFilter.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 08/01/2018. 6 | // 7 | 8 | #import "MTIPixellateFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | #import "MTIVector.h" 11 | 12 | @implementation MTIPixellateFilter 13 | 14 | - (instancetype)init { 15 | if (self = [super init]) { 16 | _scale = CGSizeMake(16.0, 16.0); 17 | } 18 | return self; 19 | } 20 | 21 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 22 | return [[MTIFunctionDescriptor alloc] initWithName:@"pixellate"]; 23 | } 24 | 25 | - (NSDictionary *)parameters { 26 | return @{@"scale": [MTIVector vectorWithCGSize:CGSizeMake(MAX(self.scale.width,1), MAX(self.scale.height,1))]}; 27 | } 28 | 29 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 30 | return MTIAlphaTypeHandlingRule.passthroughAlphaTypeHandlingRule; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIRGBColorSpaceConversionFilter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRGBColorSpaceConversionFilter.swift 3 | // Pods 4 | // 5 | // Created by YuAo on 2021/4/13. 6 | // 7 | 8 | import Foundation 9 | import Metal 10 | 11 | #if SWIFT_PACKAGE 12 | import MetalPetalObjectiveC.Core 13 | #endif 14 | 15 | extension MTIRGBColorSpaceConversionFilter { 16 | public static func convert(_ image: MTIImage, from inputColorSpace: MTIRGBColorSpace, to outputColorSpace: MTIRGBColorSpace, alphaType: MTIAlphaType, pixelFormat: MTLPixelFormat = .unspecified) -> MTIImage { 17 | return MTIRGBColorSpaceConversionFilter.__image(byConverting: image, from: inputColorSpace, to: outputColorSpace, outputAlphaType: alphaType, outputPixelFormat: pixelFormat) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIRGBToneCurveFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRGBToneCurveFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 12/01/2018. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIFilter.h" 12 | #endif 13 | 14 | @class MTIVector; 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | __attribute__((objc_subclassing_restricted)) 19 | @interface MTIRGBToneCurveFilter : NSObject 20 | 21 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 22 | 23 | @property (nonatomic, copy) NSArray *redControlPoints; 24 | @property (nonatomic, copy) NSArray *greenControlPoints; 25 | @property (nonatomic, copy) NSArray *blueControlPoints; 26 | @property (nonatomic, copy) NSArray *RGBCompositeControlPoints; 27 | 28 | @property (nonatomic) float intensity; //default 1.0 29 | 30 | @property (nonatomic, strong, readonly) MTIImage *toneCurveColorLookupImage; 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIRoundCornerFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRoundCornerFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/12/20. 6 | // 7 | 8 | #import 9 | #if __has_include() 10 | #import 11 | #import 12 | #else 13 | #import "MTIFilter.h" 14 | #import "MTICorner.h" 15 | #endif 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | __attribute__((objc_subclassing_restricted)) 20 | @interface MTIRoundCornerFilter : NSObject 21 | 22 | @property (nonatomic) MTICornerRadius cornerRadius; 23 | @property (nonatomic) MTICornerCurve cornerCurve; 24 | 25 | @property (nonatomic) simd_float4 radius __attribute__((deprecated("Use `cornerRadius` and `cornerCurve` instead."))); 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIVibranceFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIVibranceFilter.h 3 | // MetalPetal 4 | // 5 | // Created by 杨乃川 on 2017/11/6. 6 | // 7 | 8 | #import 9 | #if __has_include() 10 | #import 11 | #else 12 | #import "MTIUnaryImageRenderingFilter.h" 13 | #endif 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | __attribute__((objc_subclassing_restricted)) 18 | @interface MTIVibranceFilter : MTIUnaryImageRenderingFilter 19 | 20 | /// Specifies the scale of the operation in the range of -1 to 1, with 0 being no-change. 21 | @property (nonatomic) float amount; 22 | 23 | @property (nonatomic) BOOL avoidsSaturatingSkinTones; 24 | 25 | @property (nonatomic) simd_float3 grayColorTransform; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIComputePipelineKernel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIComputePipelineKernel.swift 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/10/26. 6 | // 7 | 8 | import Foundation 9 | import Metal 10 | 11 | #if SWIFT_PACKAGE 12 | import MetalPetalObjectiveC.Core 13 | #endif 14 | 15 | extension MTIComputeFunctionDispatchOptions { 16 | public convenience init(_ generator: @escaping (_ pipelineState: MTLComputePipelineState) -> (threads: MTLSize, threadgroups: MTLSize, threadsPerThreadgroup: MTLSize)) { 17 | self.init(__generator: { pipelineState, threadsPtr, threadgroupsPtr, threadsPerThreadgroupPtr in 18 | let results = generator(pipelineState) 19 | threadsPtr.pointee = results.threads 20 | threadgroupsPtr.pointee = results.threadgroups 21 | threadsPerThreadgroupPtr.pointee = results.threadsPerThreadgroup 22 | }) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIKernel.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIKernel.h 3 | // Pods 4 | // 5 | // Created by YuAo on 02/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class MTIContext; 14 | 15 | @protocol MTIKernelConfiguration 16 | 17 | @property (nonatomic, copy, readonly) id identifier; 18 | 19 | @end 20 | 21 | /// A kernel must be stateless. 22 | 23 | @protocol MTIKernel 24 | 25 | - (nullable id)newKernelStateWithContext:(MTIContext *)context configuration:(nullable id)configuration error:(NSError **)error NS_SWIFT_NAME(makeKernelState(context:configuration:)); 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIMultilayerCompositeKernel.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMultilayerRenderPipelineKernel.h 3 | // MetalPetal 4 | // 5 | // Created by YuAo on 27/09/2017. 6 | // 7 | 8 | #import 9 | #if __has_include() 10 | #import 11 | #import 12 | #import 13 | #else 14 | #import "MTIKernel.h" 15 | #import "MTITextureDimensions.h" 16 | #import "MTIAlphaType.h" 17 | #endif 18 | 19 | NS_ASSUME_NONNULL_BEGIN 20 | 21 | @class MTIRenderPipeline, MTIFunctionDescriptor, MTIContext, MTIImage, MTILayer; 22 | 23 | __attribute__((objc_subclassing_restricted)) 24 | @interface MTIMultilayerCompositeKernel : NSObject 25 | 26 | - (MTIImage *)applyToBackgroundImage:(MTIImage *)image 27 | layers:(NSArray *)layers 28 | rasterSampleCount:(NSUInteger)rasterSampleCount 29 | outputAlphaType:(MTIAlphaType)outputAlphaType 30 | outputTextureDimensions:(MTITextureDimensions)outputTextureDimensions 31 | outputPixelFormat:(MTLPixelFormat)outputPixelFormat; 32 | 33 | @end 34 | 35 | @class MTIRenderGraphNode; 36 | 37 | FOUNDATION_EXPORT void MTIMultilayerCompositingRenderGraphNodeOptimize(MTIRenderGraphNode *node); 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIRenderCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderCommand.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 26/11/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIGeometry.h" 12 | #endif 13 | 14 | @class MTIRenderPipelineKernel, MTIImage, MTIRenderPassOutputDescriptor; 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | __attribute__((objc_subclassing_restricted)) 19 | @interface MTIRenderCommand : NSObject 20 | 21 | @property (nonatomic, strong, readonly) MTIRenderPipelineKernel *kernel; 22 | 23 | @property (nonatomic, copy, readonly) id geometry; 24 | 25 | @property (nonatomic, copy, readonly) NSArray *images; 26 | 27 | @property (nonatomic, copy, readonly) NSDictionary *parameters; 28 | 29 | - (instancetype)init NS_UNAVAILABLE; 30 | 31 | + (instancetype)new NS_UNAVAILABLE; 32 | 33 | - (instancetype)initWithKernel:(MTIRenderPipelineKernel *)kernel 34 | geometry:(id)geometry 35 | images:(NSArray *)images 36 | parameters:(NSDictionary *)parameters NS_DESIGNATED_INITIALIZER; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIRenderCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderCommand.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 26/11/2017. 6 | // 7 | 8 | #import "MTIRenderCommand.h" 9 | #import "MTIRenderPipelineKernel.h" 10 | #import "MTIImage.h" 11 | 12 | @implementation MTIRenderCommand 13 | 14 | - (instancetype)initWithKernel:(MTIRenderPipelineKernel *)kernel geometry:(id)geometry images:(NSArray *)images parameters:(NSDictionary *)parameters { 15 | if (self = [super init]) { 16 | NSParameterAssert(kernel); 17 | NSParameterAssert(images); 18 | NSParameterAssert(parameters); 19 | NSParameterAssert(geometry); 20 | NSParameterAssert([kernel.alphaTypeHandlingRule _canHandleAlphaTypesInImages:images]); 21 | _kernel = kernel; 22 | _geometry = [geometry copyWithZone:nil]; 23 | _images = [images copy]; 24 | _parameters = [parameters copy]; 25 | } 26 | return self; 27 | } 28 | 29 | - (id)copyWithZone:(NSZone *)zone { 30 | return self; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIBlendFormulaSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // This is an auto-generated source file. 3 | // 4 | 5 | #import 6 | 7 | FOUNDATION_EXPORT NSString * MTIBuildBlendFormulaShaderSource(NSString *formula); 8 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVMetalIOSurfaceBridge.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVMetalIOSurfaceBridge.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/10/10. 6 | // 7 | 8 | #import 9 | #if __has_include() 10 | #import 11 | #else 12 | #import "MTICVMetalTextureBridging.h" 13 | #endif 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | FOUNDATION_EXPORT NSString * const MTICVMetalIOSurfaceBridgeErrorDomain; 18 | 19 | typedef NS_ERROR_ENUM(MTICVMetalIOSurfaceBridgeErrorDomain, MTICVMetalIOSurfaceBridgeError) { 20 | MTICVMetalIOSurfaceBridgeErrorImageBufferIsNotBackedByIOSurface = 10001, 21 | MTICVMetalIOSurfaceBridgeErrorFailedToCreateTexture = 10002, 22 | MTICVMetalIOSurfaceBridgeErrorCoreVideoDoesNotSupportIOSurface = 10003 23 | }; 24 | 25 | __attribute__((objc_subclassing_restricted)) 26 | NS_CLASS_AVAILABLE(10_11, 11_0) 27 | @interface MTICVMetalIOSurfaceBridge : NSObject 28 | 29 | - (instancetype)init NS_UNAVAILABLE; 30 | 31 | + (instancetype)new NS_UNAVAILABLE; 32 | 33 | - (instancetype)initWithDevice:(id)device; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVMetalTextureBridging.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVMetalTextureBridging.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 2018/10/10. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol MTICVMetalTexture 14 | 15 | @property (nonatomic, readonly) id texture; 16 | 17 | @end 18 | 19 | @protocol MTICVMetalTextureBridging 20 | 21 | + (nullable instancetype)newCoreVideoMetalTextureBridgeWithDevice:(id)device error:(NSError **)error NS_SWIFT_NAME(makeCoreVideoMetalTextureBridge(device:)); 22 | 23 | - (nullable id)newTextureWithCVImageBuffer:(CVImageBufferRef)imageBuffer 24 | textureDescriptor:(MTLTextureDescriptor *)textureDescriptor 25 | planeIndex:(size_t)planeIndex 26 | error:(NSError **)error NS_SWIFT_NAME(makeTexture(with:textureDescriptor:planeIndex:)); 27 | 28 | - (void)flushCache; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVMetalTextureCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVMetalTextureCache.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 07/01/2018. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTICVMetalTextureBridging.h" 12 | #endif 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | FOUNDATION_EXPORT NSString * const MTICVMetalTextureCacheErrorDomain; 17 | 18 | typedef NS_ERROR_ENUM(MTICVMetalTextureCacheErrorDomain, MTICVMetalTextureCacheError) { 19 | MTICVMetalTextureCacheErrorMetalIsNotSupported = 10001, 20 | MTICVMetalTextureCacheErrorFailedToInitialize = 10002, 21 | MTICVMetalTextureCacheErrorFailedToCreateTexture = 10003 22 | }; 23 | 24 | /// Thread-safe object-orientated CVMetalTextureCache. 25 | __attribute__((objc_subclassing_restricted)) 26 | @interface MTICVMetalTextureCache : NSObject 27 | 28 | - (instancetype)init NS_UNAVAILABLE; 29 | 30 | + (instancetype)new NS_UNAVAILABLE; 31 | 32 | - (nullable instancetype)initWithDevice:(id)device 33 | cacheAttributes:(nullable NSDictionary *)cacheAttributes 34 | textureAttributes:(nullable NSDictionary *)textureAttributes 35 | error:(NSError **)error; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVPixelBufferRendering.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVPixelBufferRendering.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 08/04/2018. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | typedef NS_ENUM(NSInteger, MTICVPixelBufferRenderingAPI) { 13 | MTICVPixelBufferRenderingAPIDefault = 1, 14 | MTICVPixelBufferRenderingAPIMetalPetal = 1, 15 | MTICVPixelBufferRenderingAPICoreImage = 2 16 | }; 17 | 18 | __attribute__((objc_subclassing_restricted)) 19 | @interface MTICVPixelBufferRenderingOptions: NSObject 20 | 21 | @property (nonatomic, readonly) MTICVPixelBufferRenderingAPI renderingAPI; 22 | 23 | @property (nonatomic, readonly) BOOL sRGB; //An option for treating the pixel buffer data as sRGB image data. Specifying whether to create the texture with an sRGB (gamma corrected) pixel format. 24 | 25 | + (instancetype)new NS_UNAVAILABLE; 26 | 27 | - (instancetype)init NS_UNAVAILABLE; 28 | 29 | - (instancetype)initWithRenderingAPI:(MTICVPixelBufferRenderingAPI)renderingAPI sRGB:(BOOL)sRGB NS_DESIGNATED_INITIALIZER; 30 | 31 | @property (nonatomic, strong, class, readonly) MTICVPixelBufferRenderingOptions *defaultOptions; 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVPixelBufferRendering.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVPixelBufferRendering.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 08/04/2018. 6 | // 7 | 8 | #import "MTICVPixelBufferRendering.h" 9 | 10 | @implementation MTICVPixelBufferRenderingOptions 11 | 12 | - (instancetype)initWithRenderingAPI:(MTICVPixelBufferRenderingAPI)renderingAPI sRGB:(BOOL)sRGB { 13 | if (self = [super init]) { 14 | _renderingAPI = renderingAPI; 15 | _sRGB = sRGB; 16 | } 17 | return self; 18 | } 19 | 20 | - (id)copyWithZone:(NSZone *)zone { 21 | return self; 22 | } 23 | 24 | + (MTICVPixelBufferRenderingOptions *)defaultOptions { 25 | static MTICVPixelBufferRenderingOptions *options; 26 | static dispatch_once_t onceToken; 27 | dispatch_once(&onceToken, ^{ 28 | options = [[MTICVPixelBufferRenderingOptions alloc] initWithRenderingAPI:MTICVPixelBufferRenderingAPIDefault sRGB:NO]; 29 | }); 30 | return options; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIColor.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColor.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 10/10/2017. 6 | // 7 | 8 | #import "MTIColor.h" 9 | 10 | MTIColor const MTIColorWhite = (MTIColor){.red = 1, .green = 1, .blue = 1, .alpha = 1}; 11 | MTIColor const MTIColorBlack = (MTIColor){.red = 0, .green = 0, .blue = 0, .alpha = 1}; 12 | MTIColor const MTIColorClear = (MTIColor){.red = 0, .green = 0, .blue = 0, .alpha = 0}; 13 | 14 | simd_float3 const MTIGrayColorTransform_ITU_R_601 = (simd_float3){0.299f, 0.587f, 0.114f}; 15 | simd_float3 const MTIGrayColorTransform_ITU_R_709 = (simd_float3){0.2126f, 0.7152f, 0.0722f}; 16 | 17 | simd_float3 const MTIGrayColorTransformDefault = MTIGrayColorTransform_ITU_R_601; 18 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColor.swift 3 | // MetalPetal 4 | // 5 | // Created by YuAo on 2020/7/12. 6 | // 7 | 8 | import Foundation 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | extension MTIColor: Hashable { 15 | 16 | public static func == (lhs: Self, rhs: Self) -> Bool { 17 | lhs.red == rhs.red && lhs.green == rhs.green && lhs.blue == rhs.blue && lhs.alpha == rhs.alpha 18 | } 19 | 20 | public func hash(into hasher: inout Hasher) { 21 | hasher.combine(red) 22 | hasher.combine(green) 23 | hasher.combine(blue) 24 | hasher.combine(alpha) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIColorMatrix.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColorMatrix.swift 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 25/10/2017. 6 | // 7 | 8 | import Foundation 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | extension MTIColorMatrix : Equatable { 15 | public static func == (lhs: MTIColorMatrix, rhs: MTIColorMatrix) -> Bool { 16 | return lhs.isEqual(to: rhs) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIComputePipeline.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIComputePipeline.h 3 | // Pods 4 | // 5 | // Created by YuAo on 27/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | __attribute__((objc_subclassing_restricted)) 14 | @interface MTIComputePipeline : NSObject 15 | 16 | @property (nonatomic,strong,readonly) id state; 17 | 18 | @property (nonatomic,strong,readonly) MTLComputePipelineReflection *reflection; 19 | 20 | - (instancetype)init NS_UNAVAILABLE; 21 | 22 | + (instancetype)new NS_UNAVAILABLE; 23 | 24 | - (instancetype)initWithState:(id)state reflection:(MTLComputePipelineReflection *)reflection NS_DESIGNATED_INITIALIZER; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIComputePipeline.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIComputePipeline.m 3 | // Pods 4 | // 5 | // Created by YuAo on 27/07/2017. 6 | // 7 | // 8 | 9 | #import "MTIComputePipeline.h" 10 | 11 | @implementation MTIComputePipeline 12 | 13 | - (instancetype)initWithState:(id)state reflection:(MTLComputePipelineReflection *)reflection { 14 | if (self = [super init]) { 15 | _state = state; 16 | _reflection = reflection; 17 | } 18 | return self; 19 | } 20 | 21 | - (id)copyWithZone:(NSZone *)zone { 22 | return self; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIContext.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIContext.swift 3 | // MetalPetal 4 | // 5 | // Created by YuAo on 2020/7/24. 6 | // 7 | 8 | import Foundation 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | extension MTIContext { 15 | public func startTaskToCreateCGImage(from image: MTIImage, colorSpace: CGColorSpace? = nil, completion: ((MTIRenderTask) -> Void)? = nil) throws -> (image: CGImage, task: MTIRenderTask) { 16 | var outputCGImage: CGImage? 17 | let task = try self.startTask(toCreate: &outputCGImage, from: image, colorSpace: colorSpace, completion: completion) 18 | return (outputCGImage!, task) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICorner.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTICorner.swift 3 | // Pods 4 | // 5 | // Created by YuAo on 2021/4/28. 6 | // 7 | 8 | import Foundation 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | extension MTICornerRadius: Equatable { 15 | public static func == (lhs: MTICornerRadius, rhs: MTICornerRadius) -> Bool { 16 | return lhs.topLeft == rhs.topLeft && 17 | lhs.topRight == rhs.topRight && 18 | lhs.bottomLeft == rhs.bottomLeft && 19 | lhs.bottomRight == rhs.bottomRight 20 | } 21 | } 22 | 23 | extension MTICornerRadius: Hashable { 24 | public func hash(into hasher: inout Hasher) { 25 | hasher.combine(topLeft) 26 | hasher.combine(topRight) 27 | hasher.combine(bottomLeft) 28 | hasher.combine(bottomRight) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICropRegion.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTICropRegion.swift 3 | // MetalPetal 4 | // 5 | // Created by YuAo on 2021/2/1. 6 | // 7 | 8 | import Foundation 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | extension MTICropRegion { 15 | public static func pixel(_ rect: CGRect) -> MTICropRegion { 16 | MTICropRegion(bounds: rect, unit: .pixel) 17 | } 18 | 19 | public static func fractional(_ rect: CGRect) -> MTICropRegion { 20 | MTICropRegion(bounds: rect, unit: .percentage) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIDataBuffer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIDataBuffer.swift 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/1/24. 6 | // 7 | 8 | import Foundation 9 | import Metal 10 | 11 | #if SWIFT_PACKAGE 12 | import MetalPetalObjectiveC.Core 13 | #endif 14 | 15 | extension MTIDataBuffer { 16 | 17 | public convenience init?(values: [T], options: MTLResourceOptions = []) { 18 | self.init(bytes: values, length: UInt(MemoryLayout.size * values.count), options: options) 19 | } 20 | 21 | public func unsafeAccess(_ block: (UnsafeMutableBufferPointer) throws -> ReturnType) rethrows -> ReturnType { 22 | var result: (pointer: UnsafeMutableRawPointer, length: UInt)! 23 | self.unsafeAccess { (pointer: UnsafeMutableRawPointer, length: UInt) -> Void in 24 | result = (pointer, length) 25 | } 26 | precondition(Int(result.length) % MemoryLayout.size == 0) 27 | return try block(UnsafeMutableBufferPointer(start: result.pointer.assumingMemoryBound(to: BufferContentType.self), count: Int(result.length)/MemoryLayout.size)) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIDefer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUtilities.h 3 | // Pods 4 | // 5 | // Created by yi chen on 2017/7/26. 6 | // 7 | // 8 | 9 | #import 10 | 11 | #define MTI_METAMACRO_CONCAT(A, B) \ 12 | MTI_METAMACRO_CONCAT_(A, B) 13 | 14 | #define MTI_METAMACRO_CONCAT_(A, B) A ## B 15 | 16 | #define MTI_DEFER \ 17 | try {} @finally {} \ 18 | __strong MTIDeferBlock MTI_METAMACRO_CONCAT(MTIExitBlock_, __LINE__) __attribute__((cleanup(MTIExecuteCleanupBlock), unused)) = ^ 19 | 20 | typedef void (^MTIDeferBlock)(void); 21 | 22 | FOUNDATION_EXPORT void MTIExecuteCleanupBlock (__strong MTIDeferBlock *block); 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIDefer.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUtilities.m 3 | // Pods 4 | // 5 | // Created by yi chen on 2017/7/26. 6 | // 7 | // 8 | 9 | #import "MTIDefer.h" 10 | 11 | void MTIExecuteCleanupBlock (__strong MTIDeferBlock *block) { 12 | (*block)(); 13 | } 14 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIDrawableRendering.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIDrawableRendering.m 3 | // Pods 4 | // 5 | // Created by YuAo on 01/07/2017. 6 | // 7 | // 8 | 9 | #import "MTIDrawableRendering.h" 10 | 11 | @implementation MTIDrawableRenderingRequest 12 | 13 | - (instancetype)initWithDrawableProvider:(id)drawableProvider resizingMode:(MTIDrawableRenderingResizingMode)resizingMode { 14 | if (self = [super init]) { 15 | _drawableProvider = drawableProvider; 16 | _resizingMode = resizingMode; 17 | } 18 | return self; 19 | } 20 | 21 | @end 22 | 23 | @implementation MTKView (MTIDrawableProvider) 24 | 25 | - (id)drawableForRequest:(MTIDrawableRenderingRequest *)request { 26 | return self.currentDrawable; 27 | } 28 | 29 | - (MTLRenderPassDescriptor *)renderPassDescriptorForRequest:(MTIDrawableRenderingRequest *)request { 30 | return self.currentRenderPassDescriptor; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIError.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIError.m 3 | // Pods 4 | // 5 | // Created by YuAo on 10/08/2017. 6 | // 7 | // 8 | 9 | #import "MTIError.h" 10 | 11 | NSString * const MTIErrorDomain = @"MTIErrorDomain"; 12 | 13 | NSError * _MTIErrorCreate(MTIError code, NSString *defaultDescription, NSDictionary *userInfo) { 14 | if (userInfo[NSLocalizedDescriptionKey] == nil) { 15 | NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary:userInfo]; 16 | info[NSLocalizedDescriptionKey] = defaultDescription; 17 | return [NSError errorWithDomain:MTIErrorDomain code:code userInfo:info]; 18 | } else { 19 | return [NSError errorWithDomain:MTIErrorDomain code:code userInfo:userInfo]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIError.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIError.swift 3 | // MetalPetal 4 | // 5 | // Created by YuAo on 2020/3/25. 6 | // 7 | 8 | import Foundation 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | extension MTIError: Equatable { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIFunctionArgumentsEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFunctionArgumentsEncoder.h 3 | // MetalPetal 4 | // 5 | // Created by YuAo on 2020/7/11. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @protocol MTIFunctionArgumentEncodingProxy 13 | 14 | - (void)encodeBytes:(const void *)bytes length:(NSUInteger)length; 15 | 16 | @end 17 | 18 | @protocol MTIFunctionArgumentEncoding 19 | 20 | + (BOOL)encodeValue:(id)value argument:(MTLArgument *)argument proxy:(id)proxy error:(NSError **)error; 21 | 22 | @end 23 | 24 | __attribute__((objc_subclassing_restricted)) 25 | @interface MTIFunctionArgumentsEncoder : NSObject 26 | 27 | - (instancetype)init NS_UNAVAILABLE; 28 | 29 | + (instancetype)new NS_UNAVAILABLE; 30 | 31 | + (BOOL)encodeArguments:(NSArray*)arguments 32 | values:(NSDictionary *)parameters 33 | functionType:(MTLFunctionType)functionType 34 | encoder:(id)encoder 35 | error:(NSError **)error; 36 | 37 | @end 38 | 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIFunctionDescriptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFilterFunctionDescriptor.h 3 | // Pods 4 | // 5 | // Created by YuAo on 25/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | __attribute__((objc_subclassing_restricted)) 14 | @interface MTIFunctionDescriptor : NSObject 15 | 16 | @property (nonatomic, copy, readonly, nullable) NSURL *libraryURL; 17 | 18 | @property (nonatomic, copy, readonly) NSString *name; 19 | 20 | @property (nonatomic, copy, readonly, nullable) MTLFunctionConstantValues *constantValues NS_AVAILABLE(10_12, 10_0); 21 | 22 | - (instancetype)init NS_UNAVAILABLE; 23 | 24 | + (instancetype)new NS_UNAVAILABLE; 25 | 26 | - (instancetype)initWithName:(NSString *)name; 27 | 28 | - (instancetype)initWithName:(NSString *)name libraryURL:(nullable NSURL *)URL NS_DESIGNATED_INITIALIZER; 29 | 30 | - (instancetype)initWithName:(NSString *)name constantValues:(nullable MTLFunctionConstantValues *)constantValues libraryURL:(nullable NSURL *)URL NS_AVAILABLE(10_12, 10_0) NS_DESIGNATED_INITIALIZER; 31 | 32 | - (MTIFunctionDescriptor *)functionDescriptorWithConstantValues:(nullable MTLFunctionConstantValues *)constantValues; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIFunctionDescriptor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFunctionDescriptor.swift 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/12/26. 6 | // 7 | 8 | import Foundation 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | extension MTIFunctionDescriptor { 15 | public static let passthroughFragment: MTIFunctionDescriptor = MTIFunctionDescriptor(name: MTIFilterPassthroughFragmentFunctionName) 16 | 17 | public static let passthroughVertex: MTIFunctionDescriptor = MTIFunctionDescriptor(name: MTIFilterPassthroughVertexFunctionName) 18 | } 19 | 20 | extension MTIFunctionDescriptor { 21 | public convenience init(name: String, constantValues: MTLFunctionConstantValues? = nil, in bundle: Bundle) { 22 | self.init(name: name, constantValues: constantValues, libraryURL: MTIDefaultLibraryURLForBundle(bundle)) 23 | } 24 | } 25 | 26 | extension URL { 27 | public static func defaultMetalLibraryURL(for bundleForClass: AnyClass) -> URL! { 28 | return MTIDefaultLibraryURLForBundle(Bundle(for: bundleForClass)) 29 | } 30 | 31 | public static func defaultMetalLibraryURL(for bundle: Bundle) -> URL! { 32 | return MTIDefaultLibraryURLForBundle(bundle) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometry.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIGeometry.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 2018/5/6. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @class MTIRenderPipeline; 13 | 14 | @protocol MTIGeometryRenderingContext 15 | 16 | @property (nonatomic, readonly, strong) MTIRenderPipeline *renderPipeline; 17 | 18 | @property (nonatomic, readonly, strong) id device; 19 | 20 | @end 21 | 22 | @protocol MTIGeometry 23 | 24 | - (void)encodeDrawCallWithCommandEncoder:(id)commandEncoder 25 | context:(id)context; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | 31 | #if __has_include() 32 | #import 33 | #else 34 | #import "MTIRenderPipeline.h" 35 | #endif 36 | 37 | NS_ASSUME_NONNULL_BEGIN 38 | 39 | @interface MTIRenderPipeline (MTIGeometryRenderingContext) 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometry.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIGeometry.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/2/2. 6 | // 7 | 8 | #import "MTIGeometry.h" 9 | 10 | @implementation MTIRenderPipeline (MTIGeometryRenderingContext) 11 | 12 | - (MTIRenderPipeline *)renderPipeline { 13 | return self; 14 | } 15 | 16 | - (id)device { 17 | return self.state.device; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometryUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIGeometryUtilities.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/11/8. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | FOUNDATION_EXPORT CGRect MTIMakeRectWithAspectRatioFillRect(CGSize aspectRatio, CGRect boundingRect) NS_SWIFT_NAME(MTIMakeRect(aspectRatio:fillRect:)); 14 | 15 | FOUNDATION_EXPORT CGRect MTIMakeRectWithAspectRatioInsideRect(CGSize aspectRatio, CGRect boundingRect) NS_SWIFT_NAME(MTIMakeRect(aspectRatio:insideRect:)); 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometryUtilities.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIGeometryUtilities.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/11/8. 6 | // 7 | 8 | #import "MTIGeometryUtilities.h" 9 | #import 10 | 11 | CGRect MTIMakeRectWithAspectRatioFillRect(CGSize aspectRatio, CGRect boundingRect) { 12 | CGFloat horizontalRatio = boundingRect.size.width / aspectRatio.width; 13 | CGFloat verticalRatio = boundingRect.size.height / aspectRatio.height; 14 | CGFloat ratio = MAX(horizontalRatio, verticalRatio); 15 | CGSize newSize = CGSizeMake(aspectRatio.width * ratio, aspectRatio.height * ratio); 16 | CGRect rect = CGRectMake(boundingRect.origin.x + (boundingRect.size.width - newSize.width)/2, boundingRect.origin.y + (boundingRect.size.height - newSize.height)/2, newSize.width, newSize.height); 17 | return rect; 18 | } 19 | 20 | CGRect MTIMakeRectWithAspectRatioInsideRect(CGSize aspectRatio, CGRect boundingRect) { 21 | return AVMakeRectWithAspectRatioInsideRect(aspectRatio, boundingRect); 22 | } 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImage+Promise.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImage-Private.h 3 | // Pods 4 | // 5 | // Created by YuAo on 14/07/2017. 6 | // 7 | // 8 | 9 | #if __has_include() 10 | #import 11 | #else 12 | #import "MTIImage.h" 13 | #endif 14 | @protocol MTIImagePromise; 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | @interface MTIImage (Promise) 19 | 20 | @property (nonatomic,copy,readonly) id promise; 21 | 22 | - (instancetype)initWithPromise:(id)promise; 23 | 24 | - (instancetype)initWithPromise:(id)promise samplerDescriptor:(MTISamplerDescriptor *)samplerDescriptor; 25 | 26 | - (instancetype)initWithPromise:(id)promise samplerDescriptor:(MTISamplerDescriptor *)samplerDescriptor cachePolicy:(MTIImageCachePolicy)cachePolicy; 27 | 28 | - (instancetype)initWithPromise:(id)promise cachePolicy:(MTIImageCachePolicy)cachePolicy; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImageOrientation.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImageOrientation.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 16/10/2017. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | // https://developer.apple.com/documentation/uikit/uiimageorientation?language=objc 12 | 13 | typedef NS_ENUM(NSInteger, MTIImageOrientation) { 14 | MTIImageOrientationUnknown = 0, 15 | MTIImageOrientationUp = 1, 16 | MTIImageOrientationUpMirrored = 2, 17 | MTIImageOrientationDown = 3, 18 | MTIImageOrientationDownMirrored = 4, 19 | MTIImageOrientationLeftMirrored = 5, 20 | MTIImageOrientationRight = 6, 21 | MTIImageOrientationRightMirrored = 7, 22 | MTIImageOrientationLeft = 8 23 | }; 24 | 25 | FOUNDATION_EXPORT MTIImageOrientation MTIImageOrientationFromCGImagePropertyOrientation(CGImagePropertyOrientation orientation) NS_SWIFT_NAME(MTIImageOrientation.init(cgImagePropertyOrientation:)); 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImagePromiseDebug.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImagePromiseDebug.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 23/11/2017. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @protocol MTIImagePromise; 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | typedef NS_ENUM(NSInteger, MTIImagePromiseType) { 16 | MTIImagePromiseTypeSource, 17 | MTIImagePromiseTypeProcessor 18 | }; 19 | 20 | FOUNDATION_EXPORT NSString * MTIImagePromiseDebugIdentifierForObject(id object); 21 | 22 | __attribute__((objc_subclassing_restricted)) 23 | @interface MTIImagePromiseDebugInfo : NSObject 24 | 25 | @property (nonatomic,copy,readonly) NSString *identifier; 26 | 27 | @property (nonatomic,readonly) MTIImagePromiseType type; 28 | 29 | @property (nonatomic,copy,readonly) NSString *title; 30 | 31 | @property (nonatomic,strong,readonly,nullable) id content; 32 | 33 | - (instancetype)init NS_UNAVAILABLE; 34 | 35 | + (instancetype)new NS_UNAVAILABLE; 36 | 37 | - (instancetype)initWithPromise:(id)promise 38 | type:(MTIImagePromiseType)type 39 | content:(id)content; 40 | 41 | @end 42 | 43 | @interface MTIImagePromiseDebugInfo (RenderGraph) 44 | 45 | + (CALayer *)layerRepresentationOfRenderGraphForPromise:(id)promise; 46 | 47 | @end 48 | 49 | NS_ASSUME_NONNULL_END 50 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImageRenderingContext+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImageRenderingContext+Internal.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2020/1/20. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIImageRenderingContext.h" 12 | #endif 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @protocol MTIImagePromiseResolution 17 | 18 | @property (nonatomic,readonly) id texture; 19 | 20 | - (void)markAsConsumedBy:(id)consumer; 21 | 22 | @end 23 | 24 | @interface MTIImageRenderingContext (Internal) 25 | 26 | - (instancetype)initWithContext:(MTIContext *)context; 27 | 28 | - (nullable id)resolutionForImage:(MTIImage *)image error:(NSError **)error; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTILock.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTILock.h 3 | // Pods 4 | // 5 | // Created by YuAo on 05/08/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol MTILocking 14 | 15 | - (BOOL)tryLock; 16 | 17 | @end 18 | 19 | ///Create a non-recursive lock. Unlocking a lock from a different thread other than the locking thread can result in undefined behavior. 20 | FOUNDATION_EXPORT id MTILockCreate(void) NS_RETURNS_RETAINED; 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTILock.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTILock.m 3 | // Pods 4 | // 5 | // Created by YuAo on 05/08/2017. 6 | // 7 | // 8 | 9 | #import "MTILock.h" 10 | #import 11 | 12 | //https://gist.github.com/steipete/36350a8a60693d440954b95ea6cbbafc 13 | 14 | __attribute__((objc_subclassing_restricted)) 15 | OS_UNFAIR_LOCK_AVAILABILITY 16 | @interface MTILock : NSObject { 17 | os_unfair_lock _unfairlock; 18 | } 19 | 20 | @end 21 | 22 | @implementation MTILock 23 | 24 | - (instancetype)init { 25 | if (self = [super init]) { 26 | _unfairlock = OS_UNFAIR_LOCK_INIT; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)lock { 32 | os_unfair_lock_lock(&_unfairlock); 33 | } 34 | 35 | - (void)unlock { 36 | os_unfair_lock_unlock(&_unfairlock); 37 | } 38 | 39 | - (BOOL)tryLock { 40 | return os_unfair_lock_trylock(&_unfairlock); 41 | } 42 | 43 | @end 44 | 45 | id MTILockCreate(void) { 46 | return [[MTILock alloc] init]; 47 | } 48 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIMask.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMask.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 14/11/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIColor.h" 12 | #endif 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @class MTIImage; 17 | 18 | typedef NS_ENUM(NSInteger, MTIMaskMode) { 19 | MTIMaskModeNormal = 0, 20 | MTIMaskModeOneMinusMaskValue 21 | }; 22 | 23 | __attribute__((objc_subclassing_restricted)) 24 | @interface MTIMask : NSObject 25 | 26 | @property (nonatomic, strong, readonly) MTIImage *content; 27 | 28 | @property (nonatomic, readonly) MTIColorComponent component; 29 | 30 | @property (nonatomic, readonly) MTIMaskMode mode; 31 | 32 | - (instancetype)init NS_UNAVAILABLE; 33 | 34 | + (instancetype)new NS_UNAVAILABLE; 35 | 36 | - (instancetype)initWithContent:(MTIImage *)content component:(MTIColorComponent)component mode:(MTIMaskMode)mode NS_DESIGNATED_INITIALIZER; 37 | 38 | - (instancetype)initWithContent:(MTIImage *)content; 39 | 40 | @end 41 | 42 | NS_ASSUME_NONNULL_END 43 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIMask.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMask.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 14/11/2017. 6 | // 7 | 8 | #import "MTIMask.h" 9 | 10 | @implementation MTIMask 11 | 12 | - (instancetype)initWithContent:(MTIImage *)content component:(MTIColorComponent)component mode:(MTIMaskMode)mode { 13 | if (self = [super init]) { 14 | _content = content; 15 | _component = component; 16 | _mode = mode; 17 | } 18 | return self; 19 | } 20 | 21 | - (instancetype)initWithContent:(MTIImage *)content { 22 | return [self initWithContent:content component:MTIColorComponentRed mode:MTIMaskModeNormal]; 23 | } 24 | 25 | - (id)copyWithZone:(NSZone *)zone { 26 | return self; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIMemoryWarningObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMemoryWarningObserver.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/8/27. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @protocol MTIMemoryWarningHandling 13 | 14 | - (void)handleMemoryWarning; 15 | 16 | @end 17 | 18 | __attribute__((objc_subclassing_restricted)) 19 | @interface MTIMemoryWarningObserver : NSObject 20 | 21 | - (instancetype)init NS_UNAVAILABLE; 22 | 23 | + (instancetype)new NS_UNAVAILABLE; 24 | 25 | + (void)addMemoryWarningHandler:(id)memoryWarningHandler; 26 | 27 | + (void)removeMemoryWarningHandler:(id)memoryWarningHandler; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END 32 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIPixelFormat.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPixelFormat.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 11/10/2017. 6 | // 7 | 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatUnspecified NS_REFINED_FOR_SWIFT; //aliased to MTLPixelFormatInvalid 14 | 15 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P NS_REFINED_FOR_SWIFT; 16 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P_sRGB NS_REFINED_FOR_SWIFT; 17 | 18 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR10_420_2P NS_REFINED_FOR_SWIFT; 19 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR10_420_2P_sRGB NS_REFINED_FOR_SWIFT; 20 | 21 | FOUNDATION_EXPORT BOOL MTIDeviceSupportsYCBCRPixelFormat(id device); 22 | 23 | NS_ASSUME_NONNULL_END 24 | 25 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIPixelFormat.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPixelFormat.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 11/10/2017. 6 | // 7 | 8 | #import "MTIPixelFormat.h" 9 | #import 10 | 11 | MTLPixelFormat const MTIPixelFormatUnspecified = MTLPixelFormatInvalid; 12 | 13 | MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P = 500; 14 | MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P_sRGB = 520; 15 | 16 | MTLPixelFormat const MTIPixelFormatYCBCR10_420_2P = 505; 17 | MTLPixelFormat const MTIPixelFormatYCBCR10_420_2P_sRGB = 525; 18 | 19 | BOOL MTIDeviceSupportsYCBCRPixelFormat(id device) { 20 | if (@available(iOS 13.0, tvOS 13.0, macCatalyst 14.0, macOS 11.0, *)) { 21 | if ([device supportsFamily:MTLGPUFamilyApple3]) { 22 | return YES; 23 | } else { 24 | return NO; 25 | } 26 | } else { 27 | #if TARGET_OS_TV 28 | return [device supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily2_v1]; 29 | #elif TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR && !TARGET_OS_MACCATALYST 30 | return [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]; 31 | #else 32 | return NO; 33 | #endif 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIPixelFormat.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPixelFormat.swift 3 | // Pods 4 | // 5 | // Created by Yu Ao on 2018/11/8. 6 | // 7 | 8 | import Metal 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | extension MTLPixelFormat { 15 | public static let unspecified = MTLPixelFormat.invalid 16 | public static let yCbCr8_420_2p = __MTIPixelFormatYCBCR8_420_2P 17 | public static let yCbCr8_420_2p_srgb = __MTIPixelFormatYCBCR8_420_2P_sRGB 18 | public static let yCbCr10_420_2p = __MTIPixelFormatYCBCR10_420_2P 19 | public static let yCbCr10_420_2p_srgb = __MTIPixelFormatYCBCR10_420_2P_sRGB 20 | } 21 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIPrint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPrint.h 3 | // Pods 4 | // 5 | // Created by YuAo on 26/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | #if !defined(MTIPrint) 12 | 13 | #if DEBUG 14 | 15 | #define MTIPrint(format, ...) do { \ 16 | if (getenv("MTI_PRINT_ENABLED") != NULL) {\ 17 | NSLog(format, ##__VA_ARGS__); \ 18 | }\ 19 | } while(0) 20 | 21 | #else 22 | 23 | #define MTIPrint(format, ...) do { } while(0) 24 | 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderGraphOptimization.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderGraphMerge.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 20/11/2017. 6 | // 7 | 8 | #if __has_include() 9 | #import 10 | #else 11 | #import "MTIImagePromise.h" 12 | #endif 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @class MTIImage; 17 | 18 | __attribute__((objc_subclassing_restricted)) 19 | @interface MTIRenderGraphNode: NSObject 20 | 21 | @property (nonatomic, strong, nullable) NSMutableArray *inputs; 22 | 23 | @property (nonatomic, strong, nullable) MTIImage *image; 24 | 25 | @property (nonatomic, readonly) NSInteger uniqueDependentCount; 26 | 27 | @end 28 | 29 | __attribute__((objc_subclassing_restricted)) 30 | @interface MTIRenderGraphOptimizer : NSObject 31 | 32 | + (id)promiseByOptimizingRenderGraphOfPromise:(id)promise; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderPipeline.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderPipelineInfo.h 3 | // Pods 4 | // 5 | // Created by YuAo on 30/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | __attribute__((objc_subclassing_restricted)) 14 | @interface MTIRenderPipeline : NSObject 15 | 16 | @property (nonatomic,strong,readonly) id state; 17 | 18 | @property (nonatomic,strong,readonly) MTLRenderPipelineReflection *reflection; 19 | 20 | - (instancetype)init NS_UNAVAILABLE; 21 | 22 | + (instancetype)new NS_UNAVAILABLE; 23 | 24 | - (instancetype)initWithState:(id)state reflection:(MTLRenderPipelineReflection *)reflection NS_DESIGNATED_INITIALIZER; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderPipeline.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderPipelineInfo.m 3 | // Pods 4 | // 5 | // Created by YuAo on 30/06/2017. 6 | // 7 | // 8 | 9 | #import "MTIRenderPipeline.h" 10 | 11 | @implementation MTIRenderPipeline 12 | 13 | - (instancetype)initWithState:(id)state reflection:(MTLRenderPipelineReflection *)reflection { 14 | if (self = [super init]) { 15 | _state = state; 16 | _reflection = reflection; 17 | } 18 | return self; 19 | } 20 | 21 | - (id)copyWithZone:(NSZone *)zone { 22 | return self; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderTask.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderTask.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/5/22. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @class MTIImageRenderingContext; 13 | 14 | /// Represents a GPU render task - i.e., commands in a command buffer. 15 | __attribute__((objc_subclassing_restricted)) 16 | @interface MTIRenderTask : NSObject 17 | 18 | /// Status of the underlaying command buffer. 19 | @property (readonly) MTLCommandBufferStatus commandBufferStatus; 20 | 21 | - (instancetype)initWithCommandBuffer:(id)commandBuffer NS_DESIGNATED_INITIALIZER; 22 | 23 | - (instancetype)init NS_UNAVAILABLE; 24 | 25 | + (instancetype)new NS_UNAVAILABLE; 26 | 27 | /// Synchronously blocks execution until the task either completes or fails (with error). 28 | - (void)waitUntilCompleted; 29 | 30 | /// If an error occurred during execution, the NSError may contain more details about the problem. 31 | @property (nullable, readonly) NSError *error; 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderTask.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderTask.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/5/22. 6 | // 7 | 8 | #import "MTIRenderTask.h" 9 | #import "MTIImageRenderingContext.h" 10 | 11 | @interface MTIRenderTask () 12 | 13 | @property (nonatomic, readonly, strong) id commandBuffer; 14 | 15 | @end 16 | 17 | @implementation MTIRenderTask 18 | 19 | - (instancetype)initWithCommandBuffer:(id)commandBuffer { 20 | if (self = [super init]) { 21 | _commandBuffer = commandBuffer; 22 | } 23 | return self; 24 | } 25 | 26 | - (NSError *)error { 27 | return _commandBuffer.error; 28 | } 29 | 30 | - (void)waitUntilCompleted { 31 | [_commandBuffer waitUntilCompleted]; 32 | } 33 | 34 | - (MTLCommandBufferStatus)commandBufferStatus { 35 | return _commandBuffer.status; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTISamplerDescriptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTISamplerDescriptor.h 3 | // Pods 4 | // 5 | // Created by YuAo on 29/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /// An immutable wrapper for MTLSamplerDescriptor. 14 | __attribute__((objc_subclassing_restricted)) 15 | @interface MTISamplerDescriptor : NSObject 16 | 17 | - (instancetype)init NS_UNAVAILABLE; 18 | 19 | + (instancetype)new NS_UNAVAILABLE; 20 | 21 | - (instancetype)initWithMTLSamplerDescriptor:(MTLSamplerDescriptor *)samplerDescriptor NS_DESIGNATED_INITIALIZER; 22 | 23 | - (MTLSamplerDescriptor *)newMTLSamplerDescriptor NS_SWIFT_NAME(makeMTLSamplerDescriptor()); 24 | 25 | @property (nonatomic, readonly, class) MTISamplerDescriptor *defaultSamplerDescriptor; 26 | 27 | + (instancetype)defaultSamplerDescriptorWithAddressMode:(MTLSamplerAddressMode)addressMode; 28 | 29 | @end 30 | 31 | @interface MTLSamplerDescriptor (MTISamplerDescriptor) 32 | 33 | - (MTISamplerDescriptor *)newMTISamplerDescriptor NS_SWIFT_NAME(makeMTISamplerDescriptor()); 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITextureDimensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTITextureDimensions.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 11/10/2017. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | struct MTITextureDimensions { 13 | NSUInteger width; 14 | NSUInteger height; 15 | NSUInteger depth; 16 | }; 17 | typedef struct MTITextureDimensions MTITextureDimensions; 18 | 19 | NS_INLINE NS_SWIFT_NAME(MTITextureDimensions.init(cgSize:)) MTITextureDimensions MTITextureDimensionsMake2DFromCGSize(CGSize size) { 20 | return (MTITextureDimensions){.width = (NSUInteger)size.width, .height = (NSUInteger)size.height, .depth = 1}; 21 | } 22 | 23 | NS_INLINE NS_SWIFT_NAME(MTITextureDimensions.isEqual(self:to:)) BOOL MTITextureDimensionsEqualToTextureDimensions(MTITextureDimensions a, MTITextureDimensions b) { 24 | return a.width == b.width && a.height == b.height && a.depth == b.depth; 25 | } 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITextureDimensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTITextureDimensions.swift 3 | // Pods 4 | // 5 | // Created by Yu Ao on 11/10/2017. 6 | // 7 | 8 | #if SWIFT_PACKAGE 9 | import MetalPetalObjectiveC.Core 10 | #endif 11 | 12 | extension MTITextureDimensions : Equatable { 13 | public static func == (lhs: MTITextureDimensions, rhs: MTITextureDimensions) -> Bool { 14 | return lhs.isEqual(to: rhs) 15 | } 16 | 17 | public init(width: Int, height: Int, depth: Int = 1) { 18 | self.init(width: UInt(width), height: UInt(height), depth: UInt(depth)) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITransform.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTITransform.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 28/10/2017. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | FOUNDATION_EXPORT simd_float4x4 MTIMakeOrthographicMatrix(float left, float right, float top, float bottom, float near, float far); 13 | 14 | FOUNDATION_EXPORT simd_float4x4 MTIMakePerspectiveMatrix(float left, float right, float top, float bottom, float near, float far); 15 | 16 | FOUNDATION_EXPORT simd_float4x4 MTIMakeTransformMatrixFromCATransform3D(CATransform3D transform); 17 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIVector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIVector.swift 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/7/2. 6 | // 7 | 8 | import Foundation 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | extension MTIVector { 15 | 16 | public convenience init(values: [Float]) { 17 | self.init(floatValues: values, count: UInt(values.count)) 18 | } 19 | 20 | public convenience init(values: [Int32]) { 21 | self.init(intValues: values, count: UInt(values.count)) 22 | } 23 | 24 | public convenience init(values: [UInt32]) { 25 | self.init(uintValues: values, count: UInt(values.count)) 26 | } 27 | 28 | public convenience init(values: [Int16]) { 29 | self.init(shortValues: values, count: UInt(values.count)) 30 | } 31 | 32 | public convenience init(values: [UInt16]) { 33 | self.init(ushortValues: values, count: UInt(values.count)) 34 | } 35 | 36 | public convenience init(values: [Int8]) { 37 | self.init(charValues: values, count: UInt(values.count)) 38 | } 39 | 40 | public convenience init(values: [UInt8]) { 41 | self.init(ucharValues: values, count: UInt(values.count)) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIWeakToStrongObjectsMapTable.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIWeakToStrongMapTable.h 3 | // Pods 4 | // 5 | // Created by YuAo on 16/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /// Behaves like NSMapTable with key options: NSMapTableObjectPointerPersonality|NSMapTableWeakMemory, value options: NSMapTableStrongMemory. Entries are purged right away when the weak key is reclaimed. 14 | 15 | __attribute__((objc_subclassing_restricted)) 16 | @interface MTIWeakToStrongObjectsMapTable : NSObject 17 | 18 | - (nullable ObjectType)objectForKey:(KeyType)aKey; 19 | 20 | - (void)removeObjectForKey:(KeyType)aKey; 21 | 22 | - (void)setObject:(nullable ObjectType)anObject forKey:(KeyType)aKey; 23 | 24 | - (void)removeAllObjects; 25 | 26 | - (void)compact; 27 | 28 | @end 29 | 30 | NS_ASSUME_NONNULL_END 31 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MetalPetal.modulemap: -------------------------------------------------------------------------------- 1 | framework module MetalPetal { 2 | umbrella header "MetalPetal.h" 3 | 4 | export * 5 | module * { export * } 6 | 7 | explicit module Extension { 8 | header "MTIContext+Internal.h" 9 | header "MTIImage+Promise.h" 10 | export * 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MetalPetal.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Export.swift 3 | // MetalPetal 4 | // 5 | // Created by YuAo on 2020/3/17. 6 | // 7 | 8 | #if SWIFT_PACKAGE 9 | @_exported import MetalPetalObjectiveC.Core 10 | #endif 11 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/UI/MTIImageViewProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImageViewProtocol.swift 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/7/5. 6 | // 7 | 8 | import Metal 9 | 10 | #if SWIFT_PACKAGE 11 | import MetalPetalObjectiveC.Core 12 | #endif 13 | 14 | public protocol MTIImageViewProtocol: AnyObject { 15 | 16 | var automaticallyCreatesContext: Bool { get set } 17 | 18 | var colorPixelFormat: MTLPixelFormat { get set } 19 | 20 | var clearColor: MTLClearColor { get set } 21 | 22 | var resizingMode: MTIDrawableRenderingResizingMode { get set } 23 | 24 | var context: MTIContext? { get set } 25 | 26 | var image: MTIImage? { get set } 27 | } 28 | 29 | extension MTIImageViewProtocol { 30 | public var inputPort: Port> { 31 | return Port(self, \.image) 32 | } 33 | } 34 | 35 | #if canImport(UIKit) 36 | 37 | extension MTIImageView: MTIImageViewProtocol { 38 | 39 | } 40 | 41 | extension MTIThreadSafeImageView: MTIImageViewProtocol { 42 | 43 | } 44 | 45 | extension MTIImageView: InputPortProvider { 46 | 47 | } 48 | 49 | extension MTIThreadSafeImageView: InputPortProvider { 50 | 51 | } 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /Pods/MetalPetal/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Yu Ao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MTTransitions/MTTransitions-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | ${PODS_DEVELOPMENT_LANGUAGE} 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.6.6 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MTTransitions/MTTransitions-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MTTransitions : NSObject 3 | @end 4 | @implementation PodsDummy_MTTransitions 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MTTransitions/MTTransitions-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MTTransitions/MTTransitions-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "MTTransitionLib.h" 14 | 15 | FOUNDATION_EXPORT double MTTransitionsVersionNumber; 16 | FOUNDATION_EXPORT const unsigned char MTTransitionsVersionString[]; 17 | 18 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MTTransitions/MTTransitions.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MTTransitions 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LIBRARY_SEARCH_PATHS = $(inherited) "${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift 6 | MTL_HEADER_SEARCH_PATHS = ${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal/MetalPetal.framework/Headers 7 | OTHER_LDFLAGS = $(inherited) -framework "MetalPetal" -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 8 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} 12 | PODS_ROOT = ${SRCROOT} 13 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/.. 14 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 15 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 16 | SKIP_INSTALL = YES 17 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 18 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MTTransitions/MTTransitions.modulemap: -------------------------------------------------------------------------------- 1 | framework module MTTransitions { 2 | umbrella header "MTTransitions-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MTTransitions/MTTransitions.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MTTransitions 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LIBRARY_SEARCH_PATHS = $(inherited) "${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift 6 | MTL_HEADER_SEARCH_PATHS = ${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal/MetalPetal.framework/Headers 7 | OTHER_LDFLAGS = $(inherited) -framework "MetalPetal" -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 8 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} 12 | PODS_ROOT = ${SRCROOT} 13 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/.. 14 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 15 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 16 | SKIP_INSTALL = YES 17 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 18 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MTTransitions/MTTransitions.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MTTransitions 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | MTL_HEADER_SEARCH_PATHS = ${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal/MetalPetal.framework/Headers 5 | OTHER_LDFLAGS = $(inherited) -framework "MetalPetal" -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 6 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 7 | PODS_BUILD_DIR = ${BUILD_DIR} 8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_ROOT = ${SRCROOT} 10 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/.. 11 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 12 | SKIP_INSTALL = YES 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal/MetalPetal-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | ${PODS_DEVELOPMENT_LANGUAGE} 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.23.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal/MetalPetal-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MetalPetal : NSObject 3 | @end 4 | @implementation PodsDummy_MetalPetal 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal/MetalPetal-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal/MetalPetal.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_CXX_LANGUAGE_STANDARD = c++14 2 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 3 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LIBRARY_SEARCH_PATHS = $(inherited) "${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift 6 | OTHER_LDFLAGS = $(inherited) -l"c++" -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} 11 | PODS_ROOT = ${SRCROOT} 12 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MetalPetal 13 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 14 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 15 | SKIP_INSTALL = YES 16 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal/MetalPetal.modulemap: -------------------------------------------------------------------------------- 1 | framework module MetalPetal { 2 | umbrella header "MetalPetal.h" 3 | 4 | export * 5 | module * { export * } 6 | 7 | explicit module Extension { 8 | header "MTIContext+Internal.h" 9 | header "MTIImage+Promise.h" 10 | export * 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal/MetalPetal.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_CXX_LANGUAGE_STANDARD = c++14 2 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 3 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LIBRARY_SEARCH_PATHS = $(inherited) "${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift 6 | OTHER_LDFLAGS = $(inherited) -l"c++" -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} 11 | PODS_ROOT = ${SRCROOT} 12 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MetalPetal 13 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 14 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 15 | SKIP_INSTALL = YES 16 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal/MetalPetal.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_LDFLAGS = $(inherited) -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MetalPetal 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | ${PODS_DEVELOPMENT_LANGUAGE} 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_MTTransitionsDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_MTTransitionsDemo 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo-frameworks-Debug-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/MTTransitions/MTTransitions.framework 3 | ${BUILT_PRODUCTS_DIR}/MetalPetal/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo-frameworks-Debug-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTTransitions.framework 2 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo-frameworks-Release-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/MTTransitions/MTTransitions.framework 3 | ${BUILT_PRODUCTS_DIR}/MetalPetal/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo-frameworks-Release-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTTransitions.framework 2 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_MTTransitionsDemoVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_MTTransitionsDemoVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-MTTransitionsDemo/Pods-MTTransitionsDemo.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_MTTransitionsDemo { 2 | umbrella header "Pods-MTTransitionsDemo-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Source/Assets.bundle/bilinear-lateral.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/bilinear-lateral.png -------------------------------------------------------------------------------- /Source/Assets.bundle/conical-asym.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/conical-asym.png -------------------------------------------------------------------------------- /Source/Assets.bundle/conical-sym.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/conical-sym.png -------------------------------------------------------------------------------- /Source/Assets.bundle/displacementMap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/displacementMap.jpg -------------------------------------------------------------------------------- /Source/Assets.bundle/en.lproj/Root.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/en.lproj/Root.strings -------------------------------------------------------------------------------- /Source/Assets.bundle/linear-sawtooth-lateral-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/linear-sawtooth-lateral-4.png -------------------------------------------------------------------------------- /Source/Assets.bundle/radial-tri-lateral-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/radial-tri-lateral-4.png -------------------------------------------------------------------------------- /Source/Assets.bundle/spiral-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/spiral-1.png -------------------------------------------------------------------------------- /Source/Assets.bundle/spiral-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/spiral-2.png -------------------------------------------------------------------------------- /Source/Assets.bundle/spiral-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/spiral-3.png -------------------------------------------------------------------------------- /Source/Assets.bundle/square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexiscn/MTTransitions/66531b19368f8cd49d55e892db6f273d3fea4205/Source/Assets.bundle/square.png -------------------------------------------------------------------------------- /Source/CALayer+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CALayer+Extensions.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2020/3/22. 6 | // 7 | 8 | import UIKit 9 | 10 | extension CALayer { 11 | var snapshot: UIImage? { 12 | get { 13 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.isOpaque, UIScreen.main.scale) 14 | guard let ctx = UIGraphicsGetCurrentContext() else { return nil } 15 | self.render(in: ctx) 16 | let result = UIGraphicsGetImageFromCurrentImageContext() 17 | UIGraphicsEndImageContext() 18 | return result 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTAngularTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTAngularTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTAngularTransition: MTTransition { 9 | 10 | public var startingAngle: Float = 90 11 | 12 | override var fragmentName: String { 13 | return "AngularFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "startingAngle": startingAngle 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTBookFlipTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTBookFlipTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2022/7/8. 6 | // 7 | 8 | import Foundation 9 | 10 | class MTBookFlipTransition: MTTransition { 11 | 12 | override var fragmentName: String { 13 | return "BookFlipFragment" 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Source/Transitions/MTBounceTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTBounceTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTBounceTransition: MTTransition { 11 | 12 | public var bounces: Float = 3 13 | 14 | public var shadowColour: MTIColor = MTIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.6) 15 | 16 | public var shadowHeight: Float = 0.075 17 | 18 | override var fragmentName: String { 19 | return "BounceFragment" 20 | } 21 | 22 | override var parameters: [String: Any] { 23 | return [ 24 | "bounces": bounces, 25 | "shadowColour": MTIVector(value: shadowColour.toFloat4()), 26 | "shadowHeight": shadowHeight 27 | ] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Transitions/MTBowTieHorizontalTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTBowTieHorizontalTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTBowTieHorizontalTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "BowTieHorizontalFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTBowTieVerticalTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTBowTieVerticalTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTBowTieVerticalTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "BowTieVerticalFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTBurnTransition.metal: -------------------------------------------------------------------------------- 1 | // License: MIT 2 | // Author: gre 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 BurnFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float3 & color [[ buffer(0) ]], 14 | constant float & ratio [[ buffer(1) ]], 15 | constant float & progress [[ buffer(2) ]], 16 | sampler textureSampler [[ sampler(0) ]]) 17 | { 18 | float2 uv = vertexIn.textureCoordinate; 19 | uv.y = 1.0 - uv.y; 20 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 21 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 22 | 23 | return mix(getFromColor(uv, fromTexture, ratio, _fromR) + float4(progress*color, 1.0), 24 | getToColor(uv, toTexture, ratio, _toR) + float4((1.0-progress)*color, 1.0), 25 | progress 26 | ); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Source/Transitions/MTBurnTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTBurnTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTBurnTransition: MTTransition { 11 | 12 | public var color: MTIColor = MTIColor(red: 0.9, green: 0.4, blue: 0.2, alpha: 1.0) 13 | 14 | override var fragmentName: String { 15 | return "BurnFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "color": MTIVector(value: simd_float3(color.red, color.green, color.blue)) 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Transitions/MTButterflyWaveScrawlerTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTButterflyWaveScrawlerTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTButterflyWaveScrawlerTransition: MTTransition { 9 | 10 | public var colorSeparation: Float = 0.3 11 | 12 | public var amplitude: Float = 1 13 | 14 | public var waves: Float = 30 15 | 16 | override var fragmentName: String { 17 | return "ButterflyWaveScrawlerFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "colorSeparation": colorSeparation, 23 | "amplitude": amplitude, 24 | "waves": waves 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTCannabisleafTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCannabisleafTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTCannabisleafTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "CannabisleafFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTCircleCropTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCircleCropTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTCircleCropTransition: MTTransition { 11 | 12 | public var bgcolor: MTIColor = MTIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0) 13 | 14 | override var fragmentName: String { 15 | return "CircleCropFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "bgcolor": MTIVector(value: bgcolor.toFloat4()) 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Transitions/MTCircleOpenTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCircleOpenTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTCircleOpenTransition: MTTransition { 9 | 10 | public var smoothness: Float = 0.3 11 | 12 | public var opening: Bool = true 13 | 14 | override var fragmentName: String { 15 | return "CircleOpenFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "smoothness": smoothness, 21 | "opening": opening 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Transitions/MTCircleTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCircleTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | import MetalPetal 11 | 12 | public class MTCircleTransition: MTTransition { 13 | 14 | public var center: CGPoint = CGPoint(x: 0.5, y: 0.5) 15 | 16 | public var backColor: MTIColor = MTIColor(red: 0.1, green: 0.1, blue: 0.1, alpha: 1.0) 17 | 18 | override var fragmentName: String { 19 | return "CircleFragment" 20 | } 21 | 22 | override var parameters: [String: Any] { 23 | return [ 24 | "center": MTIVector(value: center), 25 | "backColor": MTIVector(value: simd_float3(backColor.red, backColor.green, backColor.blue)) 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Transitions/MTColorPhaseTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: gre 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 ColorPhaseFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float4 & fromStep [[ buffer(0) ]], 14 | constant float4 & toStep [[ buffer(1) ]], 15 | constant float & ratio [[ buffer(2) ]], 16 | constant float & progress [[ buffer(3) ]], 17 | sampler textureSampler [[ sampler(0) ]]) 18 | { 19 | float2 uv = vertexIn.textureCoordinate; 20 | uv.y = 1.0 - uv.y; 21 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 22 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 23 | 24 | float4 a = getFromColor(uv, fromTexture, ratio, _fromR); 25 | float4 b = getFromColor(uv, toTexture, ratio, _toR); 26 | return mix(a, b, smoothstep(fromStep, toStep, float4(progress))); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Source/Transitions/MTColorPhaseTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTColorPhaseTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTColorPhaseTransition: MTTransition { 11 | 12 | // Usage: fromStep and toStep must be in [0.0, 1.0] range 13 | // and all(fromStep) must be < all(toStep) 14 | public var fromStep: MTIColor = MTIColor(red: 0.0, green: 0.2, blue: 0.4, alpha: 0.0) 15 | 16 | public var toStep: MTIColor = MTIColor(red: 0.6, green: 0.8, blue: 1.0, alpha: 1.0) 17 | 18 | override var fragmentName: String { 19 | return "ColorPhaseFragment" 20 | } 21 | 22 | override var parameters: [String: Any] { 23 | return [ 24 | "fromStep": MTIVector(value: fromStep.toFloat4()), 25 | "toStep": MTIVector(value: toStep.toFloat4()) 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Transitions/MTColourDistanceTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTColourDistanceTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTColourDistanceTransition: MTTransition { 9 | 10 | public var power: Float = 5 11 | 12 | override var fragmentName: String { 13 | return "ColourDistanceFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "power": power 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTCoordFromInTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: haiyoucuv 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 CoordFromInFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & ratio [[ buffer(0) ]], 14 | constant float & progress [[ buffer(1) ]], 15 | sampler textureSampler [[ sampler(0) ]]) 16 | { 17 | float2 uv = vertexIn.textureCoordinate; 18 | uv.y = 1.0 - uv.y; 19 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 20 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 21 | 22 | float4 coordTo = getToColor(uv, toTexture, ratio, _toR); 23 | //float4 coordFrom = getFromColor(uv, fromTexture, ratio, _fromR); 24 | 25 | float4 a = getFromColor(coordTo.rg, fromTexture, ratio, _fromR); 26 | float4 b = getToColor(uv, toTexture, ratio, _toR); 27 | 28 | return mix(a, b, progress); 29 | } 30 | -------------------------------------------------------------------------------- /Source/Transitions/MTCoordFromInTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCoordFromInTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexis on 2022/4/9. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTCoordFromInTransition: MTTransition { 11 | 12 | override var fragmentName: String { 13 | return "CoordFromInFragment" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Transitions/MTCrazyParametricFunTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCrazyParametricFunTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTCrazyParametricFunTransition: MTTransition { 9 | 10 | public var a: Float = 4 11 | 12 | public var b: Float = 1 13 | 14 | public var smoothness: Float = 0.1 15 | 16 | public var amplitude: Float = 120 17 | 18 | override var fragmentName: String { 19 | return "CrazyParametricFunFragment" 20 | } 21 | 22 | override var parameters: [String: Any] { 23 | return [ 24 | "a": a, 25 | "b": b, 26 | "smoothness": smoothness, 27 | "amplitude": amplitude 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/Transitions/MTCrossHatchTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCrossHatchTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | import MetalPetal 8 | 9 | public class MTCrossHatchTransition: MTTransition { 10 | 11 | public var threshold: Float = 3 12 | 13 | public var center: CGPoint = CGPoint(x: 0.5, y: 0.5) 14 | 15 | public var fadeEdge: Float = 0.1 16 | 17 | override var fragmentName: String { 18 | return "CrossHatchFragment" 19 | } 20 | 21 | override var parameters: [String: Any] { 22 | return [ 23 | "threshold": threshold, 24 | "center": MTIVector(value: center), 25 | "fadeEdge": fadeEdge 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Transitions/MTCrossWarpTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: Eke Péter 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 CrossWarpFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & ratio [[ buffer(0) ]], 14 | constant float & progress [[ buffer(1) ]], 15 | sampler textureSampler [[ sampler(0) ]]) 16 | { 17 | float2 uv = vertexIn.textureCoordinate; 18 | uv.y = 1.0 - uv.y; 19 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 20 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 21 | 22 | float x = progress; 23 | x = smoothstep(.0,1.0,(x * 2.0 + uv.x - 1.0)); 24 | return mix(getFromColor((uv - 0.5) * (1.0 - x) + 0.5, fromTexture, ratio, _fromR), 25 | getToColor((uv - 0.5) * x + 0.5, toTexture, ratio, _toR), 26 | x); 27 | } 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTCrossWarpTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCrossWarpTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTCrossWarpTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "CrossWarpFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTCrossZoomTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCrossZoomTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTCrossZoomTransition: MTTransition { 9 | 10 | public var strength: Float = 0.4 11 | 12 | override var fragmentName: String { 13 | return "CrossZoomFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "strength": strength 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTCubeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTCubeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTCubeTransition: MTTransition { 9 | 10 | public var persp: Float = 0.7 11 | 12 | public var unzoom: Float = 0.3 13 | 14 | public var reflection: Float = 0.4 15 | 16 | public var floating: Float = 3 17 | 18 | override var fragmentName: String { 19 | return "CubeFragment" 20 | } 21 | 22 | override var parameters: [String: Any] { 23 | return [ 24 | "persp": persp, 25 | "unzoom": unzoom, 26 | "reflection": reflection, 27 | "floating": floating 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/Transitions/MTDirectionalEasingTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDirectionalEasingTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2021/2/22. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTDirectionalEasingTransition: MTTransition { 11 | 12 | public var direction: CGPoint = CGPoint(x: 0.0, y: 1.0) 13 | 14 | override var fragmentName: String { 15 | return "DirectionalEasingFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "direction": MTIVector(value: direction) 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Transitions/MTDirectionalTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: Gaëtan Renaudeau 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 DirectionalFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float2 & direction [[ buffer(0) ]], 14 | constant float & ratio [[ buffer(1) ]], 15 | constant float & progress [[ buffer(2) ]], 16 | sampler textureSampler [[ sampler(0) ]]) 17 | { 18 | float2 uv = vertexIn.textureCoordinate; 19 | uv.y = 1.0 - uv.y; 20 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 21 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 22 | 23 | float2 p = uv + progress * sign(direction); 24 | float2 f = fract(p); 25 | return mix(getToColor(f, toTexture, ratio, _toR), 26 | getFromColor(f, fromTexture, ratio, _fromR), 27 | step(0.0, p.y) * step(p.y, 1.0) * step(0.0, p.x) * step(p.x, 1.0)); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Source/Transitions/MTDirectionalTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDirectionalTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTDirectionalTransition: MTTransition { 11 | 12 | public var direction: CGPoint = CGPoint(x: 0, y: 1.0) 13 | 14 | override var fragmentName: String { 15 | return "DirectionalFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "direction": MTIVector(value: direction) 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Transitions/MTDirectionalWarpTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDirectionalWarpTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTDirectionalWarpTransition: MTTransition { 11 | 12 | public var direction: CGPoint = CGPoint(x: -1.0, y: 1.0) 13 | 14 | override var fragmentName: String { 15 | return "DirectionalWarpFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "direction": MTIVector(value: direction) 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Transitions/MTDirectionalWipeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDirectionalwipeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTDirectionalWipeTransition: MTTransition { 11 | 12 | public var direction: CGPoint = CGPoint(x: 1.0, y: -1.0) 13 | 14 | public var smoothness: Float = 0.5 15 | 16 | override var fragmentName: String { 17 | return "DirectionalWipeFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "direction": MTIVector(value: direction), 23 | "smoothness": smoothness 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Transitions/MTDisplacementTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDisplacementTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | // TODO: displacementMap should be parameter 9 | public class MTDisplacementTransition: MTTransition { 10 | 11 | public var strength: Float = 0.5 12 | 13 | override var fragmentName: String { 14 | return "DisplacementFragment" 15 | } 16 | 17 | override var parameters: [String: Any] { 18 | return [ 19 | "strength": strength, 20 | ] 21 | } 22 | 23 | override var samplers: [String : String] { 24 | return [ 25 | "displacementMap": "displacementMap.jpg" 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Transitions/MTDissolveTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDissolveTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2023/10/26. 6 | // 7 | 8 | import Foundation 9 | import simd 10 | 11 | public class MTDissolveTransition: MTTransition { 12 | 13 | public var uLineWidth: Float = 0.1 14 | 15 | public var uSpreadClr: SIMD3 = SIMD3(1.0, 0.0, 0.0) 16 | 17 | public var uHotClr: SIMD3 = SIMD3(0.9, 0.9, 0.2) 18 | 19 | public var uPow: Float = 5.0 20 | 21 | public var uIntensity: Float = 1.0 22 | 23 | override var fragmentName: String { 24 | return "DissolveFragment" 25 | } 26 | 27 | override var parameters: [String : Any] { 28 | return [ 29 | "uLineWidth": uLineWidth, 30 | "uSpreadClr": uSpreadClr, 31 | "uHotClr": uHotClr, 32 | "uPow": uPow, 33 | "uIntensity": uIntensity 34 | ] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Transitions/MTDoomScreenTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDoomScreenTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTDoomScreenTransition: MTTransition { 9 | 10 | // How much the bars seem to "run" from the middle of the screen first (sticking to the sides). 0 = no drip, 1 = curved drip 11 | public var dripScale: Float = 0.5 12 | 13 | // Number of total bars/columns 14 | public var bars: Int = 30 15 | 16 | // Further variations in speed. 0 = no noise, 1 = super noisy (ignore frequency) 17 | public var noise: Float = 0.1 18 | 19 | // Speed variation horizontally. the bigger the value, the shorter the waves 20 | public var frequency: Float = 0.5 21 | 22 | // Multiplier for speed ratio. 0 = no variation when going down, higher = some elements go much faster 23 | public var amplitude: Float = 2 24 | 25 | override var fragmentName: String { 26 | return "DoomScreenFragment" 27 | } 28 | 29 | override var parameters: [String: Any] { 30 | return [ 31 | "dripScale": dripScale, 32 | "bars": Int32(bars), 33 | "noise": noise, 34 | "frequency": frequency, 35 | "amplitude": amplitude 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Transitions/MTDoorwayTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDoorwayTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTDoorwayTransition: MTTransition { 9 | 10 | public var depth: Float = 3 11 | 12 | public var reflection: Float = 0.4 13 | 14 | public var perspective: Float = 0.4 15 | 16 | override var fragmentName: String { 17 | return "DoorwayFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "depth": depth, 23 | "reflection": reflection, 24 | "perspective": perspective 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTDreamyTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: mikolalysenko 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | float2 offset(float progress, float x, float theta) { 11 | //float phase = progress * progress + progress + theta; 12 | float shifty = 0.03 * progress * cos(10.0*(progress + x)); 13 | return float2(0, shifty); 14 | } 15 | 16 | fragment float4 DreamyFragment(VertexOut vertexIn [[ stage_in ]], 17 | texture2d fromTexture [[ texture(0) ]], 18 | texture2d toTexture [[ texture(1) ]], 19 | constant float & ratio [[ buffer(0) ]], 20 | constant float & progress [[ buffer(1) ]], 21 | sampler textureSampler [[ sampler(0) ]]) 22 | { 23 | float2 uv = vertexIn.textureCoordinate; 24 | uv.y = 1.0 - uv.y; 25 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 26 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 27 | 28 | return mix(getFromColor(uv + offset(progress, uv.x, 0.0), fromTexture, ratio, _fromR), 29 | getToColor(uv + offset(1.0-progress, uv.x, 3.14), toTexture, ratio, _toR), 30 | progress); 31 | } 32 | -------------------------------------------------------------------------------- /Source/Transitions/MTDreamyTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDreamyTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTDreamyTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "DreamyFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTDreamyZoomTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTDreamyZoomTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTDreamyZoomTransition: MTTransition { 9 | 10 | public var rotation: Float = 6 11 | 12 | public var scale: Float = 1.2 13 | 14 | override var fragmentName: String { 15 | return "DreamyZoomFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "rotation": rotation, 21 | "scale": scale 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Transitions/MTFadeColorTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTFadeColorTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTFadeColorTransition: MTTransition { 11 | 12 | public var color: MTIColor = MTIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0) 13 | 14 | /// if 0.0, there is no black phase, if 0.9, the black phase is very important 15 | public var colorPhase: Float = 0.4 16 | 17 | override var fragmentName: String { 18 | return "FadeColorFragment" 19 | } 20 | 21 | override var parameters: [String: Any] { 22 | return [ 23 | "color": MTIVector(value: simd_float3(color.red, color.green, color.blue)), 24 | "colorPhase": colorPhase 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTFadeInWipeLeftTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTFadeInWipeLeftTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by Nazmul on 04/08/2022. 6 | // 7 | 8 | import Foundation 9 | 10 | import Foundation 11 | //MTFadeInTranslationTransitionTranslationTransition.swift 12 | public class MTFadeInWipeLeftTransition: MTTransition { 13 | 14 | override var fragmentName: String { 15 | return "FadeInWipeLeftFragment" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Transitions/MTFadeInWipeUpTransition.metal: -------------------------------------------------------------------------------- 1 | // 2 | // MTFadeInWipeUpTransition.metal 3 | // MTTransitions 4 | // 5 | // Created by Nazmul on 04/08/2022. 6 | // 7 | 8 | #include 9 | #include "MTIShaderLib.h" 10 | #include "MTTransitionLib.h" 11 | 12 | using namespace metalpetal; 13 | 14 | fragment float4 FadeInWipeUpFragment(VertexOut vertexIn [[ stage_in ]], 15 | texture2d fromTexture [[ texture(0) ]], 16 | texture2d toTexture [[ texture(1) ]], 17 | constant float & ratio [[ buffer(0) ]], 18 | constant float & progress [[ buffer(1) ]], 19 | 20 | sampler textureSampler [[ sampler(0) ]]) 21 | { 22 | float2 uv = vertexIn.textureCoordinate; 23 | uv.y = 1.0 - uv.y; 24 | float2 _uv = uv; 25 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 26 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 27 | 28 | _uv.y -= progress; 29 | 30 | if(uv.y >= progress) 31 | { 32 | return getFromColor(_uv, fromTexture, ratio, _fromR); 33 | } 34 | 35 | float4 a = getFromColor(uv, fromTexture, ratio, _fromR); 36 | float4 b = getToColor(uv, toTexture, ratio, _toR); 37 | return mix(a, b, progress); 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /Source/Transitions/MTFadeInWipeUpTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTYAxisTranslationTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by Nazmul on 04/08/2022. 6 | // 7 | 8 | import Foundation 9 | //MTFadeInTranslationTransitionTranslationTransition.swift 10 | public class MTFadeInWipeUpTransition: MTTransition { 11 | 12 | override var fragmentName: String { 13 | return "FadeInWipeUpFragment" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Transitions/MTFadeTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: gre 2 | // license: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 FadeFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & ratio [[ buffer(0) ]], 14 | constant float & progress [[ buffer(1) ]], 15 | sampler textureSampler [[ sampler(0) ]]) 16 | { 17 | float2 uv = vertexIn.textureCoordinate; 18 | uv.y = 1.0 - uv.y; 19 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 20 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 21 | 22 | float4 a = getFromColor(uv, fromTexture, ratio, _fromR); 23 | float4 b = getToColor(uv, toTexture, ratio, _toR); 24 | return mix(a, b, progress); 25 | } 26 | -------------------------------------------------------------------------------- /Source/Transitions/MTFadeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTFadeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTFadeTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "FadeFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTFadegrayscaleTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTFadegrayscaleTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTFadegrayscaleTransition: MTTransition { 9 | 10 | public var intensity: Float = 0.3 11 | 12 | override var fragmentName: String { 13 | return "FadegrayscaleFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "intensity": intensity 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTFlyeyeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTFlyeyeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTFlyeyeTransition: MTTransition { 9 | 10 | public var colorSeparation: Float = 0.3 11 | 12 | public var zoom: Float = 50 13 | 14 | public var size: Float = 0.04 15 | 16 | override var fragmentName: String { 17 | return "FlyeyeFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "colorSeparation": colorSeparation, 23 | "zoom": zoom, 24 | "size": size 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTGlitchDisplaceTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTGlitchDisplaceTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTGlitchDisplaceTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "GlitchDisplaceFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTGlitchMemoriesTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTGlitchMemoriesTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTGlitchMemoriesTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "GlitchMemoriesFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTGridFlipTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTGridFlipTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | import simd 10 | 11 | public class MTGridFlipTransition: MTTransition { 12 | 13 | public var bgcolor: MTIColor = MTIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0) 14 | 15 | public var randomness: Float = 0.1 16 | 17 | public var pause: Float = 0.1 18 | 19 | public var dividerWidth: Float = 0.05 20 | 21 | //public var size: int2 = int2(4, 4) 22 | public var size: SIMD2 = SIMD2(4, 4) 23 | 24 | override var fragmentName: String { 25 | return "GridFlipFragment" 26 | } 27 | 28 | override var parameters: [String: Any] { 29 | return [ 30 | "bgcolor": MTIVector(value: bgcolor.toFloat4()), 31 | "randomness": randomness, 32 | "pause": pause, 33 | "dividerWidth": dividerWidth, 34 | "size": MTIVector(value: size) 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Transitions/MTHeartTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: gre 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | float inHeart(float2 p, float2 center, float size) { 11 | if (size == 0.0) { 12 | return 0.0; 13 | } 14 | float2 o = (p-center)/(1.6*size); 15 | float a = o.x*o.x+o.y*o.y-0.3; 16 | return step(a*a*a, o.x*o.x*o.y*o.y*o.y); 17 | } 18 | 19 | fragment float4 HeartFragment(VertexOut vertexIn [[ stage_in ]], 20 | texture2d fromTexture [[ texture(0) ]], 21 | texture2d toTexture [[ texture(1) ]], 22 | constant float & ratio [[ buffer(0) ]], 23 | constant float & progress [[ buffer(1) ]], 24 | sampler textureSampler [[ sampler(0) ]]) 25 | { 26 | float2 uv = vertexIn.textureCoordinate; 27 | uv.y = 1.0 - uv.y; 28 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 29 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 30 | 31 | return mix(getFromColor(uv, fromTexture, ratio, _fromR), 32 | getToColor(uv, toTexture, ratio, _toR), 33 | inHeart(uv, float2(0.5, 0.4), progress) 34 | ); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Source/Transitions/MTHeartTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTHeartTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTHeartTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "HeartFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTHexagonalizeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTHexagonalizeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTHexagonalizeTransition: MTTransition { 9 | 10 | public var steps: Int = 50 11 | 12 | public var horizontalHexagons: Float = 20 13 | 14 | override var fragmentName: String { 15 | return "HexagonalizeFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "steps": Int32(steps), 21 | "horizontalHexagons": horizontalHexagons 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Transitions/MTInvertedPageCurlTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTInvertedPageCurlTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTInvertedPageCurlTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "InvertedPageCurlFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTKaleidoScopeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTKaleidoScopeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTKaleidoScopeTransition: MTTransition { 9 | 10 | public var angle: Float = 1 11 | 12 | public var speed: Float = 1 13 | 14 | public var power: Float = 1.5 15 | 16 | override var fragmentName: String { 17 | return "KaleidoScopeFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "angle": angle, 23 | "speed": speed, 24 | "power": power 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTLeftRightTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTLeftRightTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2021/2/22. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTLeftRightTransition: MTTransition { 11 | 12 | override var fragmentName: String { 13 | return "LeftRightFragment" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Transitions/MTLinearBlurTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTLinearBlurTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTLinearBlurTransition: MTTransition { 9 | 10 | public var intensity: Float = 0.1 11 | 12 | override var fragmentName: String { 13 | return "LinearBlurFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "intensity": intensity 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTLissajousTilesTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTLissajousTilesTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2024/12/12. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTLissajousTilesTransition: MTTransition { 11 | 12 | public var speed: Float = 0.5 13 | public var freq: CGPoint = CGPoint(x: 2.0, y: 3.0) 14 | public var offset: Float = 2.0 15 | public var zoom: Float = 0.8 16 | public var fade: Float = 0.8 17 | 18 | override var fragmentName: String { 19 | return "LissajousTilesFragment" 20 | } 21 | 22 | override var parameters: [String: Any] { 23 | return [ 24 | "speed": speed, 25 | "offset": offset, 26 | "zoom": zoom, 27 | "fade": fade 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/Transitions/MTLumaTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: gre 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 LumaFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | texture2d luma [[ texture(2) ]], 14 | constant float & ratio [[ buffer(0) ]], 15 | constant float & progress [[ buffer(1) ]], 16 | sampler textureSampler [[ sampler(0) ]]) 17 | { 18 | float2 uv = vertexIn.textureCoordinate; 19 | uv.y = 1.0 - uv.y; 20 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 21 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 22 | 23 | constexpr sampler s(coord::normalized, address::clamp_to_edge, filter::linear); 24 | float r = luma.sample(s, uv).r; 25 | 26 | return mix(getFromColor(uv, toTexture, ratio, _toR), 27 | getToColor(uv, fromTexture, ratio, _fromR), 28 | step(progress, r) 29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /Source/Transitions/MTLumaTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTLumaTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | // TODO 9 | public class MTLumaTransition: MTTransition { 10 | 11 | override var fragmentName: String { 12 | return "LumaFragment" 13 | } 14 | 15 | override var samplers: [String : String] { 16 | return [ 17 | "luma": "spiral-1.png" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Source/Transitions/MTLuminanceMeltTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTLuminance_meltTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTLuminanceMeltTransition: MTTransition { 9 | 10 | /// direction of movement : 0 : up, 1, down 11 | public var direction: Bool = true 12 | 13 | /// does the movement takes effect above or below luminance threshold ? 14 | public var above: Bool = false 15 | 16 | /// luminance threshold 17 | public var l_threshold: Float = 0.8 18 | 19 | override var fragmentName: String { 20 | return "LuminanceMeltFragment" 21 | } 22 | 23 | override var parameters: [String: Any] { 24 | return [ 25 | "direction": direction, 26 | "above": above, 27 | "l_threshold": l_threshold 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/Transitions/MTMorphTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTMorphTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTMorphTransition: MTTransition { 9 | 10 | public var strength: Float = 0.1 11 | 12 | override var fragmentName: String { 13 | return "MorphFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "strength": strength 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTMosaicTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTMosaicTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTMosaicTransition: MTTransition { 9 | 10 | public var endy: Int = -1 11 | 12 | public var endx: Int = 2 13 | 14 | override var fragmentName: String { 15 | return "MosaicFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "endy": Int32(endy), 21 | "endx": Int32(endx) 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Transitions/MTMosaicYueDevTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTMosaicYueDevTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2022/7/8. 6 | // 7 | 8 | import Foundation 9 | 10 | class MTMosaicYueDevTransition: MTTransition { 11 | 12 | public var mosaicNum: Float = 10 13 | 14 | override var fragmentName: String { 15 | return "MosaicYueDevFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ "mosaicNum": mosaicNum ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTMultiplyBlendTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTMultiply_blendTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTMultiplyBlendTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "MultiplyBlendFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTNoneTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTNoneTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2020/3/30. 6 | // 7 | 8 | import Foundation 9 | import MetalPetal 10 | 11 | /// None transition 12 | public class MTNoneTransition: MTTransition { 13 | 14 | public override var outputImage: MTIImage? { 15 | // Just return toImage 16 | return destImage?.oriented(.downMirrored) 17 | } 18 | 19 | public override func transition(from fromImage: MTIImage, to toImage: MTIImage, updater: @escaping MTTransitionUpdater, completion: MTTransitionCompletion?) { 20 | updater(toImage.oriented(.downMirrored)) 21 | DispatchQueue.main.asyncAfter(deadline: .now() + duration) { 22 | completion?(true) 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Source/Transitions/MTOverexposureTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTOverexposureTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexis on 2022/4/9. 6 | // 7 | 8 | 9 | public class MTOverexposureTransition: MTTransition { 10 | 11 | public var strength: Float = 0.6 12 | 13 | override var fragmentName: String { 14 | return "OverexposureFragment" 15 | } 16 | 17 | override var parameters: [String: Any] { 18 | return [ 19 | "strength": strength 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Source/Transitions/MTParametricGlitchTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTParametricGlitchTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2024/12/11. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTParametricGlitchTransition: MTTransition { 11 | 12 | public var ampx: Float = 1.0 13 | 14 | public var ampy: Float = 1.0 15 | 16 | override var fragmentName: String { 17 | return "ParametricGlitchFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "ampx": ampx, 23 | "ampy": ampy 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Transitions/MTPerlinTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTPerlinTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTPerlinTransition: MTTransition { 9 | 10 | public var scale: Float = 4 11 | 12 | public var seed: Float = 12.9898 13 | 14 | public var smoothness: Float = 0.01 15 | 16 | override var fragmentName: String { 17 | return "PerlinFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "scale": scale, 23 | "seed": seed, 24 | "smoothness": smoothness 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTPinwheelTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: Mr Speaker 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 PinwheelFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & speed [[ buffer(0) ]], 14 | constant float & ratio [[ buffer(1) ]], 15 | constant float & progress [[ buffer(2) ]], 16 | sampler textureSampler [[ sampler(0) ]]) 17 | { 18 | float2 uv = vertexIn.textureCoordinate; 19 | uv.y = 1.0 - uv.y; 20 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 21 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 22 | 23 | float2 p = uv.xy / float2(1.0).xy; 24 | 25 | float circPos = atan2(p.y - 0.5, p.x - 0.5) + progress * speed; 26 | float modPos = mod(circPos, 3.1415 / 4.); 27 | float s = sign(progress - modPos); 28 | 29 | return mix(getToColor(p, toTexture, ratio, _toR), 30 | getFromColor(p, fromTexture, ratio, _fromR), 31 | step(s, 0.5)); 32 | } 33 | -------------------------------------------------------------------------------- /Source/Transitions/MTPinwheelTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTPinwheelTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTPinwheelTransition: MTTransition { 9 | 10 | public var speed: Float = 2 11 | 12 | override var fragmentName: String { 13 | return "PinwheelFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "speed": speed 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTPixelizeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTPixelizeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | import simd 10 | 11 | public class MTPixelizeTransition: MTTransition { 12 | 13 | // minimum number of squares (when the effect is at its higher level) 14 | //public var squaresMin: int2 = int2(20, 20) 15 | public var squaresMin: SIMD2 = SIMD2(20, 20) 16 | 17 | // zero disable the stepping 18 | public var steps: Int = 50 19 | 20 | override var fragmentName: String { 21 | return "PixelizeFragment" 22 | } 23 | 24 | override var parameters: [String: Any] { 25 | return [ 26 | "squaresMin": MTIVector(value: squaresMin), 27 | "steps": Int32(steps) 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/Transitions/MTPolarFunctionTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTPolar_functionTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTPolarFunctionTransition: MTTransition { 9 | 10 | public var segments: Int = 5 11 | 12 | override var fragmentName: String { 13 | return "PolarFunctionFragment" 14 | } 15 | 16 | override var parameters: [String : Any] { 17 | return [ 18 | "segments": Int32(segments) 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTPolkaDotsCurtainTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTPolkaDotsCurtainTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTPolkaDotsCurtainTransition: MTTransition { 11 | 12 | public var dots: Float = 20 13 | 14 | public var center: CGPoint = CGPoint(x: 0, y: 0) 15 | 16 | override var fragmentName: String { 17 | return "PolkaDotsCurtainFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "dots": dots, 23 | "center": MTIVector(value: center) 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Transitions/MTPowerKaleidoTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTPowerKaleidoTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexis on 2022/4/5. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTPowerKaleidoTransition: MTTransition { 11 | 12 | public var scale: Float = 2.0 13 | 14 | public var z: Float = 1.5 15 | 16 | public var speed: Float = 5.0 17 | 18 | override var fragmentName: String { 19 | return "PowerKaleidoFragment" 20 | } 21 | 22 | override var parameters: [String: Any] { 23 | return [ 24 | "scale": scale, 25 | "z": z, 26 | "speed": speed 27 | ] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Transitions/MTRadialTransition.metal: -------------------------------------------------------------------------------- 1 | // License: MIT 2 | // Author: Xaychru 3 | // ported by gre from https://gist.github.com/Xaychru/ce1d48f0ce00bb379750 4 | 5 | #include 6 | #include "MTIShaderLib.h" 7 | #include "MTTransitionLib.h" 8 | 9 | using namespace metalpetal; 10 | 11 | fragment float4 RadialFragment(VertexOut vertexIn [[ stage_in ]], 12 | texture2d fromTexture [[ texture(0) ]], 13 | texture2d toTexture [[ texture(1) ]], 14 | constant float & smoothness [[ buffer(0) ]], 15 | constant float & ratio [[ buffer(1) ]], 16 | constant float & progress [[ buffer(2) ]], 17 | sampler textureSampler [[ sampler(0) ]]) 18 | { 19 | float2 uv = vertexIn.textureCoordinate; 20 | uv.y = 1.0 - uv.y; 21 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 22 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 23 | 24 | float2 rp = uv * 2.0 - 1.0; 25 | return mix(getToColor(uv, toTexture, ratio, _toR), 26 | getFromColor(uv, fromTexture, ratio, _fromR), 27 | smoothstep(0.0, smoothness, atan2(rp.y,rp.x) - (progress - 0.5) * PI * 2.5) 28 | ); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Source/Transitions/MTRadialTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTRadialTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTRadialTransition: MTTransition { 9 | 10 | public var smoothness: Float = 1 11 | 12 | override var fragmentName: String { 13 | return "RadialFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "smoothness": smoothness 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTRandomNoisexTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTRandomNoisexTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2021/2/22. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTRandomNoisexTransition: MTTransition { 11 | override var fragmentName: String { 12 | return "MTRandomNoisexFragment" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Transitions/MTRandomSquaresTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTRandomSquaresTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTRandomSquaresTransition: MTTransition { 11 | 12 | public var smoothness: Float = 0.5 13 | 14 | public var size: CGSize = CGSize(width: 10, height: 10) 15 | 16 | override var fragmentName: String { 17 | return "RandomSquaresFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "smoothness": smoothness, 23 | "size": MTIVector(value: size) 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Transitions/MTRippleTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTRippleTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTRippleTransition: MTTransition { 9 | 10 | public var speed: Float = 50 11 | 12 | public var amplitude: Float = 100 13 | 14 | override var fragmentName: String { 15 | return "RippleFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "speed": speed, 21 | "amplitude": amplitude 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Transitions/MTRotateScaleFadeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTRotate_scale_fadeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTRotateScaleFadeTransition: MTTransition { 11 | 12 | public var scale: Float = 8 13 | 14 | public var rotations: Float = 1 15 | 16 | public var center: CGPoint = CGPoint(x: 0.5, y: 0.5) 17 | 18 | public var backColor: MTIColor = MTIColor(red: 0.15, green: 0.15, blue: 0.15, alpha: 1.0) 19 | 20 | override var fragmentName: String { 21 | return "RotateScaleFadeFragment" 22 | } 23 | 24 | override var parameters: [String: Any] { 25 | return [ 26 | "scale": scale, 27 | "rotations": rotations, 28 | "center": MTIVector(value: center), 29 | "backColor": MTIVector(value: backColor.toFloat4()) 30 | ] 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Source/Transitions/MTRotateTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: haiyoucuv 2 | // License: MIT 3 | #include 4 | #include "MTIShaderLib.h" 5 | #include "MTTransitionLib.h" 6 | 7 | using namespace metalpetal; 8 | 9 | float2 rotate2D(float2 uv, float angle){ 10 | 11 | return uv * float2x2(float2(cos(angle), -sin(angle)), 12 | float2(sin(angle), cos(angle))); 13 | } 14 | 15 | fragment float4 RotateFragment(VertexOut vertexIn [[ stage_in ]], 16 | texture2d fromTexture [[ texture(0) ]], 17 | texture2d toTexture [[ texture(1) ]], 18 | constant float & ratio [[ buffer(0) ]], 19 | constant float & progress [[ buffer(1) ]], 20 | sampler textureSampler [[ sampler(0) ]]) 21 | { 22 | float2 uv = vertexIn.textureCoordinate; 23 | uv.y = 1.0 - uv.y; 24 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 25 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 26 | 27 | float2 p = fract(rotate2D(uv - 0.5, progress * PI * 2.0) + 0.5); 28 | float4 a = getFromColor(uv, fromTexture, ratio, _fromR); 29 | float4 b = getToColor(uv, toTexture, ratio, _toR); 30 | return mix(a, b, step(0.0 + p.x, progress)); 31 | } 32 | -------------------------------------------------------------------------------- /Source/Transitions/MTRotateTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTRotateTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2021/6/8. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTRotateTransition: MTTransition { 11 | 12 | override var fragmentName: String { 13 | return "RotateFragment" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Transitions/MTScaleInTransition.metal: -------------------------------------------------------------------------------- 1 | // Author:haiyoucuv 2 | // License: MIT 3 | #include 4 | #include "MTIShaderLib.h" 5 | #include "MTTransitionLib.h" 6 | 7 | using namespace metalpetal; 8 | 9 | fragment float4 ScaleInFragment(VertexOut vertexIn [[ stage_in ]], 10 | texture2d fromTexture [[ texture(0) ]], 11 | texture2d toTexture [[ texture(1) ]], 12 | constant float & ratio [[ buffer(0) ]], 13 | constant float & progress [[ buffer(1) ]], 14 | sampler textureSampler [[ sampler(0) ]]) 15 | { 16 | float2 uv = vertexIn.textureCoordinate; 17 | uv.y = 1.0 - uv.y; 18 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 19 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 20 | 21 | float4 a = getFromColor(uv, fromTexture, ratio, _fromR); 22 | uv = 0.5 + (uv - 0.5) * progress; 23 | float4 b = getToColor(uv, toTexture, ratio, _toR); 24 | return mix(a, b, progress); 25 | } 26 | -------------------------------------------------------------------------------- /Source/Transitions/MTScaleInTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTScaleInTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexis on 2022/4/9. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTScaleInTransition: MTTransition { 11 | 12 | override var fragmentName: String { 13 | return "ScaleInFragment" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Transitions/MTSimpleZoomTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTSimpleZoomTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTSimpleZoomTransition: MTTransition { 9 | 10 | public var zoomQuickness: Float = 0.8 11 | 12 | override var fragmentName: String { 13 | return "SimpleZoomFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "zoomQuickness": zoomQuickness 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTSquaresWireTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTSquaresWireTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTSquaresWireTransition: MTTransition { 11 | 12 | public var direction: CGPoint = CGPoint(x: 1.0, y: -0.5) 13 | 14 | public var squares: SIMD2 = SIMD2(10, 10) 15 | 16 | public var smoothness: Float = 1.6 17 | 18 | override var fragmentName: String { 19 | return "SquaresWireFragment" 20 | } 21 | 22 | override var parameters: [String: Any] { 23 | return [ 24 | "direction": MTIVector(value: direction), 25 | "squares": MTIVector(value: squares), 26 | "smoothness": smoothness 27 | ] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Transitions/MTSqueezeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTSqueezeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTSqueezeTransition: MTTransition { 9 | 10 | public var colorSeparation: Float = 0.04 11 | 12 | override var fragmentName: String { 13 | return "SqueezeFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "colorSeparation": colorSeparation 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTStarWipeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTStarWipeTransition.swift 3 | // Pods 4 | // 5 | // Created by alexiscn on 2024/12/11. 6 | // 7 | 8 | import Foundation 9 | import MetalPetal 10 | 11 | public class MTStarWipeTransition: MTTransition { 12 | 13 | public var boderThickness: Float = 0.01 14 | 15 | public var starRotation: Float = 0.75 16 | 17 | public var borderColor: MTIColor = MTIColor(red: 1, green: 1, blue: 1, alpha: 1.0) 18 | 19 | public var starCenter: CGPoint = CGPoint(x: 0.5, y: 0.5) 20 | 21 | override var fragmentName: String { 22 | return "StarWipeFragment" 23 | } 24 | 25 | override var parameters: [String: Any] { 26 | return [ 27 | "boderThickness": boderThickness, 28 | "starRotation": starRotation, 29 | "borderColor": MTIVector(value: borderColor.toFloat4()), 30 | "starCenter": MTIVector(value: starCenter) 31 | ] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/Transitions/MTStaticFadeTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTStaticFadeTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2023/10/26. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTStaticFadeTransition: MTTransition { 11 | 12 | public var nNoisePixels: Float = 200.0 13 | 14 | public var staticLuminosity: Float = 0.8 15 | 16 | override var fragmentName: String { 17 | return "StaticFadeFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "nNoisePixels": nNoisePixels, 23 | "staticLuminosity": staticLuminosity 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Transitions/MTStereoViewerTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTStereoViewerTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTStereoViewerTransition: MTTransition { 9 | 10 | // Corner radius as a fraction of the image height 11 | public var cornerRadius: Float = 0.22 12 | 13 | // How much to zoom (out) for the effect ~ 0.5 - 1.0 14 | public var zoom: Float = 0.88 15 | 16 | override var fragmentName: String { 17 | return "StereoViewerFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "cornerRadius": cornerRadius, 23 | "zoom": zoom 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Transitions/MTSwapTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTSwapTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTSwapTransition: MTTransition { 9 | 10 | public var depth: Float = 3 11 | 12 | public var reflection: Float = 0.4 13 | 14 | public var perspective: Float = 0.2 15 | 16 | override var fragmentName: String { 17 | return "SwapFragment" 18 | } 19 | 20 | override var parameters: [String: Any] { 21 | return [ 22 | "depth": depth, 23 | "reflection": reflection, 24 | "perspective": perspective 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTSwirlTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTSwirlTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTSwirlTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "SwirlFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTTVStaticTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTTVStaticTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2020/3/24. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTTVStaticTransition: MTTransition { 11 | 12 | public var offset: Float = 0.02 13 | 14 | override var fragmentName: String { 15 | return "TVStaticFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ "offset": offset ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTTangentMotionBlurTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTTangentMotionBlurTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2020/4/9. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTTangentMotionBlurTransition: MTTransition { 11 | 12 | override var fragmentName: String { 13 | return "TangentMotionBlurFragment" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Transitions/MTTopBottomTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTTopBottomTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2021/2/22. 6 | // 7 | 8 | import Foundation 9 | 10 | public class MTTopBottomTransition: MTTransition { 11 | override var fragmentName: String { 12 | return "TopBottomFragment" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Transitions/MTUndulatingBurnOutTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTUndulatingBurnOutTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | import MetalPetal 9 | 10 | public class MTUndulatingBurnOutTransition: MTTransition { 11 | 12 | public var color: MTIColor = MTIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0) 13 | 14 | public var smoothness: Float = 0.03 15 | 16 | public var center: CGPoint = CGPoint(x: 0.5, y: 0.5) 17 | 18 | override var fragmentName: String { 19 | return "UndulatingBurnOutFragment" 20 | } 21 | 22 | override var parameters: [String: Any] { 23 | return [ 24 | "color": MTIVector(value: simd_float3(color.red, color.green, color.blue)), 25 | "smoothness": smoothness, 26 | "center": MTIVector(value: center) 27 | ] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Transitions/MTWaterDropTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTWaterDropTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTWaterDropTransition: MTTransition { 9 | 10 | public var speed: Float = 30 11 | 12 | public var amplitude: Float = 30 13 | 14 | override var fragmentName: String { 15 | return "WaterDropFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "speed": speed, 21 | "amplitude": amplitude 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Transitions/MTWindTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: gre 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 WindFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & size [[ buffer(0) ]], 14 | constant float & ratio [[ buffer(1) ]], 15 | constant float & progress [[ buffer(2) ]], 16 | sampler textureSampler [[ sampler(0) ]]) 17 | { 18 | float2 uv = vertexIn.textureCoordinate; 19 | uv.y = 1.0 - uv.y; 20 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 21 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 22 | float r = rand(float2(0, uv.y)); 23 | float m = smoothstep(0.0, -size, uv.x*(1.0-size) + size*r - (progress * (1.0 + size))); 24 | return mix(getFromColor(uv, fromTexture, ratio, _fromR), 25 | getToColor(uv, toTexture, ratio, _toR), 26 | m); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Source/Transitions/MTWindTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTWindTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTWindTransition: MTTransition { 9 | 10 | public var size: Float = 0.2 11 | 12 | override var fragmentName: String { 13 | return "WindFragment" 14 | } 15 | 16 | override var parameters: [String: Any] { 17 | return [ 18 | "size": size 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Transitions/MTWindowBlindsTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: Fabien Benetou 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 WindowBlindsFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & ratio [[ buffer(0) ]], 14 | constant float & progress [[ buffer(1) ]], 15 | sampler textureSampler [[ sampler(0) ]]) 16 | { 17 | float2 uv = vertexIn.textureCoordinate; 18 | uv.y = 1.0 - uv.y; 19 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 20 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 21 | 22 | float t = progress; 23 | 24 | if (mod(floor(uv.y * 100.0 * progress),2.0) == 0.0) { 25 | t *= 2.0 - 0.5; 26 | } 27 | 28 | return mix( 29 | getFromColor(uv, fromTexture, ratio, _fromR), 30 | getToColor(uv, toTexture, ratio, _toR), 31 | mix(t, progress, smoothstep(0.8, 1.0, progress)) 32 | ); 33 | } 34 | -------------------------------------------------------------------------------- /Source/Transitions/MTWindowBlindsTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTWindowblindsTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTWindowBlindsTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "WindowBlindsFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTWindowSliceTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: gre 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 WindowSliceFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & count [[ buffer(0) ]], 14 | constant float & smoothness [[ buffer(1) ]], 15 | constant float & ratio [[ buffer(2) ]], 16 | constant float & progress [[ buffer(3) ]], 17 | sampler textureSampler [[ sampler(0) ]]) 18 | { 19 | float2 uv = vertexIn.textureCoordinate; 20 | uv.y = 1.0 - uv.y; 21 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 22 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 23 | 24 | float pr = smoothstep(-smoothness, 0.0, uv.x - progress * (1.0 + smoothness)); 25 | float s = step(pr, fract(count * uv.x)); 26 | return mix(getFromColor(uv, fromTexture, ratio, _fromR), 27 | getToColor(uv, toTexture, ratio, _toR), 28 | s); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Source/Transitions/MTWindowSliceTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTWindowsliceTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTWindowSliceTransition: MTTransition { 9 | 10 | public var count: Float = 10 11 | 12 | public var smoothness: Float = 0.5 13 | 14 | override var fragmentName: String { 15 | return "WindowSliceFragment" 16 | } 17 | 18 | override var parameters: [String: Any] { 19 | return [ 20 | "count": count, 21 | "smoothness": smoothness 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Transitions/MTWipeDownTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: Jake Nelson 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 WipeDownFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & ratio [[ buffer(0) ]], 14 | constant float & progress [[ buffer(1) ]], 15 | sampler textureSampler [[ sampler(0) ]]) 16 | { 17 | float2 uv = vertexIn.textureCoordinate; 18 | uv.y = 1.0 - uv.y; 19 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 20 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 21 | 22 | float2 p = uv.xy/float2(1.0).xy; 23 | float4 a = getFromColor(uv, fromTexture, ratio, _fromR); 24 | float4 b = getToColor(uv, toTexture, ratio, _toR); 25 | return mix(a, b, step(1.0 - p.y, progress)); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTWipeDownTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTWipeDownTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTWipeDownTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "WipeDownFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTWipeLeftTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: Jake Nelson 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 WipeLeftFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & ratio [[ buffer(0) ]], 14 | constant float & progress [[ buffer(1) ]], 15 | sampler textureSampler [[ sampler(0) ]]) 16 | { 17 | float2 uv = vertexIn.textureCoordinate; 18 | uv.y = 1.0 - uv.y; 19 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 20 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 21 | 22 | float2 p = uv.xy/float2(1.0).xy; 23 | float4 a = getFromColor(uv, fromTexture, ratio, _fromR); 24 | float4 b = getToColor(uv, toTexture, ratio, _toR); 25 | return mix(a, b, step(1.0 - p.x, progress)); 26 | } 27 | -------------------------------------------------------------------------------- /Source/Transitions/MTWipeLeftTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTWipeLeftTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTWipeLeftTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "WipeLeftFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTWipeRightTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: Jake Nelson 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 WipeRightFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & ratio [[ buffer(0) ]], 14 | constant float & progress [[ buffer(1) ]], 15 | sampler textureSampler [[ sampler(0) ]]) 16 | { 17 | float2 uv = vertexIn.textureCoordinate; 18 | uv.y = 1.0 - uv.y; 19 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 20 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 21 | 22 | float2 p = uv.xy/float2(1.0).xy; 23 | float4 a = getFromColor(uv, fromTexture, ratio, _fromR); 24 | float4 b = getToColor(uv, toTexture, ratio, _toR); 25 | return mix(a, b, step(0.0 + p.x, progress)); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Source/Transitions/MTWipeRightTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTWipeRightTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTWipeRightTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "WipeRightFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTWipeUpTransition.metal: -------------------------------------------------------------------------------- 1 | // Author: Jake Nelson 2 | // License: MIT 3 | 4 | #include 5 | #include "MTIShaderLib.h" 6 | #include "MTTransitionLib.h" 7 | 8 | using namespace metalpetal; 9 | 10 | fragment float4 WipeUpFragment(VertexOut vertexIn [[ stage_in ]], 11 | texture2d fromTexture [[ texture(0) ]], 12 | texture2d toTexture [[ texture(1) ]], 13 | constant float & ratio [[ buffer(0) ]], 14 | constant float & progress [[ buffer(1) ]], 15 | sampler textureSampler [[ sampler(0) ]]) 16 | { 17 | float2 uv = vertexIn.textureCoordinate; 18 | uv.y = 1.0 - uv.y; 19 | float _fromR = float(fromTexture.get_width())/float(fromTexture.get_height()); 20 | float _toR = float(toTexture.get_width())/float(toTexture.get_height()); 21 | 22 | float2 p = uv.xy/float2(1.0).xy; 23 | float4 a = getFromColor(uv, fromTexture, ratio, _fromR); 24 | float4 b = getToColor(uv, toTexture, ratio, _toR); 25 | return mix(a, b, step(0.0 + p.y, progress)); 26 | } 27 | -------------------------------------------------------------------------------- /Source/Transitions/MTWipeUpTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTWipeUpTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTWipeUpTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "WipeUpFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Transitions/MTZoomInCirclesTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTZoomInCirclesTransition.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2019/1/28. 6 | // 7 | 8 | public class MTZoomInCirclesTransition: MTTransition { 9 | 10 | override var fragmentName: String { 11 | return "ZoomInCirclesFragment" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/UIImage+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Extensions.swift 3 | // MTTransitions 4 | // 5 | // Created by alexiscn on 2020/3/22. 6 | // 7 | 8 | import UIKit 9 | 10 | // Based on: https://stackoverflow.com/a/29552143 11 | extension UIImage { 12 | func imageWithSize(size:CGSize) -> UIImage? { 13 | var scaledImageRect = CGRect.zero 14 | 15 | let aspectWidth:CGFloat = size.width / self.size.width 16 | let aspectHeight:CGFloat = size.height / self.size.height 17 | let aspectRatio:CGFloat = min(aspectWidth, aspectHeight) 18 | 19 | scaledImageRect.size.width = self.size.width * aspectRatio 20 | scaledImageRect.size.height = self.size.height * aspectRatio 21 | scaledImageRect.origin.x = (size.width - scaledImageRect.size.width) / 2.0 22 | scaledImageRect.origin.y = (size.height - scaledImageRect.size.height) / 2.0 23 | 24 | UIGraphicsBeginImageContextWithOptions(size, false, 0) 25 | 26 | self.draw(in: scaledImageRect) 27 | 28 | let scaledImage = UIGraphicsGetImageFromCurrentImageContext() 29 | UIGraphicsEndImageContext(); 30 | 31 | return scaledImage 32 | } 33 | } 34 | --------------------------------------------------------------------------------