squib 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/CHANGELOG.md +10 -0
  4. data/README.md +44 -21
  5. data/Rakefile +74 -1
  6. data/benchmarks/shiny-purse.png +0 -0
  7. data/benchmarks/spanner.svg +91 -0
  8. data/benchmarks/tons_of_png.rb +6 -0
  9. data/benchmarks/tons_of_svg.rb +7 -0
  10. data/benchmarks/tons_of_text.rb +8 -0
  11. data/lib/squib/api/background.rb +1 -1
  12. data/lib/squib/api/image.rb +6 -4
  13. data/lib/squib/api/save.rb +4 -3
  14. data/lib/squib/api/shapes.rb +7 -7
  15. data/lib/squib/api/text.rb +1 -1
  16. data/lib/squib/args/unit_conversion.rb +21 -0
  17. data/lib/squib/card.rb +2 -1
  18. data/lib/squib/constants.rb +8 -0
  19. data/lib/squib/deck.rb +14 -12
  20. data/lib/squib/graphics/background.rb +1 -1
  21. data/lib/squib/graphics/cairo_context_wrapper.rb +42 -0
  22. data/lib/squib/graphics/gradient_regex.rb +46 -0
  23. data/lib/squib/graphics/image.rb +17 -7
  24. data/lib/squib/graphics/save_doc.rb +16 -13
  25. data/lib/squib/graphics/save_images.rb +4 -4
  26. data/lib/squib/graphics/shapes.rb +7 -7
  27. data/lib/squib/graphics/text.rb +1 -1
  28. data/lib/squib/input_helpers.rb +8 -8
  29. data/lib/squib/version.rb +1 -1
  30. data/samples/colors.rb +22 -1
  31. data/samples/glass-heart.svg +52 -0
  32. data/samples/gradients.rb +34 -0
  33. data/samples/load_images.rb +14 -0
  34. data/samples/saves.rb +5 -0
  35. data/spec/api/api_image_spec.rb +2 -2
  36. data/spec/args/unit_conversion_spec.rb +22 -0
  37. data/spec/data/samples/autoscale_font.rb.txt +9 -9
  38. data/spec/data/samples/basic.rb.txt +24 -24
  39. data/spec/data/samples/cairo_access.rb.txt +4 -4
  40. data/spec/data/samples/csv_import.rb.txt +10 -10
  41. data/spec/data/samples/custom_config.rb.txt +3 -3
  42. data/spec/data/samples/draw_shapes.rb.txt +8 -8
  43. data/spec/data/samples/excel.rb.txt +15 -15
  44. data/spec/data/samples/gradients.rb.txt +65 -0
  45. data/spec/data/samples/hello_world.rb.txt +4 -4
  46. data/spec/data/samples/load_images.rb.txt +30 -4
  47. data/spec/data/samples/portrait-landscape.rb.txt +6 -6
  48. data/spec/data/samples/ranges.rb.txt +30 -30
  49. data/spec/data/samples/saves.rb.txt +74 -70
  50. data/spec/data/samples/showcase.rb.txt +20 -20
  51. data/spec/data/samples/text_options.rb.txt +63 -63
  52. data/spec/data/samples/tgc_proofs.rb.txt +8 -8
  53. data/spec/data/samples/units.rb.txt +8 -8
  54. data/spec/deck_spec.rb +6 -0
  55. data/spec/graphics/cairo_context_wrapper_spec.rb +75 -0
  56. data/spec/graphics/graphics_images_spec.rb +5 -6
  57. data/spec/input_helpers_spec.rb +11 -9
  58. data/spec/samples/samples_regression_spec.rb +3 -1
  59. data/spec/spec_helper.rb +1 -0
  60. metadata +20 -5
  61. data/spec/data/samples/colors.rb.txt +0 -124
@@ -22,7 +22,7 @@ module Squib
22
22
  # @option opts font_size [Integer] (nil) an override of font string description, for scaling the font according to the size of the string
23
23
  # @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
24
24
  # @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
25
- # @option opts color [String] (:black) the color the font will render to. See {file:README.md#Specifying_Colors Specifying Colors}
25
+ # @option opts color [String] (:black) the color the font will render to. Gradients supported. See {file:README.md#Specifying_Colors___Gradients Specifying Colors}
26
26
  # @option opts markup: [Boolean] (false) Enable markup parsing of `str` using the HTML-like Pango Markup syntax, defined [here](http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup) and [here](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html).
