Created
June 26, 2016 14:41
-
-
Save greggirwin/3792015ce3ed43d78c1f0b07887aa33d to your computer and use it in GitHub Desktop.
Move a face in a layout dynamically, and with variable speed.
This file contains 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
Red [ | |
Title: "Move a face, like a spring" | |
Author: "Gregg Irwin" | |
File: %move-face-spring.red | |
Tabs: 4 | |
Needs: View | |
Purpose: { | |
- Show how changing a face's offset moves it. | |
- Adjust the speed to make it more interesting. | |
} | |
] | |
diff: does [11x11 - divide absolute (btn/offset - 100x100) 10] | |
dir: 1 | |
view [ | |
size 200x200 | |
origin 0x0 | |
btn: button "Quit" 50x50 rate 30 [quit] on-time [ | |
face/offset: face/offset + (dir * diff) | |
if face/offset > 150x150 [dir: -1] | |
if face/offset < 0 [dir: 1] | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment