tags:

views:

176

answers:

1

Hi dear community!

I need draw some lines/circles/rect/etc from ruby into something like canvas.

I tried wxRuby and fxRuby but they are have no good examples to draw simple lines.

Just tried to install qtruby on Windows and its fall cause of some number of errors.

So:

1) Which API for ruby to draw on canvas I need? 2) Give me a little sample of it (full code please)?

Sincerely Eugene

+1  A: 

So, it was interesting.

I'm using NetBeans IDE, with inbuilt JRuby interpreter.

JRuby.org - it's a pure implementation of Ruby in Java, also you can call java methods.

So I decided to use Java GUI instead some other wrapper.


Here is an example of code:

require 'java'

W=800 H=600

frame = javax.swing.JFrame.new("Window")

frame.setDefaultCloseOperation(javax.swing.JFrame::EXIT_ON_CLOSE) frame.pack frame.setVisible(true) frame.setSize(W,H) frame.graphics.setColor(java.awt.Color.cyan) frame.graphics.drawLine(0,0,100,100)

Eugene
some addition samples of calling Java from Rubyhttp://kenai.com/projects/jruby/pages/CallingJavaFromJRuby
Eugene