27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/picss/css_writer.rb', line 27
def self.convert(image, options={})
box_shadows = Array.new
image.height.times do |y|
image.height.times do |x|
pixel = image.get_pixel(x, y)
if pixel != 0
box_shadows.push(Mustache.render @@pixel_template, {
x: x + options[:scale],
y: y + options[:scale],
color: ColorConverter.hex_to_rgba(pixel.to_s(16).rjust(8, '0'))
})
end
end
end
options[:box_shadows] = box_shadows.join(",\n")
options[:height] = image.height
options[:width] = image.width
Mustache.render @@template, options
end
|