Sha256: 8a4acffae59a951fc559329f10bf7e9cf8e0d5b46fd3f5c6c135164ac1d58eb0
Contents?: true
Size: 872 Bytes
Versions: 83
Compression:
Stored size: 872 Bytes
Contents
#!/usr/bin/env ruby require 'gtk2' require 'rsvg2' unless RSVG.cairo_available? puts "this sample needs RSVG with cairo support" exit(-1) end unless Gdk.cairo_available? puts "this sample needs GDK with cairo support" exit(-1) end if ARGV.size != 1 puts "usage: #{$0} input.svg" exit(-1) end input = ARGV.shift handle = RSVG::Handle.new_from_file(input) width, height = handle.dimensions.to_a window = Gtk::Window.new window.set_default_size(width, height) area = Gtk::DrawingArea.new window.signal_connect("destroy") do Gtk.main_quit end area.signal_connect("expose_event") do |widget, event| context = widget.window.create_cairo_context window_width, window_height = widget.window.size context.scale(window_width.to_f / width, window_height.to_f / height) context.render_rsvg_handle(handle) end window.add(area) window.show_all Gtk.main
Version data entries
83 entries across 83 versions & 1 rubygems
Version | Path |
---|---|
rsvg2-0.90.2.1 | sample/svg-viewer.rb |
rsvg2-0.90.2-x86-mingw32 | sample/svg-viewer.rb |
rsvg2-0.90.2 | sample/svg-viewer.rb |