Sha256: 550e9c45e0190666cf8c1773625e1c083051d494c268f8ba271c7c91881c31a7
Contents?: true
Size: 957 Bytes
Versions: 2
Compression:
Stored size: 957 Bytes
Contents
#!/usr/bin/env ruby top = File.expand_path(File.join(File.dirname(__FILE__), "..")) src = File.join(top, "src") $LOAD_PATH.unshift src $LOAD_PATH.unshift File.join(src, "lib") require 'cairo' width = 200 height = 200 data = nil stride = nil Cairo::ImageSurface.new(width, height) do |surface| cr = Cairo::Context.new(surface) # fill background with white cr.set_source_color("#fffc") 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_color(:black) cr.fill_preserve cr.set_source_color(:red) cr.set_line_join(Cairo::LINE_JOIN_MITER) cr.set_line_width(4) cr.stroke cr.target.write_to_png("test.png") data = cr.target.data stride = cr.target.stride end Cairo::ImageSurface.new(data, Cairo::FORMAT_ARGB32, width, height, stride) do |surface| surface.write_to_png("test-renew.png") end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cairo-1.5.1 | samples/png.rb |
cairo-1.5.0 | samples/png.rb |