There exists this vanilla processing example, which is ideal for our degree sin/cos lookup tables (and a more functional approach in ruby processing using lambda). Basically if you can do the math then I think you should (rather than hide behind dubious vanilla processing map/normalize utility they are not helping you they are hindering your brain).
load_library :fastmath
def setup
size 200, 200
stroke 255
smooth 8
end
def draw
background 0
fill 80
no_stroke
clock_x = ->(val, adj, length){DegLut.cos((val * adj).to_i - 90) * length + width / 2}
clock_y = ->(val, adj, length){DegLut.sin((val * adj).to_i - 90) * length + height / 2}
ellipse 100, 100, 160, 160
stroke 220
stroke_weight 6
line( 100, 100, clock_x.call(hour % 12 + (minute / 60.0), 30, 50), clock_y.call(hour % 12 + (minute / 60.0), 30, 50) )
stroke_weight 3
line( 100, 100, clock_x.call(minute + (second / 60.0), 6, 60), clock_y.call(minute + (second / 60.0), 6, 60) )
stroke 255, 0, 0
stroke_weight 1
line( 100, 100, clock_x.call(second, 6, 72), clock_y.call(second, 6, 72) )
stroke_weight 2
stroke 255
(0..360).step(6) do |a|
x = 100 + DegLut.cos(a) * 72
y = 100 + DegLut.sin(a) * 72
point x, y
end
end
No comments:
Post a Comment