Skip to content

Commit

Permalink
stargazer mode
Browse files Browse the repository at this point in the history
  • Loading branch information
echophon committed Sep 5, 2020
1 parent 70b4022 commit 550e209
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 84 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# barycenter

barycenter: fluctuating relationships
v0.1.0 @echophon
v0.1.1 @echophon

ENC 1 - offset horizon

Expand All @@ -15,4 +15,4 @@ KEY 3 - cycle speed focus

a script for Norns loosely based on the motion of celestial bodies https://en.wikipedia.org/wiki/Barycenter

two bodies rotate around a central point, two rotate around those, two rotate around those to create 8 visible bodies. as the visible bodies cross the horizon notes are struck and sound is made. symmetry is maintained at a horizon of zero, offsetting the horizon allows for asymmetry
two bodies rotate around a central point, two rotate around those, & two more rotate around those to create 8 visible bodies. as the visible bodies cross the horizon notes are struck and sound is made. symmetry is maintained at a horizon of zero, offsetting the horizon allows for asymmetry
130 changes: 48 additions & 82 deletions barycenter.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- barycenter: fluctuating relationships
--
-- v0.1.0 @echophon
-- v0.1.1 @echophon
--
-- ENC 1 - offset horizon
-- ENC 2 - adjust space
Expand All @@ -12,32 +12,34 @@
engine.name = 'PolyPerc'

viewport = { width = 128, height = 64 }
inner = { space = 2+math.random(2,20), speed = math.random(1,10)*0.01 }
middle = { space = 2+math.random(2,20), speed = math.random(1,10)*0.01 }
outer = { space = 2+math.random(2,20), speed = math.random(1,10)*0.01 }

innerOrbit = {{x=0,y=0,spaceOffset=0,speedOffset=1}
,{x=0,y=0,spaceOffset=0,speedOffset=1}}

middleOrbit= {{x=0,y=0,spaceOffset=0,speedOffset=1}
,{x=0,y=0,spaceOffset=0,speedOffset=1}
,{x=0,y=0,spaceOffset=0,speedOffset=1}
,{x=0,y=0,spaceOffset=0,speedOffset=1}}

outerOrbit = {{x=0,y=0,spaceOffset=0,speedOffset=1,dirty=0}
,{x=0,y=0,spaceOffset=0,speedOffset=1,dirty=0}
,{x=0,y=0,spaceOffset=0,speedOffset=1,dirty=0}
,{x=0,y=0,spaceOffset=0,speedOffset=1,dirty=0}
,{x=0,y=0,spaceOffset=0,speedOffset=1,dirty=0}
,{x=0,y=0,spaceOffset=0,speedOffset=1,dirty=0}
,{x=0,y=0,spaceOffset=0,speedOffset=1,dirty=0}
,{x=0,y=0,spaceOffset=0,speedOffset=1,dirty=0}}
inner = { space = 2+math.random(2,20), speed = math.random(1,10)*0.01, dirty=0 }
middle = { space = 2+math.random(2,20), speed = math.random(1,10)*0.01, dirty=0 }
outer = { space = 2+math.random(2,20), speed = math.random(1,10)*0.01, dirty=0 }

innerOrbit = {{x=0,y=0}
,{x=0,y=0}}

middleOrbit= {{x=0,y=0}
,{x=0,y=0}
,{x=0,y=0}
,{x=0,y=0}}

outerOrbit = {{x=0,y=0,dirty=0}
,{x=0,y=0,dirty=0}
,{x=0,y=0,dirty=0}
,{x=0,y=0,dirty=0}
,{x=0,y=0,dirty=0}
,{x=0,y=0,dirty=0}
,{x=0,y=0,dirty=0}
,{x=0,y=0,dirty=0}}

spaceFocus = 0
speedFocus = 0
frame = 0
horizon = 32
txt = 'hello'
drawOrbits = 0
editCounter= 0

function draw_circle(x, y, r, l)
screen.level(l)
Expand Down Expand Up @@ -73,92 +75,51 @@ function key(id,state)
txt = 'middleSpace'
elseif spaceFocus == 2 then
txt = 'outerSpace'
-- elseif spaceFocus == 2 then
-- txt = 'innerOffSpace1'
-- elseif spaceFocus == 3 then
-- txt = 'innerOffSpace2'
-- elseif spaceFocus == 4 then
-- txt = 'outerOffSpace1'
-- elseif spaceFocus == 5 then
-- txt = 'outerOffSpace2'
end
elseif id == 3 and state == 1 then
speedFocus = (speedFocus + 1)%3
if speedFocus == 0 then
txt = 'innerSpeed'
-- elseif speedFocus == 1 then
-- txt = 'innerMult1'
-- elseif speedFocus == 2 then
-- txt = 'innerMult2'
elseif speedFocus == 1 then
txt = 'middleSpeed'
elseif speedFocus == 2 then
txt = 'outerSpeed'
-- elseif speedFocus == 4 then
-- txt = 'outerMult1'
-- elseif speedFocus == 5 then
-- txt = 'outerMult2'
-- elseif speedFocus == 6 then
-- txt = 'outerMult3'
-- elseif speedFocus == 7 then
-- txt = 'outerMult4'
end
end
end

