Project

gtk2svg

0.0
No commit activity in last 3 years
No release in over 3 years
Renders SVG using GTK2
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.3, >= 0.3.2
~> 3.3, >= 3.3.2
~> 0.4, >= 0.4.4
 Project Readme

Gtk2SVG: An onmousedown example

require 'gtk2svg'


s =<<SVG
<svg width="400" height="110">
  <script>
    def hello()
      puts 'hello world'
    end
  </script>
  <rect width="300" height="100" onmousedown="hello()" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
</svg>
SVG

app = Gtk2SVG::Main.new s, irb: true

In the above example when the left mouse button is pressed while over the blue rectangle, the message 'hello world' is displayed in the command-line.


Experimenting with creating an SVG app using the Gtk2SVG gem

#!/usr/bin/env ruby

# file: draw3.rb

require 'gtk2svg'

s =<<SVG
<svg width="400" height="110">
  <rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
  <rect x="100" y="100" width="100" height="100" style="fill:rgb(255,0,0);stroke-width:3;stroke:rgb(0,0,0)" />
</svg>
SVG

a = Gtk2SVG::Render.new(s).to_a

area = Gtk::DrawingArea.new

area.signal_connect("expose_event") do

  drawing = Gtk2SVG::DrawingInstructions.new area
  drawing.render a

end

Gtk::Window.new.add(area).show_all
Gtk.main

The above example creates a GTK2 application which can parse and render SVG. Below is a screenshot of the application.

Screenshot of the SVG rendered in a GTK2 application

Resources

gtk2 drawing svg gtk2svg gem