Sha256: 6763ebbd501c926230ca15e8629eea324fdc117930b357b06a0dde8938c93a79
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
require 'forwardable' require 'squib/graphics/gradient_regex' module Squib module Graphics class CairoContextWrapper extend Forwardable attr_accessor :cairo_cxt def initialize(cairo_cxt) @cairo_cxt = cairo_cxt end def_delegators :cairo_cxt, :save, :set_source_color, :paint, :restore, :translate, :rotate, :move_to, :update_pango_layout, :width, :height, :show_pango_layout, :rounded_rectangle, :set_line_width, :stroke, :fill, :set_source, :scale, :render_rsvg_handle, :circle, :triangle, :line_to, :operator=, :show_page, :clip, :transform, :mask, :create_pango_layout, :antialias= def set_source_squibcolor(arg) if match = arg.match(LINEAR_GRADIENT) x1, y1, x2, y2 = match.captures linear = Cairo::LinearPattern.new(x1.to_f, y1.to_f, x2.to_f, y2.to_f) arg.scan(STOPS).each do |color, offset| linear.add_color_stop(offset.to_f, color) end @cairo_cxt.set_source(linear) elsif match = arg.match(RADIAL_GRADIENT) x1, y1, r1, x2, y2, r2 = match.captures linear = Cairo::RadialPattern.new(x1.to_f, y1.to_f, r1.to_f, x2.to_f, y2.to_f, r2.to_f) arg.scan(STOPS).each do |color, offset| linear.add_color_stop(offset.to_f, color) end @cairo_cxt.set_source(linear) else @cairo_cxt.set_source_color(arg) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
squib-0.4.0 | lib/squib/graphics/cairo_context_wrapper.rb |