Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaunlebron/fece3da5254685cfc1b207c9bd075503 to your computer and use it in GitHub Desktop.
Save shaunlebron/fece3da5254685cfc1b207c9bd075503 to your computer and use it in GitHub Desktop.
first shot at dynamicland #softfab
-- Shirt (#softfab)
Claim (you) has state "waist" with initial value (30).
Claim (you) has state "arm" with initial value (5).
Claim (you) has state "armaround" with initial value (10).
Claim (you) has state "side" with initial value (20).
Claim (you) has state "neck" with initial value (15).
When (you) contains dots /dots/,
(you) has width /width/:
local max_waist = 100
local max_arm = 20
local max_armaround = 50
local max_side = 50
local max_neck = 30
for i, dot in ipairs(dots) do
Wish (you) draws shape "circle" with options ({
center = dot,
radius = 0.5,
stroke = "green"
}).
local percent = dot.x/width
if dot.y > 0 and dot.y < 1 then
Wish (you) sets state "waist" to (max_waist * percent) with jitter window (0.3).
end
if dot.y > 1 and dot.y < 2 then
Wish (you) sets state "arm" to (max_arm * percent) with jitter window (0.3).
end
if dot.y > 2 and dot.y < 3 then
Wish (you) sets state "armaround" to (max_armaround * percent) with jitter window (0.3).
end
if dot.y > 3 and dot.y < 4 then
Wish (you) sets state "side" to (max_side * percent) with jitter window (0.3).
end
if dot.y > 4 and dot.y < 5 then
Wish (you) sets state "neck" to (max_neck * percent) with jitter window (0.3).
end
end
End
When (you) has region /region/ on /supporter/,
(you) has state "waist" with value /waist/,
(you) has state "arm" with value /arm/,
(you) has state "armaround" with value /armaround/,
(you) has state "side" with value /side/,
(you) has state "neck" with value /neck/:
-- Make shape relative to page position and rotation
local shape = new_illumination()
shape:translate {translation = region[1]}
local top = vec.minus(region[1], region[2])
shape:rotate {radians = math.atan2(top.y, top.x)}
local p1 = {x = 0, y = 2}
local p2 = {x = p1.x - waist/4, y = p1.y}
local p3 = {x = p2.x, y = p2.y + side}
local p4 = {x = p3.x - arm, y = p3.y}
local p5 = {x = p4.x, y = p4.y + armaround/2}
local p6 = {x = p5.x + arm, y = p5.y}
local p7 = {x = p1.x - neck/4, y = p6.y}
local p8 = {x = p1.x, y = p7.y - neck/4}
shape:line{from=p1, to=p2, stroke="white"}
shape:line{from=p2, to=p3, stroke="white"}
shape:line{from=p3, to=p4, stroke="white"}
shape:line{from=p4, to=p5, stroke="white"}
shape:line{from=p5, to=p6, stroke="white"}
shape:line{from=p6, to=p7, stroke="white"}
shape:line{from=p7, to=p8, stroke="white"}
shape:line{from=p8, to=p1, stroke="red"}
Wish (supporter) has illumination (shape).
local measurements = new_illumination()
measurements:text {text = "waist: "..waist, x = 0.25, y = 6, font_size = 0.75}
measurements:text {text = "arm: "..arm, x = 0.25, y = 6.75, font_size = 0.75}
measurements:text {text = "arm around: "..armaround, x = 0.25, y = 7.5, font_size = 0.75}
measurements:text {text = "side: "..side, x = 0.25, y = 8.25, font_size = 0.75}
measurements:text {text = "neck: "..neck, x = 0.25, y = 9, font_size = 0.75}
Wish (you) has illumination (measurements).
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment