[cairo-commit] rcairo/samples pdf.rb, 1.3, 1.4 pdf2.rb, NONE,
1.1 png.rb, 1.8, 1.9 ps.rb, 1.2, 1.3 ps2.rb, NONE, 1.1
Kouhei Sutou
commit at pdx.freedesktop.org
Sat Oct 15 07:33:48 PDT 2005
Committed by: kou
Update of /cvs/cairo/rcairo/samples
In directory gabe:/tmp/cvs-serv12660/samples
Modified Files:
png.rb
Added Files:
pdf.rb pdf2.rb ps.rb ps2.rb
Log Message:
* packages/cairo/ext/rb_cairo_context.c: Use StringValuePtr
instead of STR2CSTR.
* packages/cairo/ext/rb_cairo_surface.c: Supported PS/PDF surface.
* samples/ps.rb, samples/ps2.rb: Added PS surface sample.
* samples/pdf.rb, samples/pdf2.rb: Added PDF surface sample.
--- NEW FILE: pdf2.rb ---
#!/usr/bin/env ruby
$LOAD_PATH.unshift "../packages/cairo/ext/"
$LOAD_PATH.unshift "../packages/cairo/lib/"
require 'cairo'
require 'stringio'
output = StringIO.new
surface = Cairo::PDFSurface.new(output, 200, 200)
cr = Cairo::Context.new(surface)
# fill background with white
cr.set_source_rgba(1.0, 1.0, 1.0, 0.8)
cr.paint
# create shape
cr.move_to(50, 50)
cr.curve_to(100, 25, 100, 75, 150, 50)
cr.line_to(150, 150)
cr.line_to(50, 150)
cr.close_path
cr.set_source_rgb(0.0, 0.0, 0.0)
cr.fill_preserve
cr.set_source_rgb(1.0, 0.0, 0.0)
cr.set_line_join(Cairo::LINE_JOIN_MITER)
cr.set_line_width(4)
cr.stroke
cr.show_page
cr.target.finish
output.rewind
File.open("test2.pdf", "wb") do |f|
f.print(output.read)
end
Index: png.rb
===================================================================
RCS file: /cvs/cairo/rcairo/samples/png.rb,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- png.rb 12 Oct 2005 14:58:52 -0000 1.8
+++ png.rb 15 Oct 2005 14:33:46 -0000 1.9
@@ -4,8 +4,9 @@
$LOAD_PATH.unshift "../packages/cairo/lib/"
require 'cairo'
-include Cairo
-cr=Context.new(ImageSurface.new(FORMAT_ARGB32, 200,200))
+
+surface = Cairo::ImageSurface.new(Cairo::FORMAT_ARGB32, 200, 200)
+cr = Cairo::Context.new(surface)
# fill background with white
cr.set_source_rgba(1.0, 1.0, 1.0, 0.8)
@@ -21,8 +22,10 @@
cr.set_source_rgb(0.0, 0.0, 0.0)
cr.fill_preserve
cr.set_source_rgb(1.0, 0.0, 0.0)
-cr.set_line_join(LINE_JOIN_MITER)
+cr.set_line_join(Cairo::LINE_JOIN_MITER)
cr.set_line_width(4)
cr.stroke
cr.target.write_to_png("test.png")
+
+cr.target.finish
--- NEW FILE: ps2.rb ---
#!/usr/bin/env ruby
$LOAD_PATH.unshift "../packages/cairo/ext/"
$LOAD_PATH.unshift "../packages/cairo/lib/"
require 'cairo'
require 'stringio'
output = StringIO.new
surface = Cairo::PSSurface.new(output, 200, 200)
cr = Cairo::Context.new(surface)
# fill background with white
cr.set_source_rgba(1.0, 1.0, 1.0, 0.8)
cr.paint
# create shape
cr.move_to(50, 50)
cr.curve_to(100, 25, 100, 75, 150, 50)
cr.line_to(150, 150)
cr.line_to(50, 150)
cr.close_path
cr.set_source_rgb(0.0, 0.0, 0.0)
cr.fill_preserve
cr.set_source_rgb(1.0, 0.0, 0.0)
cr.set_line_join(Cairo::LINE_JOIN_MITER)
cr.set_line_width(4)
cr.stroke
cr.show_page
cr.target.finish
output.rewind
File.open("test2.ps", "wb") do |f|
f.print(output.read)
end
More information about the cairo-commit
mailing list