Tim H. wrote:
Justin Bl wrote:
Ruby version: 1.8.6
ImageMagick Version: 6.5.3 Q8
Rmagick Version: rmagick-2.10.0-x86-mswin32
OS: Windows Vista
I don’t think the problem is with the from_hsla method. This produces a
nice sorta lime-green 200x200 image for me. Why don’t you post a
complete script that reproduces the problem?
irb(main):001:0> p = Magick::Pixel.from_hsla(80, 100, 50, 1)
=> red=170, green=255, blue=0, opacity=0
irb(main):002:0> img = Magick::Image.new(200,200) {
self.background_color = p}
=> 200x200 DirectClass 8-bit
irb(main):003:0> img.display
=> 200x200 DirectClass 8-bit
Tim,
Full source code is below:
require ‘rubygems’
require ‘rvg/rvg’
include Magick
class MyImage
def initialize (job_id, width, height)
@job_id = job_id.to_s;
@width = width.to_i;
@height = height.to_i;
@canvas = Magick::Image.new(@width, @height)
#@canvas.colorspace = HSLColorspace
@canvas.background_color = Magick::Pixel.from_hsla(80, 100, 50, 1)
#it will make the pixel but it will not make it the right color
end
def draw ()
choose random color and put it in a pixel
#@canvas.each_pixel {|pixel, c, r|
#ind = rand(5)
#pixel = $colors[ind]
#}
#@canvas.pixel_color(x, y[, new_color]) -> pixel
end
def finalize (type=“gif”)
@canvas.write("#{@job_id}.#{type}")
end
end
x = 500
y = 500
increm = 360/5
$colors = Array.new
$colors = [
[0,100,50,1],
[72,100,50,1],
[144,100,50,1],
[216,100,50,1],
[288,100,50,1]
]
initial array is just the h s l a values
$colors = $colors.map { |xx| Magick::Pixel.from_hsla(xx[0], xx[1],
xx[2], x[3]) }
convert it to array of pixels
puts $colors[0].class
img = MyImage.new(“hsl_test”, x, y)
img.draw()
img.finalize(‘png’)