Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env jruby
- # frozen_string_literal: false
- require 'propane'
- # robot 3
- # propane graffiti by 8mana
- # based on code by Casey Reas and Ben Fry
- class RobotThree < Propane::App
- def settings
- size 360, 480
- end
- def setup
- sketch_title 'robot'
- $x = 60
- $y = 440
- $bodyHeight = 110
- $neckHeight = 70
- $radius = 45
- $easing = 0.02
- stroke_weight 2
- ellipse_mode RADIUS
- end
- def draw
- targetX = mouseX
- $x += (targetX - $x) * $easing
- if mouse_pressed?
- $neckHeight = 16
- $bodyHeight = 90
- else
- $neckHeight = 70
- $bodyHeight = 160
- end
- $ny = $y - $bodyHeight - $neckHeight - $radius
- background 204
- #ellipseMode RADIUS
- # neck
- stroke 102 # set stroke to gray
- #line x+2, y-bodyHeight, x+2, ny # left
- line $x+12, $y-$bodyHeight, $x+12, $ny # middle
- #line x+22, y-bodyHeight, x+22, ny # right
- # antennae
- line $x+12, $ny, $x-18, $ny-43 # small
- line $x+12, $ny, $x+42, $ny-99 # tall
- line $x+12, $ny, $x+78, $ny+15 # medium
- # body
- strokeWeight 0 # disable stroke
- fill 102 # set fill to gray
- ellipse $x, $y-33, 33, 33 # antigravity orb
- fill 0 # set fill to black
- rect $x-45, $y-$bodyHeight, 90, $bodyHeight-33 # main body
- #fill 102
- #rect x-45, y-bodyHeight+17, 90, 6
- # head
- fill 0 # set fill to black
- ellipse $x+12, $ny, $radius, $radius # head
- fill 255 # set fill to white
- ellipse $x+24, $ny-6, 14, 14 # large eye
- fill 0 # set fill to black
- ellipse $x+24, $ny-6, 3, 3 # pupil
- #fill 153 # set fill to light gray
- #ellipse x, ny-8, 5, 5 # small eye 1
- #ellipse x+30, ny-26, 4, 4 # small eye 2
- #ellipse x+41, ny+6, 3, 3 # small eye 3
- end
- end
- RobotThree.new
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement