Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Red [
- Date: 5-Sep-2019
- Description: {Example of zooming and moving with different faces}
- Author: "Toomas Vooglaid"
- Licence: "Public domain"
- ]
- context [
- ofs: just-down: none
- moving: function [face event][
- mx: face/draw/matrix
- df: event/offset - ofs
- face/draw/matrix/5: mx/5 + df/x
- face/draw/matrix/6: mx/6 + df/y
- self/ofs: event/offset
- face/draw: face/draw
- ]
- zooming: function [face event][
- mx: face/draw/matrix
- ev: event/offset
- op: get pick [/ *] 0 > event/picked
- face/draw/matrix: reduce [
- sc: mx/1 op 1.1 0 0 sc
- mx/5 - ev/x op 1.1 + ev/x
- mx/6 - ev/y op 1.1 + ev/y
- ]
- ]
- view/tight [
- title "Zoom-and-move"
- style zoom: box 500x300 all-over
- on-wheel [
- unless find face/draw "zooming" [
- change find face/draw string! "zooming"
- ]
- zooming face event
- ]
- on-down [
- change find face/draw string! "ready.."
- move find face/parent/pane face tail face/parent/pane
- ofs: event/offset
- just-down: yes
- ]
- on-over [
- either event/down? [
- unless find face/draw "moving" [
- either just-down [just-down: no][
- change find face/draw string! "moving"
- ]
- ]
- moving face event
- ][
- unless find face/draw "waiting" [
- change find face/draw string! "waiting"
- ]
- ]
- ]
- on-up [change find face/draw string! "waiting"]
- zoom draw [
- matrix [1 0 0 1 0 0]
- fill-pen linen
- box 100x100 200x130 5
- text 125x105 "waiting"
- ]
- at 0x0 zoom draw [
- matrix [1 0 0 1 0 0]
- fill-pen beige
- ellipse 10x10 120x40
- text 50x20 "waiting"
- ]
- ]
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement