class

CrImage::Draw::Path

Inherits Reference / Object

Path is an SVG-like path builder for complex shapes.

Supports move_to, line_to, quadratic bezier, cubic bezier, and close commands. Paths can be filled or stroked.

Example:

path = CrImage::Draw::Path.new
  .move_to(100, 100)
  .line_to(200, 100)
  .bezier_to(250, 100, 250, 150, 200, 150)
  .line_to(100, 150)
  .close

CrImage::Draw.fill_path(img, path, CrImage::Color::RED)

Constructors

new(segments_per_curve : Int32 = 32)
Source

Instance methods

bezier_to(c1x : Number, c1y : Number, c2x : Number, c2y : Number, x : Number, y : Number) : self

Draw a cubic bezier curve to (x, y) with control points (c1x, c1y) and (c2x, c2y).

Source
close

Close the current subpath by drawing a line back to the start.

Source
commands
Source
cubic_to(c1x : Number, c1y : Number, c2x : Number, c2y : Number, x : Number, y : Number) : self

Alias for bezier_to

Source
empty?

Returns true if the path is empty.

Source
flatten

Flattens the path to an array of points (converts curves to line segments).

Source
flatten_float

Flattens path to float points for higher precision AA rendering.

Source
line_to(x : Number, y : Number) : self

Draw a line to the specified position.

Source
move_to(x : Number, y : Number) : self

Move to a new position without drawing.

Source
quadratic_to(cx : Number, cy : Number, x : Number, y : Number) : self

Draw a quadratic bezier curve to (x, y) with control point (cx, cy).

Source