Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (39 sloc) 1.9 KB
# Robot Arm Drawing
This is where the main website structure is defined
#app/main = [|root direction containts|
"drawing" "column" [#robot-controls]
"drawing" "column" [#robot-animation]]
## Drawing
Set up the robot arm linkages
angle1 = #slider1{1,4}{1,3}
angle2 = #slider2{1,4}{1,3}
angle3 = #slider3{1,4}{1,3}
x0 = 400
y0 = 550
h1 = 53
h2 = 100
h3 = 85
y1 = (y0 - 50) - h1 * math/cos(degrees: angle1)
x1 = x0 + h1 * math/sin(degrees: angle1)
y2 = y1 - h1 * math/cos(degrees: angle1)
x2 = x1 + h1 * math/sin(degrees: angle1)
y3 = y2 - h2 * math/cos(degrees: angle2)
x3 = x2 + h2 * math/sin(degrees: angle2)
y4 = y3 - h2 * math/cos(degrees: angle2)
x4 = x3 + h2 * math/sin(degrees: angle2)
y5 = y4 - h3 * math/cos(degrees: angle3)
x5 = x4 + h3 * math/sin(degrees: angle3)
#robot-arm = [|shape parameters|
"image" [x: x3 y: y3 rotation: angle2 image: "http://mech-lang.org/img/robotarm/link2.png"]
"image" [x: x1 y: y1 rotation: angle1 image: "http://mech-lang.org/img/robotarm/link1.png"]
"image" [x: x0 y: y0 rotation: 0 image: "http://mech-lang.org/img/robotarm/link0.png"]
"image" [x: x5 y: y5 rotation: angle3 image: "http://mech-lang.org/img/robotarm/gripper.png"]]
Do the draw
#drawing = [type: "canvas" class: _ contains: [#robot-arm] parameters: [width: 800 height: 650]]
Animation controls
#slider1 = [type: "slider" class: _ contains: _ parameters: [min: -120 max: 120 value: -45]]
#slider2 = [type: "slider" class: _ contains: _ parameters: [min: -120 max: 120 value: 60]]
#slider3 = [type: "slider" class: _ contains: _ parameters: [min: -90 max: 200 value: 170]]
Compose animation and controls
#robot-controls = [type: "div" class: _ containts: [#slider1; #slider2; #slider3]]
#robot-animation = [type: "div" class: _ contains: [#drawing]]
You can’t perform that action at this time.