Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #!/usr/bin/env jruby
  2. # frozen_string_literal: false
  3. require 'propane'
  4.  
  5. # robot 3
  6. # propane graffiti by 8mana
  7. # based on code by Casey Reas and Ben Fry
  8.  
  9. class RobotThree < Propane::App
  10.  
  11. def settings
  12. size 360, 480
  13. end
  14.  
  15. def setup
  16. sketch_title 'robot'
  17. $x = 60
  18. $y = 440
  19. $bodyHeight = 110
  20. $neckHeight = 70
  21. $radius = 45
  22.  
  23. $easing = 0.02
  24. stroke_weight 2
  25. ellipse_mode RADIUS
  26. end
  27.  
  28. def draw
  29. targetX = mouseX
  30. $x += (targetX - $x) * $easing
  31.  
  32. if mouse_pressed?
  33. $neckHeight = 16
  34. $bodyHeight = 90
  35. else
  36. $neckHeight = 70
  37. $bodyHeight = 160
  38. end
  39.  
  40. $ny = $y - $bodyHeight - $neckHeight - $radius
  41.  
  42. background 204
  43.  
  44. #ellipseMode RADIUS
  45.  
  46. # neck
  47. stroke 102 # set stroke to gray
  48. #line x+2, y-bodyHeight, x+2, ny # left
  49. line $x+12, $y-$bodyHeight, $x+12, $ny # middle
  50. #line x+22, y-bodyHeight, x+22, ny # right
  51.  
  52. # antennae
  53. line $x+12, $ny, $x-18, $ny-43 # small
  54. line $x+12, $ny, $x+42, $ny-99 # tall
  55. line $x+12, $ny, $x+78, $ny+15 # medium
  56.  
  57. # body
  58. strokeWeight 0 # disable stroke
  59. fill 102 # set fill to gray
  60. ellipse $x, $y-33, 33, 33 # antigravity orb
  61. fill 0 # set fill to black
  62. rect $x-45, $y-$bodyHeight, 90, $bodyHeight-33 # main body
  63. #fill 102
  64. #rect x-45, y-bodyHeight+17, 90, 6
  65.  
  66. # head
  67. fill 0 # set fill to black
  68. ellipse $x+12, $ny, $radius, $radius # head
  69. fill 255 # set fill to white
  70. ellipse $x+24, $ny-6, 14, 14 # large eye
  71. fill 0 # set fill to black
  72. ellipse $x+24, $ny-6, 3, 3 # pupil
  73. #fill 153 # set fill to light gray
  74. #ellipse x, ny-8, 5, 5 # small eye 1
  75. #ellipse x+30, ny-26, 4, 4 # small eye 2
  76. #ellipse x+41, ny+6, 3, 3 # small eye 3
  77. end
  78. end
  79.  
  80. RobotThree.new
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement