struct Tessell::Render::Polygon

Defined in:

tessell/render/polygon.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(points : Array(Tessell::Point)) #

Holds the caller's array reference (no copy).


[View source]

Class Method Detail

def self.emit_fan(points : Array(Tessell::Point), sink : Slice(Float32)) : Int32 #

Emits a triangle fan from points[0] as explicit triangles in fan order: (p0,p1,p2), (p0,p2,p3), ... writing x,y for each vertex into sink. Total floats = 6*(n-2). Returns triangle count (n-2). Raises if sink small.


[View source]
def self.mask(points : Array(Tessell::Point), bounds : Tessell::Rect, sink : Bytes) : Int32 #

Writes w*h bytes (0/1 coverage) into caller-preallocated sink for bounds, sampling pixel centers at (bounds.x + x + 0.5, bounds.y + y + 0.5). Returns covered pixel count. Raises ArgumentError if sink is too small.


[View source]

Instance Method Detail

def bounds : Tessell::Rect #

[View source]
def contains?(p : Tessell::Point) : Bool #

Even-odd ray casting: a horizontal ray from p toward +x crosses an edge when (y0 > p.y) != (y1 > p.y) (so edges with y0 == y1 do not cross) and p.x is strictly less than the edge's x at p.y. Boundary/on-edge points: classification follows these strict comparisons and is not guaranteed to be treated as inside (edge cases may return false).


[View source]
def points : Array(Tessell::Point) #

[View source]
def signed_area : Float32 #

[View source]
def size : Int32 #

[View source]