From: shawn bright Date: 2008-02-07T00:47:20+09:00 Subject: Re: question about transparent image RMAGIK fill_opacity was what i was looking for, thanks very much. shawn On Feb 6, 2008 9:27 AM, Tim Hunter 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.html#opacity]. > > 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#stroke_opacity] and > Draw#fill_opacity > [http://studio.imagemagick.org/RMagick/doc/draw.html#fill_opacity] > methods. > > Also check out the example drawing here > [http://studio.imagemagick.org/RMagick/doc/usage.html#drawing_on]. > -- > Posted via http://www.ruby-forum.com/. > >