27
27
  # @option opts width [Integer, :native] (:native) the width of the box the string will be placed in. Stretches to the content by default.. Supports Unit Conversion, see {file:README.md#Units Units}.
28
28
  # @option opts height [Integer, :native] the height of the box the string will be placed in. Stretches to the content by default. Supports Unit Conversion, see {file:README.md#Units Units}.
@@ -0,0 +1,21 @@
1
+ require 'squib/constants'
2
+
3
+ module Squib
4
+ module Args
5
+ module UnitConversion
6
+
7
+ module_function
8
+ def parse(arg, dpi=300)
9
+ case arg.to_s.rstrip
10
+ when /in$/ #ends with "in"
11
+ arg.rstrip[0..-2].to_f * dpi
12
+ when /cm$/ #ends with "cm"
13
+ arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM
14
+ else
15
+ arg
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,6 @@
1
1
  require 'cairo'
2
2
  require 'squib/input_helpers'
3
+ require 'squib/graphics/cairo_context_wrapper'
3
4
 
4
5
  module Squib
5
6
  # Back end graphics. Private.
@@ -19,7 +20,7 @@ module Squib
19
20
  def initialize(deck, width, height)
20
21
  @deck=deck; @width=width; @height=height
21
22
  @cairo_surface = Cairo::ImageSurface.new(width,height)
22
- @cairo_context = Cairo::Context.new(@cairo_surface)
23
+ @cairo_context = Squib::Graphics::CairoContextWrapper.new(Cairo::Context.new(@cairo_surface))
23
24
  end
24
25
 
25
26
  # A save/restore wrapper for using Cairo
@@ -9,6 +9,7 @@ module Squib
9
9
  :blend => :none,
10
10
  :color => :black,
11
11
  :columns => 1,
12
+ :count_format => '%02d',
12
13
  :default_font => 'Arial 36',
13
14
  :dir => '_output',
14
15
  :ellipsize => :end,
@@ -25,6 +26,7 @@ module Squib
25
26
  :justify => false,
26
27
  :margin => 75,
27
28
  :markup => false,
29
+ :mask => nil,
28
30
  :offset => 1.1,
29
31
  :prefix => 'card_',
30
32
  :progress_bar => false,
@@ -95,6 +97,7 @@ module Squib
95
97
  :justify => :justify,
96
98
  :layout => :layout,
97
99
  :markup => :markup,
100
+ :mask => :mask,
98
101
  :rect_radius => :radius,
99
102
  :spacing => :spacing,
100
103
  :str => :str,
@@ -125,10 +128,15 @@ module Squib
125
128
  # value: the user-facing API key (e.g. radius: '1in')
