Sha256: 9b80547be55d1facd1a953d84bb591ddc9b30f7baeb61289a9087bf04edc3259

Contents?: true

Size: 832 Bytes

Versions: 1

Compression:

Stored size: 832 Bytes

Contents

require 'squib'

Squib::Deck.new(cards: 2) do

  # 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(:white)
      cairo_context.paint
    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

  save_png prefix: 'cairo_access_'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
squib-0.0.5 samples/cairo_access.rb