sourceextensions/blender/demos/Sizes.xtl

1⍝│ Sizes.xtl -- the size comparison, xkcd style, as a Blender scene: one 2⍝│ cube, a 10 by 10 slab of a hundred, a 10 by 10 by 10 block of a 3⍝│ thousand, side by side on the ground and labeled, the camera going 4⍝│ once round them. Shared by the demo (demos/cubes.xtl: the video) and 5⍝│ its test (a few tiny frames). 6⍝│ Import: "sz:" u_se< "Sizes" 7 8"bp:" u̲se< "Bpy" 9 10⍝━━ The cubes 11 12⍝ every cell of an a by b by c block, x slowest, 0-based, as n by 3 13ʰc̲ells ← { abc → 14 n ← '× r̲/ abc 15 i ← (r̲ange n) − 1 16 c ← 3 s̲elect abc 17 b ← 2 s̲elect abc 18 2 1 t̲ranspose (3 c̲at n) r̲eshape (i d̲iv b × c) c̲at ((i d̲iv c) m̲od b) c̲at i m̲od c 19} 20 21⍝│ the three groups' centers (n by 3, z up, on the ground at z 0): one 22⍝│ cube at x -10; a hundred, 10 by 10 on the ground, about x 0; a 23⍝│ thousand, 10 by 10 by 10, about x 16 -- a block a step apart, the 24⍝│ cubes 0.9 wide so each shows 25⍝│ >> "sz:" u_se< "Sizes" 26⍝│ >> (1 s_elect s_hape sz:one) c_at (1 s_elect s_hape sz:hundred) c_at 1 s_elect s_hape sz:thousand 27⍝│ 1 100 1000 28ˡone ← 1 3 r̲eshape -10.0 0.0 0.5 29⍝│ a hundred: 10 by 10 on the ground, about x 0 30ˡhundred ← (f̲loat ʰc̲ells 10 10 1) + 100 3 r̲eshape -4.5 -4.5 0.5 31⍝│ a thousand: 10 by 10 by 10, about x 16 32ˡthousand ← (f̲loat ʰc̲ells 10 10 10) + 1000 3 r̲eshape 11.5 -4.5 0.5 33 34⍝━━ The scene 35 36⍝│ (width, height, frames) sz:s_cene 0: the whole script Blender runs: 37⍝│ the three groups, a label before each, the ground, a pale sky and a 38⍝│ sun, the camera going once round in the frames, EEVEE at that size; 39⍝│ then the exports and the report. The video is left to the caller 40⍝│ (bp:v_ideo or bp:s_till), added after. 41ˡs̲cene ← { (w, h, frames) z → 42 blue ← 0.42 0.62 0.9 43 ink ← 0.08 0.08 0.1 44 ((ᵇᵖhead c̲at (("one", ˡone, 0.9, blue) ᵇᵖc̲ubes 0) c̲at (("hundred", ˡhundred, 0.9, blue) ᵇᵖc̲ubes 0) c̲at (("thousand", ˡthousand, 0.9, blue) ᵇᵖc̲ubes 0)) c̲at 45 ((("1", -10.0 -3.0 0.0, 1.6, ink) ᵇᵖl̲abel 0) c̲at (("100", 0.0 -7.5 0.0, 1.6, ink) ᵇᵖl̲abel 0) c̲at (("1000", 16.0 -7.5 0.0, 1.6, ink) ᵇᵖl̲abel 0)) c̲at 46 (((3.0 0.0 0.0, 200.0, 0.97 0.97 0.95) ᵇᵖg̲round 0) c̲at ((0.55 0.62 0.72, 3.0) ᵇᵖl̲ights 0)) c̲at 47 (((3.0 0.0 3.0, 42.0, 20.0, frames) ᵇᵖo̲rbit 0) c̲at ((w, h, 24) ᵇᵖs̲etup 0)) c̲at 48 (ᵇᵖe̲xports "sizes") c̲at ᵇᵖreport) 49}