Clipper: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ <!-- GIDEROSOBJ:Clipper --> {{PLATFORMS ALL}} '''Available since:''' Gideros 2015.03.22<br/> === Description === The Clipper plugin wraps the Clipper polygon clippi..."
 
wip
Line 25: Line 25:
| style="width: 50%; vertical-align:top;"|
| style="width: 50%; vertical-align:top;"|
=== Methods ===
=== Methods ===
[[Controller:getControllerName]] ''gets the name of the controller''<br/><!--GIDEROSMTD:Controller:getControllerName(id) gets the name of the controller-->
[[Clipper.Polygon.new]] ''creates an empty polygon''<br/><!--GIDEROSMTD:Polygon.new() creates an empty polygon-->
[[Clipper.Polygon:addPoint]] ''appends a vertex to the polygon''<br/><!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon-->
[[Clipper.Polygon:getPoints]] ''returns all vertices of the polygon as a Lua table''<br/><!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table-->
[[Clipper.Polygon:getArea]] ''returns the signed area of the polygon''<br/><!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon-->
[[Clipper.Polygon:isClockwise]] ''returns the orientation of the polygon''<br/><!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon-->
[[Clipper.Polygon:clean]] ''removes self-intersections and very close vertices from the polygon in place''<br/><!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place-->
[[Clipper.Polygon:reverse]] ''reverses the order of the vertices in place, which flips the orientation of the polygon''<br/><!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon-->


| style="width: 50%; vertical-align:top;"|
| style="width: 50%; vertical-align:top;"|

Revision as of 02:14, 14 November 2026

Supported platforms:
Available since: Gideros 2015.03.22

Description

The Clipper plugin wraps the Clipper polygon clipping library for Gideros.

require "clipper"

Enable Clipper in Gideros Studio -> Plugins before use. This makes the two classes Polygon and Clipper available as globals.

It provides two classes:

  • Polygon: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)
  • Clipper: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)

All coordinates are integers. The plugin registers a weak table that keeps the C++ objects alive as long as their Lua wrappers exist, so polygons and clippers are garbage collected automatically.

Example

Methods

Clipper.Polygon.new creates an empty polygon
Clipper.Polygon:addPoint appends a vertex to the polygon
Clipper.Polygon:getPoints returns all vertices of the polygon as a Lua table
Clipper.Polygon:getArea returns the signed area of the polygon
Clipper.Polygon:isClockwise returns the orientation of the polygon
Clipper.Polygon:clean removes self-intersections and very close vertices from the polygon in place
Clipper.Polygon:reverse reverses the order of the vertices in place, which flips the orientation of the polygon

Events

Event.CONNECTED

Constants