|
Post by mikesharpe on Oct 18, 2022 3:32:41 GMT
Import Dom From "lib/web/dom.bas"
_Title "Egg Designer 2000" Dim Shared s, L, B, w, D, sw, sh, xx, x, a, y, aa Dim Shared ctlS, ctlL, ctlB, ctlW, ctlD
sw = 640 sh = 480 Screen _NewImage(sw, sh, 32) Color 15
InitControls DrawEgg
Sub DrawEgg Cls s = ctlS.value L = ctlL.value / 10 B = ctlB.value / 10 w = ctlW.value / 10 D = ctlD.value / 10 For xx = -0.5 * L * s To 0.5 * L * s x = xx / s a = (L * L - 4 * x * x) / (L * L + 8 * w * x + 4 * w * w) y = 0.5 * B * Sqr(a) 'you can stop here for p(x) = x
a = Sqr(5.5 * L * L + 11 * L * w + 4 * w * w) a = a * (Sqr(3) * B * L - 2 * D * Sqr(L * L + 2 * w * L + 4 * w * w)) a = a / (Sqr(3) * B * L * (Sqr(5.5 * L * L + 11 * L * w + 4 * w * w) - 2 * Sqr(L * L + 2 * w * L + 4 * w * w)))
aa = L * (L * L + 8 * w * x + 4 * w * w) aa = aa / (2 * (L - 2 * w) * x * x + (L * L + 8 * L * w - 4 * w * w) * x + 2 * L * w * w + L * L * w + L * L * L) aa = 1 - aa
y = y * (1 - a * aa)
Line (sw / 2 + xx, sh / 2 - s * y)-(sw / 2 + xx, sh / 2 + s * y) Next End Sub
Sub InitControls Dim c: c = Dom.Create("div") c.style.padding = "20px" Dom.Create "span", c, "s: " Dim e: e = Dom.Create("input", c) e.type = "range" e.style.width = "125px" e.style.verticalAlign = "middle" e.min = 1 e.max = 100 e.step = 1 e.value = 80 ctlS = e e = Dom.Create("span", c, "L: ") e.style.marginLeft = "20px" e = Dom.Create("input", c) e.type = "range" e.style.verticalAlign = "middle" e.style.width = "125px" e.min = 1 e.max = 100 e.value = 54 ctlL = e
e = Dom.Create("span", c, "B: ") e.style.marginLeft = "20px" e = Dom.Create("input", c) e.type = "range" e.style.verticalAlign = "middle" e.style.width = "125px" e.min = 1 e.max = 100 e.value = 41 ctlB = e e = Dom.Create("span", c, "w: ") e.style.marginLeft = "20px" e = Dom.Create("input", c) e.type = "range" e.style.verticalAlign = "middle" e.style.width = "125px" e.min = 1 e.max = 20 e.value = 4 ctlW = e
e = Dom.Create("span", c, "D: ") e.style.marginLeft = "20px" e = Dom.Create("input", c) e.type = "range" e.style.verticalAlign = "middle" e.style.width = "125px" e.min = 1 e.max = 100 e.value = 32 ctlD = e Dom.Event ctlS, "input", sub_DrawEgg Dom.Event ctlL, "input", sub_DrawEgg Dom.Event ctlB, "input", sub_DrawEgg Dom.Event ctlW, "input", sub_DrawEgg Dom.Event ctlD, "input", sub_DrawEgg End Sub
|
|