Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----- parameters -----
- base = 12:: int_slider("Bottom", 3, 48)
- top = 8:: int_slider("Top", 3, 48)
- height = 50:: int_slider("Height", 1, 500)
- block_w = 3:: float_slider("Block Width", 0.2, 10, 0.2)
- block_d = 1:: float_slider("Block Depth", 0.2, 10, 0.2)
- block_h = 1:: float_slider("Block Height", 0.2, 10, 0.2)
- rotate = 0 :: float_slider("Rotate", 0, 360, 10)
- offset_frac = 0.5 :: float_slider("Offset", 0, 1, 0.1)
- tighten = false:: toggle("Tighten")
- ----------------------
- c = col()
- c.dim = vec(block_w,block_h,block_d)
- function subtends(_c, _r)
- return (2*math.atan((_c.dim.x/2)/(_r - _c.dim.z/2)))
- end
- function radius_to(_c, _n)
- return (_c.dim.z/2 + c.dim.x/2/math.tan(2*math.pi/_n/2))
- end
- function circle(_c, _angle, _r, _y)
- local blocks = math.floor(2*math.pi/subtends(_c, _r))
- local alpha = 2*math.pi/blocks
- for i=1,blocks do
- local t = _angle + (i-1.5)*alpha
- if tighten then
- _r = radius_to(_c, blocks)
- end
- local x = _r*math.cos(t)
- local z = _r*math.sin(t)
- local b = brk(_c)
- b.pos = vec(x, _y, z)
- b.rot.y = -math.deg(t) + 90
- end
- end
- r_base = radius_to(c, base)
- r_top = radius_to(c, top)
- offset = 0
- function scale_by(_i, _imin, _imax, _min, _max)
- if _imin == _imax then
- return _min
- end
- return _min + (_i - _imin)/(_imax - _imin)*(_max - _min)
- end
- for i=1,height do
- local y = c.dim.y*(i-0.5)
- local r = scale_by(i,1,height, r_base, r_top)
- offset = offset + math.rad(rotate) + offset_frac*subtends(c, r)
- circle(c, offset, r, y)
- end
- randomize_colors()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement