How do I see a sample RMagick drawing? Help, Please!

Team,

I copied two drawings, one from The Ruby Way 2nd edition and one from
the
RMagick website.
I try to run the pgms but I get nothing. I mean nothing, no errors, I
just
get the cursor back.

The first sample (The Ruby Way 2nd edition), and which I named
magia01.rbfollows:

I run this pgm by typing: ruby magia01.rb. This is under MS Windows
XP.

require ‘RMagick’

img = Magick::ImageList.new
img.new_image(500, 500)

purplish = “#ff55ff
yuck = “#5fff62
bleah = “#3333ff

line = Magick::Draw.new
50.step(450, 50) do |n|
line.line(n,50, n,450)
line.draw(img)
line.line(50,n, 450,n)
line.draw(img)
end

Draw circle

cir = Magick::Draw.new
cir.fill(purplish)
cir.stroke(‘black’).stroke_width(1)
cir.circle(250,200, 250,310)
cir.draw(img)

#Draw rectangle
rect = Magick::Draw.new
rect.stroke(‘black’).stroke_width(1)
rect.fill(yuck)
rect.rectangle(340,380, 237,110)
rect.draw(img)

#Draw triangle
tri = Magick::Draw.new
tri.stroke(‘black’).stroke_width(1)
tri.fill(bleah)
tri.polygon(90,320,160,370,390,120)
tri.draw(img)

img = img.quantize(256,Magick::GRAYColorspace)

img.write(“drawing.gif”)

Any help will be appreciated.

Thank you

Victor

Victor R. wrote:

Team,

I copied two drawings, one from The Ruby Way 2nd edition and one from the
RMagick website.
I try to run the pgms but I get nothing. I mean nothing, no errors, I just
get the cursor back.

The programs don’t display the image, they just create it. All you have
to do is open the file “drawing.gif” with any image viewing program. Use
Internet Explorer, for example, or Paint.

Tim,

That worked fine.

One thing, I can’t see the colors. The image appears to be in black and
white (it goes from light dark to very dark).
I played with the colors but I never see any color.

Again, thank you for your help

Victor

That’s because you’re using the GRAYColorspace. You need to use
something else.

–Jeremy

On Jan 20, 2008 9:12 PM, Victor R. [email protected] wrote:

Victor

I try to run the pgms but I get nothing. I mean nothing, no errors, I
RMagick 2: http://rmagick.rubyforge.org/rmagick2.html


http://www.jeremymcanally.com/

My books:
Ruby in Practice

My free Ruby e-book

My blogs:

http://www.rubyinpractice.com/

Jeremy,

Thank you for the info.

Victor

No problem. Very easy to overlook. :slight_smile:

–Jeremy

On Jan 20, 2008 9:28 PM, Victor R. [email protected] wrote:

else.

I played with the colors but I never see any color.

The programs don’t display the image, they just create it. All you

My free Ruby e-book
http://www.humblelittlerubybook.com/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/


http://www.jeremymcanally.com/

My books:
Ruby in Practice

My free Ruby e-book

My blogs:

http://www.rubyinpractice.com/

… and, to compound my problem, this is the very first time I play with
RMagick.
It is actually very nice! I hope to learn it well.

Thanks again,

Victor