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

V

Victor Reyes

[Note: parts of this message were removed to make it a legal post.]

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.rb*follows:

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
 
T

Tim Hunter

Victor said:
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.
 
V

Victor Reyes

[Note: parts of this message were removed to make it a legal post.]

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
 
J

Jeremy McAnally

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

--Jeremy

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



--
http://www.jeremymcanally.com/

My books:
Ruby in Practice
http://www.manning.com/mcanally/

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

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

Victor Reyes

[Note: parts of this message were removed to make it a legal post.]

Jeremy,

Thank you for the info.

Victor
 
V

Victor Reyes

[Note: parts of this message were removed to make it a legal post.]

... 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

No problem. Very easy to overlook. :)

--Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top