Class: Doodler::Strategy
Instance Attribute Summary collapse
Instance Method Summary
collapse
#notify_complete, #notify_start
Constructor Details
#initialize(image) ⇒ Strategy
Returns a new instance of Strategy.
7
8
9
|
# File 'lib/doodler/strategy.rb', line 7
def initialize(image)
@image = image
end
|
Instance Attribute Details
#image ⇒ Object
Returns the value of attribute image.
5
6
7
|
# File 'lib/doodler/strategy.rb', line 5
def image
@image
end
|
Instance Method Details
#bubblize ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/doodler/strategy.rb', line 11
def bubblize
notify_start
50000.times do
centre = [rand(width), rand(height)] ; radius = rand(5)
color = ChunkyPNG::Color(image[centre[0], centre[1]])
left = [0, centre[0] - radius].max
right = [centre[0] + radius, (width-1)].min
up = [centre[1] + radius, (height-1)].min
down = [0, centre[1] - radius].max
(left..right).to_a.each do |x|
(down..up).to_a.each do |y|
image[x,y] = color if distance_from_centre(centre, x, y) <= radius
end
end
end
render
notify_complete
end
|
#cubify ⇒ Object
35
36
37
|
# File 'lib/doodler/strategy.rb', line 35
def cubify
end
|
#render ⇒ Object
43
44
45
|
# File 'lib/doodler/strategy.rb', line 43
def render
image.save("image/render/output.png")
end
|
#textify ⇒ Object
39
40
41
|
# File 'lib/doodler/strategy.rb', line 39
def textify
end
|