parent
5bbde3a259
commit
19767c54c4
|
|
@ -16,7 +16,7 @@ Features
|
||||||
* Added `:scale` shortcut to `width` and `height` options for `png` and `svg`. Allows you to set the width and the image will scale while keeping its aspect ratio. (e.g. `svg width: 500, height: :scale`) (#91)
|
* Added `:scale` shortcut to `width` and `height` options for `png` and `svg`. Allows you to set the width and the image will scale while keeping its aspect ratio. (e.g. `svg width: 500, height: :scale`) (#91)
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
* All drawn shapes (e.g. circle, triangle, star) will now draw their stroke on top of the fill. This was not consistent before, and now it is (because Squib is more DRY about it!). This means that your `stroke_width` might render wider than before, but now it's accurate.
|
* All drawn shapes (e.g. circle, triangle, star) will now draw their stroke on top of the fill. This was not consistent before, and now it is (because Squib is more DRY about it!). This means that your `stroke_width` might render wider than before. If you want the other behavior, specify `stroke_strategy: :stroke_first`. Also applies to `text` when `stroke_width` is specified.
|
||||||
* The `width` and `height` options for `text` have changed their defaults from `:native` to `:auto`. This is to differentiate them from `:native` widths that default elsewhere. Additionally, `width` and `height` for shapes now default to `:deck`, and get interpreted as the deck width and height. The `:native` options are interpreted for SVG and PNG images as their original values. The behavior is all the same, just with more specific names.
|
* The `width` and `height` options for `text` have changed their defaults from `:native` to `:auto`. This is to differentiate them from `:native` widths that default elsewhere. Additionally, `width` and `height` for shapes now default to `:deck`, and get interpreted as the deck width and height. The `:native` options are interpreted for SVG and PNG images as their original values. The behavior is all the same, just with more specific names.
|
||||||
* Removed `img_dir` from the `set` method. You can still set `img_dir` in the configuration file (e.g. `config.yml`). Added a deprecation error.
|
* Removed `img_dir` from the `set` method. You can still set `img_dir` in the configuration file (e.g. `config.yml`). Added a deprecation error.
|
||||||
* Default `width` and `height` for text embedding `png` and `svg` have changed from 32 to `:native` to be more consistent with the rest of the system
|
* Default `width` and `height` for text embedding `png` and `svg` have changed from 32 to `:native` to be more consistent with the rest of the system
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ module Squib
|
||||||
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
|
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
||||||
# @option opts join [String] ('miter') how corners will be drawn on stroke. Options are 'miter', 'bevel', or 'round'. Note that this is separate from the x_radius and y_radius of the rounded rectangle. Becomes more obvious with wider strokes.
|
# @option opts join [String] ('miter') how corners will be drawn on stroke. Options are 'miter', 'bevel', or 'round'. Note that this is separate from the x_radius and y_radius of the rounded rectangle. Becomes more obvious with wider strokes.
|
||||||
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
||||||
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
||||||
|
|
@ -51,6 +52,7 @@ module Squib
|
||||||
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
||||||
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
||||||
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
|
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
||||||
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
||||||
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
||||||
# @return [nil] intended to be void
|
# @return [nil] intended to be void
|
||||||
|
|
@ -77,6 +79,7 @@ module Squib
|
||||||
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
|
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
||||||
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
||||||
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
||||||
# @return [nil] intended to be void
|
# @return [nil] intended to be void
|
||||||
|
|
@ -105,6 +108,7 @@ module Squib
|
||||||
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
|
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
||||||
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
||||||
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
||||||
# @return [nil] intended to be void
|
# @return [nil] intended to be void
|
||||||
|
|
@ -128,6 +132,7 @@ module Squib
|
||||||
# @option opts y2 [Integer] (50) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts y2 [Integer] (50) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
||||||
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
|
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
||||||
# @option opts cap [String] ('butt') how the end of the line is drawn. Options are "square", "butt", and "round"
|
# @option opts cap [String] ('butt') how the end of the line is drawn. Options are "square", "butt", and "round"
|
||||||
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
||||||
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
||||||
|
|
@ -153,6 +158,7 @@ module Squib
|
||||||
# @option opts cy2 [Integer] (50) the y-coordinate of the second control point. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts cy2 [Integer] (50) the y-coordinate of the second control point. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
||||||
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
|
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
||||||
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
# @option opts cap [String] ('butt') how the end of the line is drawn. Options are "square", "butt", and "round"
|
# @option opts cap [String] ('butt') how the end of the line is drawn. Options are "square", "butt", and "round"
|
||||||
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
||||||
|
|
@ -179,6 +185,7 @@ module Squib
|
||||||
# @option opts inner_radius [Fixnum] (0) the inner radius. Supports Unit conversion.
|
# @option opts inner_radius [Fixnum] (0) the inner radius. Supports Unit conversion.
|
||||||
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
||||||
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
|
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
||||||
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
||||||
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
||||||
|
|
@ -205,6 +212,7 @@ module Squib
|
||||||
# @option opts radius [Fixnum] (0) the radius from center to corner. Supports Unit conversion.
|
# @option opts radius [Fixnum] (0) the radius from center to corner. Supports Unit conversion.
|
||||||
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
||||||
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
|
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
||||||
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
||||||
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ module Squib
|
||||||
# @option opts angle [FixNum] (0) Rotation of the text in radians. Note that this rotates around the upper-left corner of the text box, making the placement of x-y coordinates slightly tricky.
|
# @option opts angle [FixNum] (0) Rotation of the text in radians. Note that this rotates around the upper-left corner of the text box, making the placement of x-y coordinates slightly tricky.
|
||||||
# @option opts stroke_width [Decimal] (0.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
# @option opts stroke_width [Decimal] (0.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
||||||
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
||||||
|
# @option opts stroke_strategy [:fill_first, :stroke_first] (:fill_first) specify whether the stroke is done before (thinner) or after (thicker) filling the shape.
|
||||||
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
# @option opts dash [String] ('') define a dash pattern for the stroke. Provide a string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels by defautl. Supports Unit Conversion, see {file:README.md#Units Units} (e.g. `'0.02in 0.02in'`).
|
||||||
# @option opts hint [String] (:nil) draw a rectangle around the text with the given color. Overrides global hints (see {Deck#hint}).
|
# @option opts hint [String] (:nil) draw a rectangle around the text with the given color. Overrides global hints (see {Deck#hint}).
|
||||||
# @return [Array] Returns an Array of hashes keyed by :width and :height that mark the ink extents of the text rendered.
|
# @return [Array] Returns an Array of hashes keyed by :width and :height that mark the ink extents of the text rendered.
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ module Squib
|
||||||
fill_color: '#0000',
|
fill_color: '#0000',
|
||||||
stroke_color: :black,
|
stroke_color: :black,
|
||||||
stroke_width: 2.0,
|
stroke_width: 2.0,
|
||||||
|
stroke_strategy: :fill_first,
|
||||||
join: :miter,
|
join: :miter,
|
||||||
cap: 'butt',
|
cap: 'butt',
|
||||||
dash: ''
|
dash: ''
|
||||||
|
|
@ -74,7 +75,18 @@ module Squib
|
||||||
colorify(arg, @custom_colors)
|
colorify(arg, @custom_colors)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate_stroke_strategy(arg, _i)
|
||||||
|
case arg.to_s.downcase.strip
|
||||||
|
when 'fill_first'
|
||||||
|
:fill_first
|
||||||
|
when 'stroke_first'
|
||||||
|
:stroke_first
|
||||||
|
else
|
||||||
|
raise "Only 'stroke_first' or 'fill_first' allowed"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ module Squib
|
||||||
# Convenience method for a common task
|
# Convenience method for a common task
|
||||||
# @api private
|
# @api private
|
||||||
def fill_n_stroke(draw)
|
def fill_n_stroke(draw)
|
||||||
|
return stroke_n_fill(draw) if draw.stroke_strategy == :stroke_first
|
||||||
set_source_squibcolor draw.fill_color
|
set_source_squibcolor draw.fill_color
|
||||||
fill_preserve
|
fill_preserve
|
||||||
set_source_squibcolor draw.stroke_color
|
set_source_squibcolor draw.stroke_color
|
||||||
|
|
@ -64,6 +65,18 @@ module Squib
|
||||||
stroke
|
stroke
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stroke_n_fill(draw)
|
||||||
|
return fill_n_stroke(draw) if draw.stroke_strategy == :fill_first
|
||||||
|
set_source_squibcolor draw.stroke_color
|
||||||
|
set_line_width draw.stroke_width
|
||||||
|
set_line_join draw.join
|
||||||
|
set_line_cap draw.cap
|
||||||
|
set_dash draw.dash
|
||||||
|
stroke_preserve
|
||||||
|
set_source_squibcolor draw.fill_color
|
||||||
|
fill
|
||||||
|
end
|
||||||
|
|
||||||
# Convenience method for a common task
|
# Convenience method for a common task
|
||||||
# @api private
|
# @api private
|
||||||
def fancy_stroke(draw)
|
def fancy_stroke(draw)
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ module Squib
|
||||||
if draw.stroke_width > 0
|
if draw.stroke_width > 0
|
||||||
cc.pango_layout_path(layout)
|
cc.pango_layout_path(layout)
|
||||||
cc.fancy_stroke draw
|
cc.fancy_stroke draw
|
||||||
|
cc.set_source_squibcolor(draw.color)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -150,8 +151,9 @@ module Squib
|
||||||
vertical_start = compute_valign(layout, para.valign)
|
vertical_start = compute_valign(layout, para.valign)
|
||||||
cc.move_to(0, vertical_start)
|
cc.move_to(0, vertical_start)
|
||||||
|
|
||||||
|
stroke_outline!(cc, layout, draw) if draw.stroke_strategy == :stroke_first
|
||||||
cc.show_pango_layout(layout)
|
cc.show_pango_layout(layout)
|
||||||
stroke_outline!(cc, layout, draw)
|
stroke_outline!(cc, layout, draw) if draw.stroke_strategy == :fill_first
|
||||||
begin
|
begin
|
||||||
embed_draws.each { |ed| ed[:draw].call(self, ed[:x], ed[:y] + vertical_start) }
|
embed_draws.each { |ed| ed[:draw].call(self, ed[:x], ed[:y] + vertical_start) }
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,13 @@ Squib::Deck.new do
|
||||||
stroke_width: 5.0, stroke_color: :cyan,
|
stroke_width: 5.0, stroke_color: :cyan,
|
||||||
fill_color: :burgundy
|
fill_color: :burgundy
|
||||||
|
|
||||||
star x: 300, y: 1000, n: 5, inner_radius: 10, outer_radius: 25,
|
star x: 300, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
|
||||||
fill_color: :cyan, stroke_color: :burgundy, stroke_width: 3
|
fill_color: :cyan, stroke_color: :burgundy, stroke_width: 5
|
||||||
|
|
||||||
|
#default draw is fill-then-stroke. Can be changed to stroke-then-fill
|
||||||
|
star x: 375, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
|
||||||
|
fill_color: :cyan, stroke_color: :burgundy,
|
||||||
|
stroke_width: 5, stroke_strategy: :stroke_first
|
||||||
|
|
||||||
polygon x: 500, y: 1000, n: 5, radius: 25, angle: Math::PI / 2,
|
polygon x: 500, y: 1000, n: 5, radius: 25, angle: Math::PI / 2,
|
||||||
fill_color: :cyan, stroke_color: :burgundy, stroke_width: 2
|
fill_color: :cyan, stroke_color: :burgundy, stroke_width: 2
|
||||||
|
|
|
||||||
|
|
@ -78,14 +78,18 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
||||||
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
||||||
end
|
end
|
||||||
|
|
||||||
text str: "Stroke n <span fgcolor=\"\#ff0000\">fill</span>",
|
text str: "Fill n <span fgcolor=\"\#ff0000\">stroke</span>",
|
||||||
color: :green, stroke_width: 2.0, stroke_color: :blue,
|
color: :green, stroke_width: 2.0, stroke_color: :blue,
|
||||||
x: '1.8in', y: '3in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
x: '1.8in', y: '2.9in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
||||||
|
|
||||||
|
text str: "Stroke n <span fgcolor=\"\#ff0000\">fill</span>",
|
||||||
|
color: :green, stroke_width: 2.0, stroke_color: :blue, stroke_strategy: :stroke_first,
|
||||||
|
x: '1.8in', y: '3.0in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
||||||
|
|
||||||
text str: "Dotted",
|
text str: "Dotted",
|
||||||
color: :white, stroke_width: 2.0, dash: '4 2', stroke_color: :black,
|
color: :white, stroke_width: 2.0, dash: '4 2', stroke_color: :black,
|
||||||
x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 28', markup: true
|
x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
||||||
|
#
|
||||||
text str: "<b>Markup</b> is <i>quite</i> <s>'easy'</s> <span fgcolor=\"\#ff0000\">awesome</span>. Can't beat those \"smart\" 'quotes', now with 10--20% more en-dashes --- and em-dashes --- with explicit ellipses too...",
|
text str: "<b>Markup</b> is <i>quite</i> <s>'easy'</s> <span fgcolor=\"\#ff0000\">awesome</span>. Can't beat those \"smart\" 'quotes', now with 10--20% more en-dashes --- and em-dashes --- with explicit ellipses too...",
|
||||||
markup: true,
|
markup: true,
|
||||||
x: 50, y: 1000,
|
x: 50, y: 1000,
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,23 @@ describe Squib::Args::Draw do
|
||||||
expect(draw).to have_attributes( cap: [Cairo::LINE_CAP_SQUARE] )
|
expect(draw).to have_attributes( cap: [Cairo::LINE_CAP_SQUARE] )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'allows fill_first stroke_strategy' do
|
||||||
|
args = {stroke_strategy: :FILL_first}
|
||||||
|
draw.load! args
|
||||||
|
expect(draw).to have_attributes( stroke_strategy: [:fill_first] )
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'allows stroke_first stroke_strategy' do
|
||||||
|
args = {stroke_strategy: ' stroke_FIRST '}
|
||||||
|
draw.load! args
|
||||||
|
expect(draw).to have_attributes( stroke_strategy: [:stroke_first] )
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'disallows anything not stroke_first and fill_first' do
|
||||||
|
args = {stroke_strategy: 'foo'}
|
||||||
|
expect { draw.load! args }.to raise_error("Only 'stroke_first' or 'fill_first' allowed")
|
||||||
|
end
|
||||||
|
|
||||||
context 'custom colors' do
|
context 'custom colors' do
|
||||||
|
|
||||||
it 'looks up custom colors in the config' do
|
it 'looks up custom colors in the config' do
|
||||||
|
|
@ -75,4 +92,4 @@ describe Squib::Args::Draw do
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -91,29 +91,55 @@ cairo: save([])
|
||||||
cairo: translate([300, 1000])
|
cairo: translate([300, 1000])
|
||||||
cairo: rotate([0])
|
cairo: rotate([0])
|
||||||
cairo: translate([-300, -1000])
|
cairo: translate([-300, -1000])
|
||||||
cairo: move_to([325, 1000])
|
cairo: move_to([340, 1000])
|
||||||
cairo: line_to([325.0, 1000.0])
|
cairo: line_to([340.0, 1000.0])
|
||||||
cairo: line_to([308.09016994374946, 1005.8778525229247])
|
cairo: line_to([312.1352549156242, 1008.8167787843871])
|
||||||
cairo: line_to([307.7254248593737, 1023.7764129073788])
|
cairo: line_to([312.3606797749979, 1038.0422606518061])
|
||||||
cairo: line_to([296.90983005625054, 1009.5105651629515])
|
cairo: line_to([295.3647450843758, 1014.2658477444273])
|
||||||
cairo: line_to([279.7745751406263, 1014.6946313073119])
|
cairo: line_to([267.6393202250021, 1023.511410091699])
|
||||||
cairo: line_to([290.0, 1000.0])
|
cairo: line_to([285.0, 1000.0])
|
||||||
cairo: line_to([279.7745751406263, 985.3053686926881])
|
cairo: line_to([267.6393202250021, 976.488589908301])
|
||||||
cairo: line_to([296.90983005625054, 990.4894348370485])
|
cairo: line_to([295.3647450843758, 985.7341522555727])
|
||||||
cairo: line_to([307.7254248593737, 976.2235870926212])
|
cairo: line_to([312.3606797749979, 961.9577393481939])
|
||||||
cairo: line_to([308.09016994374946, 994.1221474770753])
|
cairo: line_to([312.1352549156242, 991.1832212156129])
|
||||||
cairo: line_to([325.0, 1000.0])
|
cairo: line_to([340.0, 1000.0])
|
||||||
cairo: close_path([])
|
cairo: close_path([])
|
||||||
cairo: set_source_color(["cyan"])
|
cairo: set_source_color(["cyan"])
|
||||||
cairo: fill_preserve([])
|
cairo: fill_preserve([])
|
||||||
cairo: set_source_color(["burgundy"])
|
cairo: set_source_color(["burgundy"])
|
||||||
cairo: set_line_width([3])
|
cairo: set_line_width([5])
|
||||||
cairo: set_line_join([0])
|
cairo: set_line_join([0])
|
||||||
cairo: set_line_cap([0])
|
cairo: set_line_cap([0])
|
||||||
cairo: set_dash([[]])
|
cairo: set_dash([[]])
|
||||||
cairo: stroke([])
|
cairo: stroke([])
|
||||||
cairo: restore([])
|
cairo: restore([])
|
||||||
cairo: save([])
|
cairo: save([])
|
||||||
|
cairo: translate([375, 1000])
|
||||||
|
cairo: rotate([0])
|
||||||
|
cairo: translate([-375, -1000])
|
||||||
|
cairo: move_to([415, 1000])
|
||||||
|
cairo: line_to([415.0, 1000.0])
|
||||||
|
cairo: line_to([387.1352549156242, 1008.8167787843871])
|
||||||
|
cairo: line_to([387.3606797749979, 1038.0422606518061])
|
||||||
|
cairo: line_to([370.3647450843758, 1014.2658477444273])
|
||||||
|
cairo: line_to([342.6393202250021, 1023.511410091699])
|
||||||
|
cairo: line_to([360.0, 1000.0])
|
||||||
|
cairo: line_to([342.6393202250021, 976.488589908301])
|
||||||
|
cairo: line_to([370.3647450843758, 985.7341522555727])
|
||||||
|
cairo: line_to([387.3606797749979, 961.9577393481939])
|
||||||
|
cairo: line_to([387.1352549156242, 991.1832212156129])
|
||||||
|
cairo: line_to([415.0, 1000.0])
|
||||||
|
cairo: close_path([])
|
||||||
|
cairo: set_source_color(["burgundy"])
|
||||||
|
cairo: set_line_width([5])
|
||||||
|
cairo: set_line_join([0])
|
||||||
|
cairo: set_line_cap([0])
|
||||||
|
cairo: set_dash([[]])
|
||||||
|
cairo: stroke_preserve([])
|
||||||
|
cairo: set_source_color(["cyan"])
|
||||||
|
cairo: fill([])
|
||||||
|
cairo: restore([])
|
||||||
|
cairo: save([])
|
||||||
cairo: translate([500, 1000])
|
cairo: translate([500, 1000])
|
||||||
cairo: rotate([1.5707963267948966])
|
cairo: rotate([1.5707963267948966])
|
||||||
cairo: translate([-500, -1000])
|
cairo: translate([-500, -1000])
|
||||||
|
|
|
||||||
|
|
@ -780,11 +780,11 @@ pango: ellipsized?([])
|
||||||
cairo: restore([])
|
cairo: restore([])
|
||||||
cairo: save([])
|
cairo: save([])
|
||||||
cairo: set_source_color(["green"])
|
cairo: set_source_color(["green"])
|
||||||
cairo: translate([540.0, 900.0])
|
cairo: translate([540.0, 870.0])
|
||||||
cairo: rotate([0])
|
cairo: rotate([0])
|
||||||
cairo: move_to([0, 0])
|
cairo: move_to([0, 0])
|
||||||
pango: font_description=([MockDouble])
|
pango: font_description=([MockDouble])
|
||||||
pango: text=(["Stroke n <span fgcolor=\"#ff0000\">fill</span>"])
|
pango: text=(["Fill n <span fgcolor=\"#ff0000\">stroke</span>"])
|
||||||
pango: markup=(["foo"])
|
pango: markup=(["foo"])
|
||||||
pango: width=([261120.0])
|
pango: width=([261120.0])
|
||||||
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
|
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
|
||||||
|
|
@ -800,6 +800,57 @@ cairo: set_line_join([0])
|
||||||
cairo: set_line_cap([0])
|
cairo: set_line_cap([0])
|
||||||
cairo: set_dash([[]])
|
cairo: set_dash([[]])
|
||||||
cairo: stroke([])
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["green"])
|
||||||
|
pango: ellipsized?([])
|
||||||
|
cairo: restore([])
|
||||||
|
cairo: save([])
|
||||||
|
cairo: set_source_color(["green"])
|
||||||
|
cairo: translate([540.0, 870.0])
|
||||||
|
cairo: rotate([0])
|
||||||
|
cairo: move_to([0, 0])
|
||||||
|
pango: font_description=([MockDouble])
|
||||||
|
pango: text=(["Fill n <span fgcolor=\"#ff0000\">stroke</span>"])
|
||||||
|
pango: markup=(["foo"])
|
||||||
|
pango: width=([261120.0])
|
||||||
|
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
|
||||||
|
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
|
||||||
|
pango: alignment=([#<Pango::Layout::Alignment left>])
|
||||||
|
pango: justify=([false])
|
||||||
|
cairo: move_to([0, 0])
|
||||||
|
cairo: show_pango_layout([MockDouble])
|
||||||
|
cairo: pango_layout_path([MockDouble])
|
||||||
|
cairo: set_source_color(["blue"])
|
||||||
|
cairo: set_line_width([2.0])
|
||||||
|
cairo: set_line_join([0])
|
||||||
|
cairo: set_line_cap([0])
|
||||||
|
cairo: set_dash([[]])
|
||||||
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["green"])
|
||||||
|
pango: ellipsized?([])
|
||||||
|
cairo: restore([])
|
||||||
|
cairo: save([])
|
||||||
|
cairo: set_source_color(["green"])
|
||||||
|
cairo: translate([540.0, 870.0])
|
||||||
|
cairo: rotate([0])
|
||||||
|
cairo: move_to([0, 0])
|
||||||
|
pango: font_description=([MockDouble])
|
||||||
|
pango: text=(["Fill n <span fgcolor=\"#ff0000\">stroke</span>"])
|
||||||
|
pango: markup=(["foo"])
|
||||||
|
pango: width=([261120.0])
|
||||||
|
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
|
||||||
|
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
|
||||||
|
pango: alignment=([#<Pango::Layout::Alignment left>])
|
||||||
|
pango: justify=([false])
|
||||||
|
cairo: move_to([0, 0])
|
||||||
|
cairo: show_pango_layout([MockDouble])
|
||||||
|
cairo: pango_layout_path([MockDouble])
|
||||||
|
cairo: set_source_color(["blue"])
|
||||||
|
cairo: set_line_width([2.0])
|
||||||
|
cairo: set_line_join([0])
|
||||||
|
cairo: set_line_cap([0])
|
||||||
|
cairo: set_dash([[]])
|
||||||
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["green"])
|
||||||
pango: ellipsized?([])
|
pango: ellipsized?([])
|
||||||
cairo: restore([])
|
cairo: restore([])
|
||||||
cairo: save([])
|
cairo: save([])
|
||||||
|
|
@ -816,7 +867,6 @@ pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
|
||||||
pango: alignment=([#<Pango::Layout::Alignment left>])
|
pango: alignment=([#<Pango::Layout::Alignment left>])
|
||||||
pango: justify=([false])
|
pango: justify=([false])
|
||||||
cairo: move_to([0, 0])
|
cairo: move_to([0, 0])
|
||||||
cairo: show_pango_layout([MockDouble])
|
|
||||||
cairo: pango_layout_path([MockDouble])
|
cairo: pango_layout_path([MockDouble])
|
||||||
cairo: set_source_color(["blue"])
|
cairo: set_source_color(["blue"])
|
||||||
cairo: set_line_width([2.0])
|
cairo: set_line_width([2.0])
|
||||||
|
|
@ -824,6 +874,8 @@ cairo: set_line_join([0])
|
||||||
cairo: set_line_cap([0])
|
cairo: set_line_cap([0])
|
||||||
cairo: set_dash([[]])
|
cairo: set_dash([[]])
|
||||||
cairo: stroke([])
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["green"])
|
||||||
|
cairo: show_pango_layout([MockDouble])
|
||||||
pango: ellipsized?([])
|
pango: ellipsized?([])
|
||||||
cairo: restore([])
|
cairo: restore([])
|
||||||
cairo: save([])
|
cairo: save([])
|
||||||
|
|
@ -840,7 +892,6 @@ pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
|
||||||
pango: alignment=([#<Pango::Layout::Alignment left>])
|
pango: alignment=([#<Pango::Layout::Alignment left>])
|
||||||
pango: justify=([false])
|
pango: justify=([false])
|
||||||
cairo: move_to([0, 0])
|
cairo: move_to([0, 0])
|
||||||
cairo: show_pango_layout([MockDouble])
|
|
||||||
cairo: pango_layout_path([MockDouble])
|
cairo: pango_layout_path([MockDouble])
|
||||||
cairo: set_source_color(["blue"])
|
cairo: set_source_color(["blue"])
|
||||||
cairo: set_line_width([2.0])
|
cairo: set_line_width([2.0])
|
||||||
|
|
@ -848,6 +899,33 @@ cairo: set_line_join([0])
|
||||||
cairo: set_line_cap([0])
|
cairo: set_line_cap([0])
|
||||||
cairo: set_dash([[]])
|
cairo: set_dash([[]])
|
||||||
cairo: stroke([])
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["green"])
|
||||||
|
cairo: show_pango_layout([MockDouble])
|
||||||
|
pango: ellipsized?([])
|
||||||
|
cairo: restore([])
|
||||||
|
cairo: save([])
|
||||||
|
cairo: set_source_color(["green"])
|
||||||
|
cairo: translate([540.0, 900.0])
|
||||||
|
cairo: rotate([0])
|
||||||
|
cairo: move_to([0, 0])
|
||||||
|
pango: font_description=([MockDouble])
|
||||||
|
pango: text=(["Stroke n <span fgcolor=\"#ff0000\">fill</span>"])
|
||||||
|
pango: markup=(["foo"])
|
||||||
|
pango: width=([261120.0])
|
||||||
|
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
|
||||||
|
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
|
||||||
|
pango: alignment=([#<Pango::Layout::Alignment left>])
|
||||||
|
pango: justify=([false])
|
||||||
|
cairo: move_to([0, 0])
|
||||||
|
cairo: pango_layout_path([MockDouble])
|
||||||
|
cairo: set_source_color(["blue"])
|
||||||
|
cairo: set_line_width([2.0])
|
||||||
|
cairo: set_line_join([0])
|
||||||
|
cairo: set_line_cap([0])
|
||||||
|
cairo: set_dash([[]])
|
||||||
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["green"])
|
||||||
|
cairo: show_pango_layout([MockDouble])
|
||||||
pango: ellipsized?([])
|
pango: ellipsized?([])
|
||||||
cairo: restore([])
|
cairo: restore([])
|
||||||
cairo: save([])
|
cairo: save([])
|
||||||
|
|
@ -872,6 +950,7 @@ cairo: set_line_join([0])
|
||||||
cairo: set_line_cap([0])
|
cairo: set_line_cap([0])
|
||||||
cairo: set_dash([[4.0, 2.0]])
|
cairo: set_dash([[4.0, 2.0]])
|
||||||
cairo: stroke([])
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["white"])
|
||||||
pango: ellipsized?([])
|
pango: ellipsized?([])
|
||||||
cairo: restore([])
|
cairo: restore([])
|
||||||
cairo: save([])
|
cairo: save([])
|
||||||
|
|
@ -896,6 +975,7 @@ cairo: set_line_join([0])
|
||||||
cairo: set_line_cap([0])
|
cairo: set_line_cap([0])
|
||||||
cairo: set_dash([[4.0, 2.0]])
|
cairo: set_dash([[4.0, 2.0]])
|
||||||
cairo: stroke([])
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["white"])
|
||||||
pango: ellipsized?([])
|
pango: ellipsized?([])
|
||||||
cairo: restore([])
|
cairo: restore([])
|
||||||
cairo: save([])
|
cairo: save([])
|
||||||
|
|
@ -920,6 +1000,7 @@ cairo: set_line_join([0])
|
||||||
cairo: set_line_cap([0])
|
cairo: set_line_cap([0])
|
||||||
cairo: set_dash([[4.0, 2.0]])
|
cairo: set_dash([[4.0, 2.0]])
|
||||||
cairo: stroke([])
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["white"])
|
||||||
pango: ellipsized?([])
|
pango: ellipsized?([])
|
||||||
cairo: restore([])
|
cairo: restore([])
|
||||||
cairo: save([])
|
cairo: save([])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue