Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教下:做缩放动画时,画面会有抖动的感觉,不流畅,如何解决呢? #26

Open
yinghuochong opened this issue Dec 2, 2024 · 0 comments

Comments

@yinghuochong
Copy link

yinghuochong commented Dec 2, 2024

demo.mp4

demo代码如下:

    func scaleAnimationDemo() -> VideoLab {
        // 1. LayerGroup
        var timeRange = CMTimeRange(start: CMTime.zero, duration: CMTime(seconds: 5, preferredTimescale: 600))
        let keyTimes = [CMTime(seconds: 0, preferredTimescale: 600),
                        CMTime(seconds: 5, preferredTimescale: 600)]
        let animation1 = KeyframeAnimation(keyPath: "scale",
                                           values: [1, 1.2],
                                           keyTimes: keyTimes,
                                           timingFunctions: [.quadraticEaseInOut])
        var transform = Transform.identity
        transform.animations = [animation1]
        
        
        // Add sub-renderLayer1
        let image = UIImage(named: "image2.HEIC")
        let imageSource = ImageSource(cgImage: image?.cgImage)
        imageSource.selectedTimeRange = CMTimeRange(start: CMTime.zero, duration: timeRange.duration)
        timeRange = imageSource.selectedTimeRange
        let renderLayer1 = RenderLayer(timeRange: timeRange, source: imageSource)
        renderLayer1.transform = transform
        
        // 2. Composition
        let composition = RenderComposition()
        composition.renderSize = CGSize(width: 2016, height: 1512)
        composition.layers = [renderLayer1]
        
        // 3. VideoLab
        let videoLab = VideoLab(renderComposition: composition)
        
        return videoLab
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant