Hey there,
first post! Nice to be here.
Let’s get down to it:
I am programming a circular sequencer for norns and need help with the drawing of the circular step “bars” (I have included the link to a picture to illustrate what I mean).
What already sort of works in the code below is drawing the dots in a circle that are used to select single steps. What I’ve been trying to do now is to have each note be represented by a step bar that starts halfway to the previous point selected by the step selector and ends halfway to the next (think like the outlines of a pie sliced into 16 pieces). The user is then supposed to be able to move the respective step bar up and down while it still adheres to the correct rotation in line with the circle.
I’ve been trying to crack this by making a grid with a finer resolution that the script can align the start and end points of the bars with (so like the for loop that fills in the step selector dots but with the number of radians quadrupled). However this kept tying knots into my brain and I lost track of what is what.
Can anyone help?
Cheers!
Design Reference:
Picture
Code
function init()
-- Initialize arrays & vars needed for circles
circle_x_vals = {}
circle_y_vals = {}
circle_radius = 0.75
-- Fill in 16 points on the circle for selector dots
for i=1, 16 do
local c = 360 * (i / 16)
circle_x_vals[i] = math.floor((circle_radius * math.sin( math.rad(c)) *20) + 64)
circle_y_vals[i] = math.floor((circle_radius * math.cos( math.rad(c)) *20) + 32)
end
selected_step = 1
light_up_sel_step = 9 -- Init var for brighter selected step
bigger_sel_step = 1 -- Init var for bigger selected step
end
function redraw()
screen.clear()
screen.aa(0)
--Draw step selector dots in a circle
for i=1, 16 do
sel_s = 1
sel_l = 1
if selected_step == i then
sel_l = sel_l + light_up_sel_step
sel_s = sel_s + bigger_sel_step
end
screen.rect(circle_x_vals[i],circle_y_vals[i],sel_s,sel_s)
-- Make step that is selected stand out
screen.level(sel_l)
screen.fill()
end
-- Draw step bars
screen.update()
end
function enc (n,d)
-- Make the 1st encoder move the step selection and handle 1&16
if n == 2 then
selected_step = selected_step + d
if selected_step > 16 then
selected_step = 1
elseif selected_step < 1 then
selected_step = 16
end
end
if n == 3 then
note_seq[selected_step] = note_seq[selected_step] + (d*0.1)
end
redraw()
end