Skip to content

Instantly share code, notes, and snippets.

@greggirwin
Created June 26, 2016 14:41
Show Gist options
  • Save greggirwin/3792015ce3ed43d78c1f0b07887aa33d to your computer and use it in GitHub Desktop.
Save greggirwin/3792015ce3ed43d78c1f0b07887aa33d to your computer and use it in GitHub Desktop.
Move a face in a layout dynamically, and with variable speed.
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