module CrImage::Operation::Draw

Overview

Draws shapes in the image

Taking sample image:

Woman with black turtleneck and white background
image.draw_square(40, 30, 80, 80, CrImage::Color.of("#00f"))
image.draw_circle(80, 70, 40, CrImage::Color.of("#00f"))
image.draw_line(50, 50, 70, 90, CrImage::Color.of("#0f0"))
Woman with blue box drawn around face Woman with blue circle drawn around face Woman with green line across face

Can also use the fill: true parameter to fill in the drawn shapes

Direct including types

Defined in:

cr-image/operation/draw.cr

Instance Method Summary

Instance Method Detail

def draw_circle(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self #

Draw a circle centered at x, y with radius


[View source]
def draw_circle(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self #

Draw a circle around the region's center (see Region#center)


[View source]
def draw_circle!(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self #

[View source]
def draw_circle!(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self #

Draw a circle around the region's center (see Region#center)


[View source]
def draw_line(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self #

[View source]
def draw_line!(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self #

Implementation of http://www.edepot.com/linec.html


[View source]
def draw_square(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self #

[View source]
def draw_square(region : Region, color : Color, *, fill : Bool = false) : self #

[View source]
def draw_square!(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self #

[View source]
def draw_square!(region : Region, color : Color, *, fill : Bool = false) : self #

[View source]