Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. Red [
  2. Date: 5-Sep-2019
  3. Description: {Example of zooming and moving with different faces}
  4. Author: "Toomas Vooglaid"
  5. Licence: "Public domain"
  6. ]
  7. context [
  8. ofs: just-down: none
  9.  
  10. moving: function [face event][
  11. mx: face/draw/matrix
  12. df: event/offset - ofs
  13. face/draw/matrix/5: mx/5 + df/x
  14. face/draw/matrix/6: mx/6 + df/y
  15. self/ofs: event/offset
  16. face/draw: face/draw
  17. ]
  18.  
  19. zooming: function [face event][
  20. mx: face/draw/matrix
  21. ev: event/offset
  22. op: get pick [/ *] 0 > event/picked
  23. face/draw/matrix: reduce [
  24. sc: mx/1 op 1.1 0 0 sc
  25. mx/5 - ev/x op 1.1 + ev/x
  26. mx/6 - ev/y op 1.1 + ev/y
  27. ]
  28. ]
  29.  
  30. view/tight [
  31. title "Zoom-and-move"
  32. style zoom: box 500x300 all-over
  33. on-wheel [
  34. unless find face/draw "zooming" [
  35. change find face/draw string! "zooming"
  36. ]
  37. zooming face event
  38. ]
  39. on-down [
  40. change find face/draw string! "ready.."
  41. move find face/parent/pane face tail face/parent/pane
  42. ofs: event/offset
  43. just-down: yes
  44. ]
  45. on-over [
  46. either event/down? [
  47. unless find face/draw "moving" [
  48. either just-down [just-down: no][
  49. change find face/draw string! "moving"
  50. ]
  51. ]
  52. moving face event
  53. ][
  54. unless find face/draw "waiting" [
  55. change find face/draw string! "waiting"
  56. ]
  57. ]
  58. ]
  59. on-up [change find face/draw string! "waiting"]
  60.  
  61. zoom draw [
  62. matrix [1 0 0 1 0 0]
  63. fill-pen linen
  64. box 100x100 200x130 5
  65. text 125x105 "waiting"
  66. ]
  67. at 0x0 zoom draw [
  68. matrix [1 0 0 1 0 0]
  69. fill-pen beige
  70. ellipse 10x10 120x40
  71. text 50x20 "waiting"
  72. ]
  73. ]
  74. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement