Sha256: 7ac02239a539445b8936649a2eb7d8f15be68576a3353c528360f91f0b57a3ac

Contents?: true

Size: 1.26 KB

Versions: 21

Compression:

Stored size: 1.26 KB

Contents

require 'squib'

Squib::Deck.new(cards: 2) do
  background color: :white
  # If you really need something custom-made, the underlying cairo context
  # can be accessed directly via each Squib::Card
  #
  # WARNING! Input validation is not done on Squib::Cards. Proceed at your own risk.

  # The recommended approach is to use Deck's Enumerable, which iterates over Squib::Cards
  # I also recommend wrapping it in a Cairo save/restore, which Squib calls "use_cairo"
  each do |card|
    card.use_cairo do |cairo_context|
      cairo_context.set_source_color(:blue)
      cairo_context.circle(150, 150, 150)
      cairo_context.fill
    end
  end

  # Or the square bracket accessors []
  self[1].use_cairo do |cairo_context|
    cairo_context.circle(50, 50, 50)
    cairo_context.set_source_color(:red)
    cairo_context.fill
  end

  # Or modify the coordinate system for all (most?) future calls
  # Could be handy for a dynamic bleed
  each do |card|
    # note how this does NOT use save/restore.
    # again... this "feature" lives in the Land of Undefined Behavior
    card.cairo_context.translate(500, 500)
  end
  rect x: 0, y: 0, # actually 500, 500
       width: 50, height: 50, fill_color: :red


  save_png prefix: 'cairo_access_'
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
squib-0.18.0 samples/images/_cairo_access.rb
squib-0.17.2 samples/images/_cairo_access.rb
squib-0.17.1 samples/images/_cairo_access.rb
squib-0.17.0 samples/images/_cairo_access.rb
squib-0.16.0 samples/images/_cairo_access.rb
squib-0.16.0.pre.preview2 samples/images/_cairo_access.rb
squib-0.16.0.pre.preview1 samples/images/_cairo_access.rb
squib-0.15.3 samples/images/_cairo_access.rb
squib-0.15.0 samples/images/_cairo_access.rb
squib-0.14.3.pre1 samples/images/_cairo_access.rb
squib-0.14.1 samples/images/_cairo_access.rb
squib-0.14.0 samples/images/_cairo_access.rb
squib-0.14.beta1 samples/images/_cairo_access.rb
squib-0.13.4 samples/images/_cairo_access.rb
squib-0.13.3 samples/images/_cairo_access.rb
squib-0.13.2 samples/images/_cairo_access.rb
squib-0.13.1 samples/images/_cairo_access.rb
squib-0.13.0 samples/images/_cairo_access.rb
squib-0.12.0 samples/cairo_access.rb
squib-0.11.0 samples/cairo_access.rb