[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

question about transparent image RMAGIK

shawn bright

2/6/2008 3:10:00 PM

Hello there all,
i have a simple function to draw an image, but i cannot for the life
of me figgure out from the docs how to make it about 20% transparent.

def circle_image(zoom)
site = self.site
zoomhash = {13 => 0.5, 14 => 1, 15 => 2, 16 => 4}
r = (self.radius.to_f * zoomhash[zoom.to_i].to_f)
canvas = Magick::Image.new((2 * r), (2*r),
Magick::HatchFill.new('transparent', 'transparent'))
gc = Magick::Draw.new
# for the outside perimeter of the circle
gc.stroke('black')
gc.stroke_width(1)
# fill in the inside
color = KeyWord.stat_description(site.status_sensor.last_value)[1]
gc.fill(color)
gc.circle(r, r, 0, r)
image = gc.draw(canvas)
canvas.write("public/images/tmp/#{site.id}.png")
end

please help, thanks

shawn

2 Answers

Tim Hunter

2/6/2008 3:27:00 PM

0

Shawn Bright wrote:
> Hello there all,
> i have a simple function to draw an image, but i cannot for the life
> of me figgure out from the docs how to make it about 20% transparent.
>
> def circle_image(zoom)
> site = self.site
> zoomhash = {13 => 0.5, 14 => 1, 15 => 2, 16 => 4}
> r = (self.radius.to_f * zoomhash[zoom.to_i].to_f)
> canvas = Magick::Image.new((2 * r), (2*r),
> Magick::HatchFill.new('transparent', 'transparent'))
> gc = Magick::Draw.new
> # for the outside perimeter of the circle
> gc.stroke('black')
> gc.stroke_width(1)
> # fill in the inside
> color = KeyWord.stat_description(site.status_sensor.last_value)[1]
> gc.fill(color)
> gc.circle(r, r, 0, r)
> image = gc.draw(canvas)
> canvas.write("public/images/tmp/#{site.id}.png")
> end
>
> please help, thanks
>
> shawn

Do you want to make the entire image 20% transparent? Use the
Image#opacity= attribute
[http://studio.imagemagick.org/RMagick/doc/imageattrs.ht...].

Do you want to make the drawing 20% transparent so that the drawn-upon
image shows through? See the Draw#stroke_opacity
[http://studio.imagemagick.org/RMagick/doc/draw.html#stro...] and
Draw#fill_opacity
[http://studio.imagemagick.org/RMagick/doc/draw.html#fi...]
methods.

Also check out the example drawing here
[http://studio.imagemagick.org/RMagick/doc/usage.html#...].
--
Posted via http://www.ruby-....

shawn bright

2/6/2008 3:47:00 PM

0

fill_opacity was what i was looking for,
thanks very much.

shawn

On Feb 6, 2008 9:27 AM, Tim Hunter <rmagick@gmail.com> wrote:
> Shawn Bright wrote:
> > Hello there all,
> > i have a simple function to draw an image, but i cannot for the life
> > of me figgure out from the docs how to make it about 20% transparent.
> >
> > def circle_image(zoom)
> > site = self.site
> > zoomhash = {13 => 0.5, 14 => 1, 15 => 2, 16 => 4}
> > r = (self.radius.to_f * zoomhash[zoom.to_i].to_f)
> > canvas = Magick::Image.new((2 * r), (2*r),
> > Magick::HatchFill.new('transparent', 'transparent'))
> > gc = Magick::Draw.new
> > # for the outside perimeter of the circle
> > gc.stroke('black')
> > gc.stroke_width(1)
> > # fill in the inside
> > color = KeyWord.stat_description(site.status_sensor.last_value)[1]
> > gc.fill(color)
> > gc.circle(r, r, 0, r)
> > image = gc.draw(canvas)
> > canvas.write("public/images/tmp/#{site.id}.png")
> > end
> >
> > please help, thanks
> >
> > shawn
>
> Do you want to make the entire image 20% transparent? Use the
> Image#opacity= attribute
> [http://studio.imagemagick.org/RMagick/doc/imageattrs.ht...].
>
> Do you want to make the drawing 20% transparent so that the drawn-upon
> image shows through? See the Draw#stroke_opacity
> [http://studio.imagemagick.org/RMagick/doc/draw.html#stro...] and
> Draw#fill_opacity
> [http://studio.imagemagick.org/RMagick/doc/draw.html#fi...]
> methods.
>
> Also check out the example drawing here
> [http://studio.imagemagick.org/RMagick/doc/usage.html#...].
> --
> Posted via http://www.ruby-....
>
>