class

CrImage::ClipContext

Inherits Reference / Object

ClipContext provides a clipping region for drawing operations.

When drawing within a clip context, all operations are restricted to the specified rectangular region. Pixels outside the region are not modified.

Example:

img = CrImage.rgba(400, 300, CrImage::Color::WHITE)

# Draw within a clipped region
img.with_clip(50, 50, 200, 150) do
  # This circle will be clipped to the 200x150 region
  img.draw_circle(100, 100, 80, color: CrImage::Color::RED, fill: true)
end

Constructors

new(image : CrImage::Image, clip_rect : CrImage::Rectangle)
Source

Instance methods

clip(rect : Rectangle) : Rectangle

Get the intersection of a rectangle with the clip region

Source
clip_rect
Source
image
Source
in_clip?(x : Int32, y : Int32) : Bool

Check if a point is within the clip region

Source
original_bounds
Source