Skip to main content

Command Palette

Search for a command to run...

WCCC_Cubes

Cubic Mindset

Published
3 min read
WCCC_Cubes

SpaceFulCubes

For this week's Creative Code challenge by @sableRaph: “Cubes“, SpaceFulCubes is coded with LiveCodeLab, HydraVIdeoSynth, Python & SonicPi. Where a realm of cubes is being examined. Also the Poetry is written in a poetic form called a “TriCube”

Poem

Spaceful Paths
Overlaid
Through Orbits

No Limits
More Upgrades
Infused Maths

Insert Space
Pace & Place,
Cubic Race

Video

https://youtu.be/0yYV3uNjyOc

Code

Python

#original code = https://matplotlib.org/stable/gallery/mplot3d/voxels.html import matplotlib.pyplot as plt import numpy as np import random as rd


def plotting(f): # prepare some coordinates x, y, z = np.indices((f, f, f))


# draw cuboids in the top left and bottom right corners, and a link between
# them
cube1 = (x < 3) & (y < 3) & (z < 3)
cube2 = (x >= 5) & (y >= 5) & (z >= 5)
link = abs(x - y) + abs(y - z) + abs(z - x) <= 2
link2 =  abs(y - z) + abs(x - z) + abs(y - x) >= 5

colors = ['red','aqua','green','white','orange','violet','black','purple']

palette = rd.choices(colors, k=20)


if f % 2 == 0:
    if f % 3 == 0:
        voxelarray = cube1 ^ cube2 | link ^ link2
        # set the colors of each object
        colors = np.empty(voxelarray.shape, dtype=object)
        colors[link] =  palette[0]
        colors[cube1] = palette[1]
        colors[cube2] = palette[2]
        colors[link2] =  palette[12]
    else:
        voxelarray = cube1 | cube2 | link 
        colors = np.empty(voxelarray.shape, dtype=object)
        colors[link] = palette[3]
        colors[cube1] = palette[4]
        colors[cube2] = palette[5]
        colors[link2] =  palette[13]
else:
    if f % 5 == 0:
        voxelarray = cube1 ^ link ^ link2
        colors = np.empty(voxelarray.shape, dtype=object)
        colors[link] = palette[6]
        colors[cube1] = palette[7]
        colors[cube2] = palette[8]
        colors[link2] =  palette[14]
    else:
        voxelarray = cube1 | link | link2
        colors = np.empty(voxelarray.shape, dtype=object)
        colors[link] = palette[9]
        colors[cube1] = palette[10]
        colors[cube2] = palette[11]
        colors[link2] =  palette[15]



# and plot everything
ax = plt.figure().add_subplot(projection='3d')
ax.voxels(voxelarray, facecolors=colors, edgecolor='k')
plt.axis('off') # Hide all axes
plt.show()

if f == 20 or f == 21:
    return 1
else:
    return plotting(f + 1)

LiveCodeLab

20 times with i
	scale 0.95
	ambientLight
	stroke black
	rotate Math.hypot(i,i/3), Math.hypot(i/5,i/10), Math.hypot(time % i, time % i)
	box Math.hypot(1,sin(time)), Math.hypot(1,sin(time)),Math.hypot(1,sin(time))


30 times with i
	scale 0.95
	ambientLight
	fill blue
	stroke red
	move i/12 
	rotate Math.hypot(i,i/3), Math.hypot(i/5,i/10), Math.hypot(time % i, time % i)
	box time % (i/10),time % (i/10),time % (i/10)


pushMatrix()
30 times with i
	scale 0.35
	ambientLight
	fill orange
	stroke blue
	move i/12 
	rotate Math.hypot(i,i/3), Math.hypot(i/5,i/10), Math.hypot(time % i, time % i)
	box time % (i/10),time % (i/10),time % (i/10)
	popMatrix()


pushMatrix()
30 times with i
	scale 0.35
	ambientLight
	fill red
	stroke blue
	move -i/12 
	rotate Math.hypot(i,i/10), Math.hypot(i/20,i/10), Math.hypot(time % i/2, time % i/4)
	box time % (i/5),time % (i/5),time % (i/5)
	popMatrix()

HydraVideoSynth

Glitch

s0.initScreen()

src(s0).blend(src(s0).scale(1.05)).blend(src(s0).scale(1.15)).diff(src(s0).scale(0.95)).diff(src(s0).scale(0.85)).diff(src(s0).scale(1.20)).out()

Mask

s0.initScreen()

src(s0).mask(noise(1,2,3).colorama(0.3).luma(0.74)).out()

speed = 0.4

SonicPi


live_loop :BassAttack do
  use_random_seed Time.now.to_i / 4
  use_bpm [40,120,240,480].choose
  
  with_fx [:echo,:ixi_techno].choose, mix: rrand(0,0.75) do
    sample :perc_snap if spread(2,3).reverse
    sample :bd_klub if spread(5,6).tick
  end
  
  sample :elec_blup if spread(4,7).tick
  sample :elec_blip if spread(1,2).tick
  sleep [2,4,8].tick
end

#shorter rest time
live_loop :BassAttackFast do
  
  use_random_seed Time.now.to_i / 5
  use_bpm [40,120,240,480].choose
  
  with_fx [:whammy,:echo].tick do
    sample :perc_snap if spread(2,3).reverse
    sample :bd_klub if spread(5,6).tick
    with_fx :bitcrusher, bits: rrand(0,16) do
      sample :elec_blup if spread(4,7).tick
      with_fx :slicer, phase: rrand(0,16) do
        sample :elec_blip if spread(1,2).tick
        sleep [1,2,4,8].tick
      end
    end
  end
  
end

#give that piano feeling
live_loop :piano do
  use_random_seed Time.now.to_i / 3
  use_bpm [40,120,240,480].choose
  
  with_fx :ping_pong, mix: rrand(0.25,0.76) do
    with_fx :echo do
      use_synth :pretty_bell
      bellTime = (scale :f3, :major).reverse
      play bellTime if (spread 10,24).tick
      sleep [1,2,4,8].tick
    end
  end
end


```ruby