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

Blinking content animation #96

Closed
zapletnev opened this issue Feb 16, 2017 · 0 comments
Closed

Blinking content animation #96

zapletnev opened this issue Feb 16, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@zapletnev
Copy link
Contributor

import Foundation
import Macaw

class StudioView: MacawView {    
    required init?(coder aDecoder: NSCoder) {
        super.init(node: Group(contents: []), coder: aDecoder)
        
        let animationGroup = Group(contents: [])
        let animation = animationGroup.contentsVar.animation({ t in
            let shape = Shape(
                form: Arc(
                    ellipse: Ellipse(
                        cx: (Double(self.bounds.width) / 2),
                        cy: (Double(self.bounds.height) / 2),
                        rx: 150.0, ry: 150.0),
                    shift: -M_PI / 2 + 0.05,
                    extent: 2 * M_PI * t - 0.1
                ),
                stroke: Stroke(fill: Color.red, width: 4)
            )
            return [shape]
        })
        
        let playBtn = Shape(
            form: Rect(
                x: Double(self.bounds.width) / 2 - 50,
                y: Double(self.bounds.height) / 2 - 50,
                w: 100, h: 100
            ),
            fill: Color.red
        )
        
        let text = Text(
            text: "START",
            align: .mid,
            place: Transform.move(
                dx: (Double(self.bounds.width) / 2),
                dy: (Double(self.bounds.height) / 2)
            ),
            opaque: false
        )
        playBtn.onTap { _ in
            animation.play()
        }
        self.node = [playBtn, text, animationGroup].group()
      }
}  

Please note: after removing 0.05/0.1 constants blinking effect is disappeared.

@zapletnev zapletnev added the bug label Feb 16, 2017
@ystrot ystrot added this to the 0.8.1 milestone Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants