Last active
April 18, 2020 07:34
-
-
Save foxicode/2937345dc413216b5a8535f72f19458d to your computer and use it in GitHub Desktop.
Sample JS plugin for iOS app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const circle1 = 1; | |
| const circle2 = 2; | |
| const circle3 = 3; | |
| let time = 0.0; | |
| let step = 0; | |
| function tick(delta) { | |
| time += delta; | |
| if (time >= 1000) { | |
| time -= 1000; | |
| loopStep(); | |
| } | |
| } | |
| function loopStep() { | |
| switch (step) { | |
| case 0: | |
| updateProperty(circle1, 'color', '#50ff0000'); | |
| updateProperty(circle2, 'color', '#ffffff00'); | |
| updateProperty(circle3, 'color', '#5000ff00'); | |
| break; | |
| case 1: | |
| updateProperty(circle1, 'color', '#50ff0000'); | |
| updateProperty(circle2, 'color', '#50ffff00'); | |
| updateProperty(circle3, 'color', '#ff00ff00'); | |
| break; | |
| case 2: | |
| updateProperty(circle1, 'color', '#ffff0000'); | |
| updateProperty(circle2, 'color', '#50ffff00'); | |
| updateProperty(circle3, 'color', '#5000ff00'); | |
| break; | |
| } | |
| step = (step + 1) % 3; | |
| } | |
| function start(width, height) { | |
| const circleRadius = height / 10; | |
| addWidget('Circle', { | |
| tag: circle1, | |
| x: width / 2, | |
| y: circleRadius * 2, | |
| radius: circleRadius, | |
| color: '#ffff0000', | |
| }); | |
| addWidget('Circle', { | |
| tag: circle2, | |
| x: width / 2, | |
| y: circleRadius * 5, | |
| radius: circleRadius, | |
| color: '#50ffff00', | |
| }); | |
| addWidget('Circle', { | |
| tag: circle3, | |
| x: width / 2, | |
| y: circleRadius * 8, | |
| radius: circleRadius, | |
| color: '#5000ff00', | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment