circle

Draw a partial or complete circle centered at the given coordinates

Options

All of these options support arrays and singleton expansion (except for range). See Squib Thinks in Arrays for deeper explanation.

x

default: 0

the x-coordinate to place, relative to the upper-left corner of the card and moving right as it increases. Supports Unit Conversion and XYWH Shorthands.

y

default: 0

the y-coordinate to place, relative to the upper-left corner of the card and moving downward as it increases. Supports Unit Conversion and XYWH Shorthands.

radius

default: 100

radius of the circle. Supports Unit Conversion.

arc_start

default: 0

angle on the circle to start an arc

arc_end

default: 2 * Math::PI

angle on the circle to end an arc

arc_direction

default: :clockwise

draw the arc clockwise or counterclockwise from arc_start to arc_end

arc_close

default: false

draw a straight line closing the arc

fill_color

default: '#0000' (fully transparent)

the color or gradient to fill with. See Specifying Colors & Gradients.

stroke_color

default: :black

the color with which to stroke the outside of the shape. See Specifying Colors & Gradients.

stroke_width

default: 2

the width of the outside stroke. Supports Unit Conversion.

stroke_strategy

default: :fill_first

Specify whether the stroke is done before (thinner) or after (thicker) filling the shape.

Must be either :fill_first or :stroke_first (or their string equivalents).

dash

default: '' (no dash pattern set)

Define a dash pattern for the stroke. This is a special string with space-separated numbers that define the pattern of on-and-off alternating strokes, measured in pixels or units. For example, '0.02in 0.02in' will be an equal on-and-off dash pattern. Supports Unit Conversion.

cap

default: :butt

Define how the end of the stroke is drawn. Options are :square, :butt, and :round (or string equivalents of those).

join

default: :mitre

Specifies how to render the junction of two lines when stroking. Options are :mitre, :round, and :bevel.

range

default: :all

the range of cards over which this will be rendered. See Using range to specify cards

layout

default: nil

entry in the layout to use as defaults for this command. See Layouts are Squib’s Best Feature.

Examples

This snippet and others like it live here
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'squib'

Squib::Deck.new do
  background color: :white

  grid x: 10, y: 10, width: 50,  height: 50,  stroke_color: '#0066FF', stroke_width: 1.5
  grid x: 10, y: 10, width: 200, height: 200, stroke_color: '#0066FF', stroke_width: 3

  rect x: 305, y: 105, width: 200, height: 50, dash: '4 2'

  rect x: 300, y: 300, width: 400, height: 400,
       fill_color: :blue, stroke_color: :red, stroke_width: 50.0,
       join: 'bevel'

  rect x: 550, y: 105, width: 100, height: 100,
       stroke_width: 5, stroke_color: :orange, angle: -0.2

  ellipse x: 675, y: 105, width: 65, height: 100,
       stroke_width: 5, stroke_color: :orange, angle: -0.2

  text str: 'Shapes!' # regression test for bug 248

  circle x: 450, y: 600, radius: 75,
         fill_color: :gray, stroke_color: :green, stroke_width: 8.0

  circle x: 600, y: 600, radius: 75, # partial circle
         arc_start: 1, arc_end: 4, arc_direction: :counter_clockwise,
         fill_color: :gray, stroke_color: :green, stroke_width: 8.0

  triangle x1: 50, y1: 50,
           x2: 150, y2: 150,
           x3: 75, y3: 250,
           fill_color: :gray, stroke_color: :green, stroke_width: 3.0

  line x1: 50, y1: 550,
       x2: 150, y2: 650,
       stroke_width: 25.0

  curve x1: 50,  y1: 850, cx1: 150, cy1: 700,
        x2: 625, y2: 900, cx2: 150, cy2: 700,
        stroke_width: 12.0, stroke_color: :cyan,
        fill_color: :burgundy, cap: 'round'

  ellipse x: 50, y: 925, width: 200, height: 100,
          stroke_width: 5.0, stroke_color: :cyan,
          fill_color: :burgundy

  star x: 300, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
       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,
          fill_color: :cyan, stroke_color: :burgundy, stroke_width: 2

  save_png prefix: 'shape_'
end