Skip to content

Instantly share code, notes, and snippets.

@sebastien
Created December 22, 2018 17:03
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 sebastien/f439b05a9c46f92207bc3233a7cb2a17 to your computer and use it in GitHub Desktop.
Save sebastien/f439b05a9c46f92207bc3233a7cb2a17 to your computer and use it in GitHub Desktop.
// Triangle study
// Ref: https://otakugangsta.com/image/180451216975
let
w = 28;
h = 34;
black = (0.016, 0.031, 0.027);
// NOTE: Here we need to add an EPSILON otherwise the polygon
// drawing will fail.
prel (a,b,k) =
if (k ==a) 0.0000001
else (k - a) / (b - a);
in
union [
for (x in 0..3)
union [
for (y in 0..10)
let
k = prel(10,0,y);
in
let
dx = sin(lerp(0,2 * pi, k));
in
triangle {w:w*k, h:h * k}
>> colour (blue)
>> move (x * w + dx,y * h)
]
]
where
triangle {w,h} = convex_polygon [
(0,0),
(w,h/2),
(0,h)
] >> move (-w/2,-h/2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment