ClipSimplifier¶
Overview¶
Simplification of a polygon for clipping output (compacts equal or axis-aligned-collinear points).
TODO: ClipSimplifier should accept Vector2, and store it if possible (instead of mutating)
TODO: Create a "not-a-simplifier" to swap into the simplifier to ensure testing works nicely.
TODO: ClipSimplifier collinearity checks, to see if we are missing things and this improves things drastically? TODO: Like, enable general collinearity, and inspect cases to see if it changes how many pixels get partials? TODO: Or improves performance
@author Jonathan Olson <jonathan.olson@colorado.edu>
Class ClipSimplifier¶
Constructor¶
new ClipSimplifier( checkGeneralCollinearity )¶
Instance Methods¶
addTransformed( matrix : Matrix3, x : number, y : number )¶
addPoint( p : Vector2 )¶
add( x : number, y : number )¶
We mutate points, so for the interest of safety, we'll end up copying the points. TODO: For performance (CPU), it would make sense to instead pass in (x,y,?:point) so we could use immutable points TODO: Only create points when needed - This would allow much better pass-through
hasPoints() : boolean¶
finalize() : Vector2[]¶
Treats the entire list of points so far as a closed polygon, completes simplification (between the start/end), returns the simplified points, AND resets the state for the next time
finalizeInto( polygons : Vector2[][] )¶
reset()¶
Static Methods¶
simplifyPolygon( polygon : Vector2[], checkGeneralCollinearity ) : Vector2[]¶
Source Code¶
See the source for ClipSimplifier.ts in the alpenglow repository.