Created
April 18, 2013 15:12
-
-
Save quephird/5413504 to your computer and use it in GitHub Desktop.
My first somewhat complex sketch using the ruby-processing library, https://github.com/jashkenas/ruby-processing. The output is here: http://quephird.deviantart.com/art/fire-blossom-clone-draft-2-366332642
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'ruby-processing' | |
class FireBlossom < Processing::App | |
@@width = 1980 | |
@@height = 1024 | |
@@blossom_colors = [[63,7,0],[102,35,9],[142,20,0],[197,70,3],[189,125,1],[223,222,106],[190,237,229],[132,139,62]] | |
def setup | |
size @@width,@@height | |
background 0 | |
no_loop | |
end | |
def f (r, t) | |
r + r*sin(5.0*t)/10.0 + r*sin(50.0*t)/10 | |
end | |
def blossom_ring_segment (r, t, dt) | |
f1 = f(r,t) | |
x1 = f1*cos(t) | |
y1 = f1*sin(t) | |
f2 = f(r,t+dt) | |
x2 = f2*cos(t+dt) | |
y2 = f2*sin(t+dt) | |
line x1,y1,x2,y2 | |
end | |
def blossom_ring (r, c) | |
stroke *c | |
dt = Math::PI/360 | |
(0..2*Math::PI).step(dt).each {|t| blossom_ring_segment r, t, dt} | |
end | |
def draw | |
translate @@width/2,@@height/2 | |
stroke_width 2 | |
(0..1000).each {|r| blossom_ring r, @@blossom_colors[(r/30)%@@blossom_colors.length]} | |
save "fire_blossom.png" | |
end | |
end | |
FireBlossom.new :title => "fire blossom" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment