[cairo-commit] rcairo/tests ps,NONE,1.1
Evan Martin
commit at pdx.freedesktop.org
Wed Nov 19 10:51:53 PST 2003
Committed by: martine
Update of /cvs/cairo/rcairo/tests
In directory pdx:/tmp/cvs-serv21675/tests
Added Files:
ps
Log Message:
Update cairo.h parser to properly handle structs with exposed members, which
recently appeared in Cairo CVS.
(Unfortunately, this means I'll have to write my own getters/setters for each
member. I think I'll wait for the API to settle.)
Add a "ps" test that generates a simple postscript file (mostly to verify my
understanding of the mapping from C's FILE* to Ruby's File objects).
--- NEW FILE: ps ---
#!/usr/bin/env ruby
# vim: set ts=2 sw=2 et :
$LOAD_PATH << "../src"
require 'cairo'
cr = Cairo::Cairo.new
# tweak these:
SIZE = 4
DPI = 200
FILENAME = 'ps.ps'
# derived constants:
PIXELS = SIZE * DPI
MARGIN = PIXELS/40
File.open(FILENAME, "w") { |f|
cr.set_target_ps(f, SIZE, SIZE, DPI, DPI)
cr.set_rgb_color(0,0,0)
cr.line_cap = Cairo::LineCap::ROUND
cr.line_width = PIXELS/40
cr.stroke {
cr.move_to(MARGIN, MARGIN)
cr.line_to(PIXELS-MARGIN, PIXELS-MARGIN)
}
cr.show_page
}
puts "wrote #{SIZE}x#{SIZE}in, #{DPI}dpi image to #{FILENAME}."
More information about the cairo-commit
mailing list