function enc(id,delta)
if id == 2 and spaceFocus == 0 then
inner.space = util.clamp(inner.space + (delta*0.1),2,50)
editCounter = 0
drawOrbits = 1
txt = inner.space
elseif id == 2 and spaceFocus == 1 then
middle.space = util.clamp(middle.space + (delta*0.1),2,50)
editCounter = 0
drawOrbits = 1
txt = middle.space
elseif id == 2 and spaceFocus == 2 then
outer.space = util.clamp(outer.space + (delta*0.1),2,50)
editCounter = 0
drawOrbits = 1
txt = outer.space
-- elseif id == 2 and spaceFocus == 2 then
-- inOrbit[1].spaceOffset = util.clamp(inOrbit[1].spaceOffset + (delta*0.1),-10,10)
-- txt = inOrbit[1].spaceOffset
-- elseif id == 2 and spaceFocus == 3 then
-- inOrbit[2].spaceOffset = util.clamp(inOrbit[2].spaceOffset + (delta*0.1),-10,10)
-- txt = inOrbit[2].spaceOffset
-- elseif id == 2 and spaceFocus == 4 then
-- outerOrbit[1].spaceOffset = util.clamp(outerOrbit[1].spaceOffset + (delta*0.1),-10,10)
-- outerOrbit[2].spaceOffset = util.clamp(outerOrbit[2].spaceOffset + (delta*0.1),-10,10)
-- txt = inOrbit[1].spaceOffset
-- elseif id == 2 and spaceFocus == 5 then
-- outerOrbit[3].spaceOffset = util.clamp(outerOrbit[3].spaceOffset + (delta*0.1),-10,10)
-- outerOrbit[4].spaceOffset = util.clamp(outerOrbit[4].spaceOffset + (delta*0.1),-10,10)
-- txt = inOrbit[1].spaceOffset

elseif id == 3 and speedFocus == 0 then
inner.speed = util.clamp(inner.speed + (delta*0.01),-20,20)
editCounter = 0
drawOrbits = 1
txt = inner.speed
-- elseif id == 3 and speedFocus == 1 then
-- inOrbit[1].speedOffset = util.clamp(inOrbit[1].speedOffset + (delta*0.1),-2,2)
-- txt = inOrbit[1].speedOffset
-- elseif id == 3 and speedFocus == 2 then
-- inOrbit[2].speedOffset = util.clamp(inOrbit[2].speedOffset + (delta*0.1),-2,2)
-- txt = inOrbit[2].speedOffset

elseif id == 3 and speedFocus == 1 then
middle.speed = util.clamp(middle.speed + (delta*0.01),-20,20)
editCounter = 0
drawOrbits = 1
txt = middle.speed
elseif id == 3 and speedFocus == 2 then
outer.speed = util.clamp(outer.speed + (delta*0.01),-20,20)
editCounter = 0
drawOrbits = 1
txt = outer.speed
-- elseif id == 3 and speedFocus == 4 then
-- outerOrbit[1].speedOffset = util.clamp(outerOrbit[1].speedOffset + (delta*0.1),-2,2)
-- txt = outerOrbit[1].speedOffset
-- elseif id == 3 and speedFocus == 5 then
-- outerOrbit[2].speedOffset = util.clamp(outerOrbit[2].speedOffset + (delta*0.1),-2,2)
-- txt = outerOrbit[2].speedOffset
-- elseif id == 3 and speedFocus == 6 then
-- outerOrbit[3].speedOffset = util.clamp(outerOrbit[3].speedOffset + (delta*0.1),-2,2)
-- txt = outerOrbit[3].speedOffset
-- elseif id == 3 and speedFocus == 7 then
-- outerOrbit[4].speedOffset = util.clamp(outerOrbit[4].speedOffset + (delta*0.1),-2,2)
-- txt = outerOrbit[4].speedOffset

elseif id == 1 then
horizon = util.clamp(horizon + delta,4,60)
Expand All @@ -172,17 +133,18 @@ function redraw()
draw_horizon(horizon)
draw_text(txt)

--inner inner
draw_circle(viewport.width/2, viewport.height/2, inner.space, drawOrbits)

--inner
-- draw_circle(innerOrbit[1].x, innerOrbit[1].y, middle.space,1)
-- draw_circle(innerOrbit[2].x, innerOrbit[2].y, middle.space,1)
-- draw_circle(innerOrbit[1].x + outerOrbit[1].spaceOffset,innerOrbit[1].y + outerOrbit[1].spaceOffset,outer.space,1)
-- draw_circle(innerOrbit[2].x + outerOrbit[2].spaceOffset,innerOrbit[2].y + outerOrbit[1].spaceOffset,outer.space,1)
draw_circle(innerOrbit[1].x, innerOrbit[1].y, middle.space, drawOrbits)
draw_circle(innerOrbit[2].x, innerOrbit[2].y, middle.space, drawOrbits)

--middle
draw_circle(middleOrbit[1].x, middleOrbit[1].y, outer.space,1)
draw_circle(middleOrbit[2].x, middleOrbit[2].y, outer.space,1)
draw_circle(middleOrbit[3].x, middleOrbit[3].y, outer.space,1)
draw_circle(middleOrbit[4].x, middleOrbit[4].y, outer.space,1)
draw_circle(middleOrbit[1].x, middleOrbit[1].y, outer.space, drawOrbits)
draw_circle(middleOrbit[2].x, middleOrbit[2].y, outer.space, drawOrbits)
draw_circle(middleOrbit[3].x, middleOrbit[3].y, outer.space, drawOrbits)
draw_circle(middleOrbit[4].x, middleOrbit[4].y, outer.space, drawOrbits)

--outer
draw_circle(outerOrbit[1].x,outerOrbit[1].y,1+outerOrbit[1].dirty,15)
Expand Down Expand Up @@ -229,6 +191,10 @@ re = metro.init()
re.time = 0.01
re.event = function()
frame = frame + 1
editCounter = editCounter + 1
if editCounter > 50 then
drawOrbits = 0
end

--inner
innerOrbit[1].x = viewport.width/2 + (math.cos(frame * (inner.speed) * 0.01) * inner.space)
Expand Down

0 comments on commit 550e209

Please sign in to comment.