Question

How to set an arbitrary HSLA color instead of gray20?

draw = Magick::Draw.new
draw.font_family = 'arial'
draw.pointsize = 12
draw.gravity = Magick::CenterGravity
draw.annotate(@canvas, size,size, x,y, text) { self.fill = 'gray20' }

Also, using gc.rectangle, how to set the HSLA color of the fill?

gc = Magick::Draw.new
gc.fill ????
gc.rectangle(x,y, x + size,y + size)
Was it helpful?

Solution

From the RMagick documentation:

Many RMagick methods expect color name arguments or return color names. A color name can be

  1. an X11 color name such as "red", "chocolate", or "lightslategray".
  2. an SVG color name (similar to the X color names), or
  3. a string in one of the formats shown in the following table.

...

hsla(h,s,l,a)

And HSL documentation

hsla(33.3333%, 100%, 50%, 1.0) green with an alpha value of 1.0

hsla(120, 255, 127.5, 1.0) green with an alpha value of 1.0

So, use a string: fill 'hsl(0%,100%,100%,1)'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top