126
129
  UNIT_CONVERSION_PARAMS = {
127
130
  :circle_radius => :radius,
131
+ :gap => :gap,
128
132
  :height => :height,
133
+ :margin => :margin,
134
+ :paper_width => :width,
135
+ :paper_height => :height,
129
136
  :rect_radius => :radius,
130
137
  :spacing => :spacing,
131
138
  :stroke_width => :stroke_width,
139
+ :trim => :trim,
132
140
  :width => :width,
133
141
  :x => :x,
134
142
  :x1 => :x1,
@@ -6,6 +6,7 @@ require 'squib/progress'
6
6
  require 'squib/input_helpers'
7
7
  require 'squib/constants'
8
8
  require 'squib/layout_parser'
9
+ require 'squib/args/unit_conversion'
9
10
 
10
11
  # The project module
11
12
  #
@@ -46,8 +47,8 @@ module Squib
46
47
  # text str: 'Hello, World!"
47
48
  # end
48
49
  #
49
- # @param width [Integer] the width of each card in pixels
50
- # @param height [Integer] the height of each card in pixels
50
+ # @param width [Integer] the width of each card in pixels. Supports unit conversion (e.g. '2.5in').
51
+ # @param height [Integer] the height of each card in pixels. Supports unit conversion (e.g. '3.5in').
51
52
  # @param cards [Integer] the number of cards in the deck
52
53
  # @param dpi [Integer] the pixels per inch when rendering out to PDF or calculating using inches.
53
54
  # @param config [String] the file used for global settings of this deck
@@ -55,20 +56,21 @@ module Squib
55
56
  # @param block [Block] the main body of the script.
56
57
  # @api public
57
58
  def initialize(width: 825, height: 1125, cards: 1, dpi: 300, config: 'config.yml', layout: nil, &block)
58
- @width=width; @height=height
59
- @dpi = dpi
60
- @font = Squib::SYSTEM_DEFAULTS[:default_font]
61
- @cards = []
59
+ @dpi = dpi
60
+ @width = Args::UnitConversion.parse width, dpi
61
+ @height = Args::UnitConversion.parse height, dpi
62
+ @font = Squib::SYSTEM_DEFAULTS[:default_font]
63
+ @cards = []
62
64
  @custom_colors = {}
63
- @img_dir = '.'
64
- @progress_bar = Squib::Progress.new(false)
65
- @text_hint = :off
66
- cards.times{ @cards << Squib::Card.new(self, width, height) }
65
+ @img_dir = '.'
66
+ @progress_bar = Squib::Progress.new(false)
67
+ @text_hint = :off
68
+ cards.times{ @cards << Squib::Card.new(self, @width, @height) }
67
69
  show_info(config, layout)
68
70
  load_config(config)
69
- @layout = LayoutParser.load_layout(layout)
71
+ @layout = LayoutParser.load_layout(layout)
70
72
  if block_given?
71
- instance_eval(&block)
73
+ instance_eval(&block) # here we go. wheeeee!
72
74
  end
73
75
  end
74
76
 
@@ -5,7 +5,7 @@ module Squib
5
5
  # @api private
6
6
  def background(color)
7
7
  use_cairo do |cc|
8
- cc.set_source_color(color)
8
+ cc.set_source_squibcolor(color)
9
9
  cc.paint
10
10
  end
11
11
  end
@@ -0,0 +1,42 @@
1
+ require 'forwardable'
2
+ require 'squib/graphics/gradient_regex'
3
+
4
+ module Squib
5
+ module Graphics
6
+ class CairoContextWrapper
7
+ extend Forwardable
8
+ attr_accessor :cairo_cxt
9
+
10
+ def initialize(cairo_cxt)
11
+ @cairo_cxt = cairo_cxt
12
+ end
13
+
14
+ def_delegators :cairo_cxt, :save, :set_source_color, :paint, :restore,
15
+ :translate, :rotate, :move_to, :update_pango_layout, :width, :height,
16
+ :show_pango_layout, :rounded_rectangle, :set_line_width, :stroke, :fill,
17
+ :set_source, :scale, :render_rsvg_handle, :circle, :triangle, :line_to,
18
+ :operator=, :show_page, :clip, :transform, :mask, :create_pango_layout
19
+
20
+ def set_source_squibcolor(arg)
21
+ if match = arg.match(LINEAR_GRADIENT)
22
+ x1, y1, x2, y2 = match.captures
23
+ linear = Cairo::LinearPattern.new(x1.to_f, y1.to_f, x2.to_f, y2.to_f)
24
+ arg.scan(STOPS).each do |color, offset|
25
+ linear.add_color_stop(offset.to_f, color)
26
+ end
27
+ @cairo_cxt.set_source(linear)
28
+ elsif match = arg.match(RADIAL_GRADIENT)
29
+ x1, y1, r1, x2, y2, r2 = match.captures
30
+ linear = Cairo::RadialPattern.new(x1.to_f, y1.to_f, r1.to_f,
31
+ x2.to_f, y2.to_f, r2.to_f)
32
+ arg.scan(STOPS).each do |color, offset|
33
+ linear.add_color_stop(offset.to_f, color)
34
+ end
35
+ @cairo_cxt.set_source(linear)
36
+ else
37
+ @cairo_cxt.set_source_color(arg)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,46 @@
1
+ module Squib
2
+ module Graphics
3
+ STOPS = / # used to capture the stops
4
+ \s* # leading whitespace is ok
5
+ (\#?[\w]+) # color
6
+ @ # no spaces here
7
+ (\d+\.?\d*) # offset number
8
+ /x
9
+
10
+ LINEAR_GRADIENT = /
11
+ \( \s* # coordinate 1
12
+ (\d+\.?\d*) \s* # x1 number
13
+ ,\s* # whitespace after comma is ok
14
+ (\d+\.?\d*) \s* # y1 number
15
+ \)
16
+ \s* # space between coordinates is ok
17
+ \( \s* # coordinate 2
18
+ (\d+\.?\d*) \s* # x2 number
19
+ ,\s* # whitespace after comma is ok
20
+ (\d+\.?\d*) \s* # y2 number
21
+ \)
22
+ (#{STOPS})+ # stops
23
+ \s* # trailing whitespace is ok
24
+ /x
25
+
26
+ RADIAL_GRADIENT = /
27
+ \( \s* # coordinate 1
28
+ (\d+\.?\d*) \s* # x1 number
29
+ ,\s* # whitespace after comma is ok
30
+ (\d+\.?\d*) \s* # y1 number
31
+ ,\s* # whitespace after comma is ok
32
+ (\d+\.?\d*) \s* # r1 number
33
+ \)
34
+ \s* # space between coordinates is ok
35
+ \( \s* # coordinate 2
36
+ (\d+\.?\d*) \s* # x2 number
37
+ ,\s* # whitespace after comma is ok
38
+ (\d+\.?\d*) \s* # y2 number
39
+ ,\s* # whitespace after comma is ok
40
+ (\d+\.?\d*) \s* # r2 number
41
+ \)
42
+ (#{STOPS})+ # stops
43
+ \s* # trailing whitespace is ok
44
+ /x
45
+ end
46
+ end
@@ -14,8 +14,8 @@ module Squib
14
14
 
15
15
  # :nodoc:
16
16
  # @api private
17
- def png(file, x, y, width, height, alpha, blend, angle)
18
- Squib.logger.debug {"Rendering: #{file} @#{x},#{y} #{width}x#{height}, alpha: #{alpha}, blend: #{blend}, angle: #{angle}"}
17
+ def png(file, x, y, width, height, alpha, blend, angle, mask)
18
+ Squib.logger.debug {"Rendering: #{file} @#{x},#{y} #{width}x#{height}, alpha: #{alpha}, blend: #{blend}, angle: #{angle}, mask: #{mask}"}
19
19
  return if file.nil? or file.eql? ''
20
20
  png = Squib.cache_load_image(file)
21
21
  use_cairo do |cc|
@@ -30,14 +30,19 @@ module Squib
30
30
  cc.translate(-1 * x, -1 * y)
31
31
  cc.set_source(png, x, y)
32
32
  cc.operator = blend unless blend == :none
33
- cc.paint(alpha)
33
+ if mask.nil?
34
+ cc.paint(alpha)
35
+ else
36
+ cc.set_source_squibcolor(mask)
37
+ cc.mask(png, x, y)
38
+ end
34
39
  end
35
40
  end
36
41
 
37
42
  # :nodoc:
38
43
  # @api private
39
- def svg(file, id, x, y, width, height, alpha, blend, angle)
40
- Squib.logger.debug {"Rendering: #{file}, id: #{id} @#{x},#{y} #{width}x#{height}, alpha: #{alpha}, blend: #{blend}, angle: #{angle}"}
44
+ def svg(file, id, x, y, width, height, alpha, blend, angle, mask)
45
+ Squib.logger.debug {"Rendering: #{file}, id: #{id} @#{x},#{y} #{width}x#{height}, alpha: #{alpha}, blend: #{blend}, angle: #{angle}, mask: #{mask}"}
41
46
  return if file.nil? or file.eql? ''
42
47
  svg = RSVG::Handle.new_from_file(file)
43
48
  width = svg.width if width == :native
@@ -50,9 +55,14 @@ module Squib
50
55
  cc.translate(x, y)
51
56
  cc.rotate(angle)
52
57
  cc.translate(-1 * x, -1 * y)
53
- cc.set_source(tmp, x, y)
54
58
  cc.operator = blend unless blend == :none
55
- cc.paint(alpha)
59
+ if mask.nil?
60
+ cc.set_source(tmp, x, y)
61
+ cc.paint(alpha)
62
+ else
63
+ cc.set_source_squibcolor(mask)
64
+ cc.mask(tmp, x, y)
65
+ end
56
66
  end
57
67
  end
58
68
 
@@ -8,16 +8,17 @@ module Squib
8
8
  #
9
9
  # @option opts file [String] the name of the PDF file to save. See {file:README.md#Specifying_Files Specifying Files}
10
10
  # @option opts dir [String] (_output) the directory to save to. Created if it doesn't exist.
11
- # @option opts margin [Integer] (75) the margin around the outside of the page
12
- # @option opts gap [Integer] (0) the space in pixels between the cards
13
- # @option opts trim [Integer] (0) the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play)
11
+ # @option opts width [Integer] (3300) the height of the page in pixels. Default is 11in * 300dpi. Supports unit conversion.
12
+ # @option opts height [Integer] (2550) the height of the page in pixels. Default is 8.5in * 300dpi. Supports unit conversion.
13
+ # @option opts margin [Integer] (75) the margin around the outside of the page. Supports unit conversion.
14
+ # @option opts gap [Integer] (0) the space in pixels between the cards. Supports unit conversion.
15
+ # @option opts trim [Integer] (0) the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play). Supports unit conversion.
14
16
  # @return [nil]
15
17
  # @api public
16
18
  def save_pdf(opts = {})
17
- p = needs(opts, [:range, :file_to_save, :creatable_dir, :margin, :gap, :trim])
18
- width = 11 * @dpi
19
- height = 8.5 * @dpi #TODO: allow this to be specified too
20
- cc = Cairo::Context.new(Cairo::PDFSurface.new("#{p[:dir]}/#{p[:file]}", width, height))
19
+ opts = {width: 3300, height: 2550}.merge(opts)
20
+ p = needs(opts, [:range, :paper_width, :paper_height, :file_to_save, :creatable_dir, :margin, :gap, :trim])
21
+ cc = Cairo::Context.new(Cairo::PDFSurface.new("#{p[:dir]}/#{p[:file]}", p[:width], p[:height]))
21
22
  x = p[:margin]
22
23
  y = p[:margin]
23
24
  @progress_bar.start("Saving PDF to #{p[:dir]}/#{p[:file]}", p[:range].size) do |bar|
@@ -27,10 +28,10 @@ module Squib
27
28
  cc.paint
28
29
  bar.increment
29
30
  x += surface.width + p[:gap]
30
- if x > (width - surface.width - p[:margin])
31
+ if x > (p[:width] - surface.width - p[:margin])
31
32
  x = p[:margin]
32
33
  y += surface.height + p[:gap]
33
- if y > (height - surface.height - p[:margin])
34
+ if y > (p[:height] - surface.height - p[:margin])
34
35
  x = p[:margin]
35
36
  y = p[:margin]
36
37
  cc.show_page #next page
@@ -49,15 +50,16 @@ module Squib
49
50
  # @option opts colulmns [Integer] (1) the number of columns in the grid
50
51
  # @option opts rows [Integer] (:infinite) the number of rows in the grid. When set to :infinite, the sheet scales to the rows needed. If there are more cards than rows*columns, new sheets are started.
51
52
  # @option opts [String] prefix (card_) the prefix of the file name(s)
53
+ # @option opts [String] count_format (%02d) the format string used for formatting the card count (e.g. padding zeros). Uses a Ruby format string (see the Ruby doc for Kernel::sprintf for specifics)
52
54
  # @option opts dir [String] (_output) the directory to save to. Created if it doesn't exist.
53
- # @option opts margin [Integer] (0) the margin around the outside of the page
55
+ # @option opts margin [Integer] (0) the margin around the outside of the page.
54
56
  # @option opts gap [Integer] (0) the space in pixels between the cards
55
57
  # @option opts trim [Integer] (0) the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play)
56
58
  # @return [nil]
57
59
  # @api public
58
60
  def save_sheet(opts = {})
59
61
  opts = {margin: 0}.merge(opts) # overriding the non-system default
60
- p = needs(opts, [:range, :prefix, :creatable_dir, :margin, :gap, :trim, :rows, :columns])
62
+ p = needs(opts, [:range, :prefix, :count_format, :creatable_dir, :margin, :gap, :trim, :rows, :columns])
61
63
  # EXTRACT METHOD HERE
62
64
  sheet_width = (p[:columns] * (@width + 2 * p[:gap] - 2 * p[:trim])) + (2 * p[:margin])
63
65
  sheet_height = (p[:rows] * (@height + 2 * p[:gap] - 2 * p[:trim])) + (2 * p[:margin])
@@ -68,7 +70,8 @@ module Squib
68
70
  @progress_bar.start("Saving PNG sheet to #{p[:dir]}/#{p[:prefix]}_*", @cards.size + 1) do |bar|
69
71
  p[:range].each do |i|
70
72
  if num_this_sheet >= (p[:columns] * p[:rows]) # new sheet
71
- cc.target.write_to_png("#{p[:dir]}/#{p[:prefix]}#{sheet_num}.png")
73
+ filename = "#{p[:dir]}/#{p[:prefix]}#{p[:count_format] % sheet_num}.png"
74
+ cc.target.write_to_png(filename)
72
75
  new_sheet = false
73
76
  num_this_sheet = 0
74
77
  sheet_num += 1
@@ -87,7 +90,7 @@ module Squib
87
90
  end
88
91
  bar.increment
89
92
  end
90
- cc.target.write_to_png("#{p[:dir]}/#{p[:prefix]}#{sheet_num}.png")
93
+ cc.target.write_to_png("#{p[:dir]}/#{p[:prefix]}#{p[:count_format] % sheet_num}.png")
91
94
  end
92
95
  end
93
96
 
@@ -3,13 +3,13 @@ module Squib
3
3
 
4
4
  # :nodoc:
5
5
  # @api private
6
- def save_png(i, dir, prefix, do_rotate, angle)
6
+ def save_png(i, dir, prefix, count_format, do_rotate, angle)
7
7
  if [true, :clockwise, :counterclockwise].include?(do_rotate)
8
8
  surface = rotated_image(angle)
9
9
  else
10
10
  surface = @cairo_surface
11
11
  end
12
- write_png(surface, i, dir, prefix)
12
+ write_png(surface, i, dir, prefix, count_format)
13
13
  end
14
14
 
15
15
  # :nodoc:
@@ -25,8 +25,8 @@ module Squib
25
25
  end
26
26
  # :nodoc:
27
27
  # @api private
28
- def write_png(surface, i, dir, prefix)
29
- surface.write_to_png("#{dir}/#{prefix}#{i}.png")
28
+ def write_png(surface, i, dir, prefix, count_format)
29
+ surface.write_to_png("#{dir}/#{prefix}#{count_format % i}.png")
30
30
  end
31
31
 
32
32
  end
@@ -8,11 +8,11 @@ module Squib
8
8
  height = @height if height == :native
9
9
  use_cairo do |cc|
10
10
  cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
11
- cc.set_source_color(stroke_color)
11
+ cc.set_source_squibcolor(stroke_color)
12
12
  cc.set_line_width(stroke_width)
13
13
  cc.stroke
14
14
  cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
15
- cc.set_source_color(fill_color)
15
+ cc.set_source_squibcolor(fill_color)
16
16
  cc.fill
17
17
  end
18
18
  end
@@ -22,11 +22,11 @@ module Squib
22
22
  def circle(x, y, radius, fill_color, stroke_color, stroke_width)
23
23
  use_cairo do |cc|
24
24
  cc.circle(x, y, radius)
25
- cc.set_source_color(stroke_color)
25
+ cc.set_source_squibcolor(stroke_color)
26
26
  cc.set_line_width(stroke_width)
27
27
  cc.stroke
28
28
  cc.circle(x, y, radius)
29
- cc.set_source_color(fill_color)
29
+ cc.set_source_squibcolor(fill_color)
30
30
  cc.fill
31
31
  end
32
32
  end
@@ -36,11 +36,11 @@ module Squib
36
36
  def triangle(x1, y1, x2, y2, x3, y3, fill_color, stroke_color, stroke_width)
37
37
  use_cairo do |cc|
38
38
  cc.triangle(x1, y1, x2, y2, x3, y3)
39
- cc.set_source_color(stroke_color)
39
+ cc.set_source_squibcolor(stroke_color)
40
40
  cc.set_line_width(stroke_width)
41
41
  cc.stroke
42
42
  cc.triangle(x1, y1, x2, y2, x3, y3)
43
- cc.set_source_color(fill_color)
43
+ cc.set_source_squibcolor(fill_color)
44
44
  cc.fill
45
45
  end
46
46
  end
@@ -51,7 +51,7 @@ module Squib
51
51
  use_cairo do |cc|
52
52
  cc.move_to(x1, y1)
53
53
  cc.line_to(x2, y2)
54
- cc.set_source_color(stroke_color)
54
+ cc.set_source_squibcolor(stroke_color)
55
55
  cc.set_line_width(stroke_width)
56
56
  cc.stroke
57
57
  end
@@ -91,7 +91,7 @@ module Squib
91
91
  Squib.logger.debug {"Placing '#{str}'' with font '#{font}' @ #{x}, #{y}, color: #{color}, angle: #{angle} etc."}
92
92
  extents = nil
93
93
  use_cairo do |cc|
94
- cc.set_source_color(color)
94
+ cc.set_source_squibcolor(color)
95
95
  cc.translate(x,y)
96
96
  cc.rotate(angle)
97
97
  cc.translate(-1*x,-1*y)