<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.gideros.rocks/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MoKaLux</id>
	<title>GiderosMobile - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.gideros.rocks/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MoKaLux"/>
	<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php/Special:Contributions/MoKaLux"/>
	<updated>2026-11-17T11:50:45Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25552</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25552"/>
		<updated>2026-11-14T22:12:19Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
*Coordinates are integers. Fractional values passed to addPoint are truncated to integers by the C++ binding&lt;br /&gt;
*Polygons are implicitly closed: the last vertex connects back to the first. getArea(), simplify() and the Clipper operations all assume closed polygons&lt;br /&gt;
*clean(), reverse() and the offset methods that return a single polygon modify or replace data in place where stated; offset and simplify always return new Polygon objects and never modify the original&lt;br /&gt;
*Offset and simplify can produce several polygons (for example when a polygon splits into multiple parts); always iterate over the returned table&lt;br /&gt;
*getPolygonOffset currently ignores its joinType argument and always uses square joins, because of a bug in the C++ binding&lt;br /&gt;
*The Clipper engine keeps references to the polygons added to it, so they must not be garbage collected before execute is called. In practice the Lua wrappers stay alive as long as you hold them&lt;br /&gt;
*Boolean operations on empty polygon sets return an empty table, they do not raise an error&lt;br /&gt;
*Fill rules follow the Clipper library conventions; FILL_EVEN_ODD and FILL_NON_ZERO are the most commonly used&lt;br /&gt;
&lt;br /&gt;
=== Full Demo ===&lt;br /&gt;
&#039;&#039;&#039;[[Clipper Demo]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&#039;&#039;&#039;Boolean operations on two polygons&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local subject = Polygon.new()&lt;br /&gt;
subject:addPoint(0, 0)&lt;br /&gt;
subject:addPoint(200, 0)&lt;br /&gt;
subject:addPoint(200, 200)&lt;br /&gt;
subject:addPoint(0, 200)&lt;br /&gt;
&lt;br /&gt;
local clip = Polygon.new()&lt;br /&gt;
clip:addPoint(100, 50)&lt;br /&gt;
clip:addPoint(250, 150)&lt;br /&gt;
clip:addPoint(100, 250)&lt;br /&gt;
clip:addPoint(-50, 150)&lt;br /&gt;
&lt;br /&gt;
local c = Clipper.new()&lt;br /&gt;
c:addSubjectPolygon(subject)&lt;br /&gt;
c:addClipPolygon(clip)&lt;br /&gt;
&lt;br /&gt;
local inter = c:getIntersection(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local uni   = c:getUnion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local diff  = c:getDifference(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local xor   = c:getExclusion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;intersection polygons:&amp;quot;, #inter)&lt;br /&gt;
print(&amp;quot;union polygons:&amp;quot;, #uni)&lt;br /&gt;
print(&amp;quot;difference polygons:&amp;quot;, #diff)&lt;br /&gt;
print(&amp;quot;exclusion polygons:&amp;quot;, #xor)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Polygon.new]] &#039;&#039;creates an empty polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon.new() creates an empty polygon--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Polygon:addPoint]] &#039;&#039;appends a vertex to the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:clean]] &#039;&#039;removes self-intersections and very close vertices from the polygon in place&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place--&amp;gt;&lt;br /&gt;
[[Polygon:getArea]] &#039;&#039;returns the signed area of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:getLineOffset]] &#039;&#039;offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getLineOffset(delta, joinType, endType, limit) offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines--&amp;gt;&lt;br /&gt;
[[Polygon:getPoints]] &#039;&#039;returns all vertices of the polygon as a Lua table&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table--&amp;gt;&lt;br /&gt;
[[Polygon:getPolygonOffset]] &#039;&#039;offsets (insets or outsets) the polygon by delta units&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPolygonOffset(delta, joinType, limit, autoFix) offsets (insets or outsets) the polygon by delta units--&amp;gt;&lt;br /&gt;
[[Polygon:isClockwise]] &#039;&#039;returns the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:reverse]] &#039;&#039;reverses the order of the vertices in place, which flips the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:simplify]] &#039;&#039;simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:simplify(fillType) simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule--&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Clipper.new]] &#039;&#039;creates a new clipping engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper.new() creates a new clipping engine--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Clipper:addClipPolygon]] &#039;&#039;adds a polygon to the clip set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addClipPolygon(poly) adds a polygon to the clip set--&amp;gt;&lt;br /&gt;
[[Clipper:addSubjectPolygon]] &#039;&#039;adds a polygon to the subject set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addSubjectPolygon(poly) adds a polygon to the subject set--&amp;gt;&lt;br /&gt;
[[Clipper:clear]] &#039;&#039;removes all subject and clip polygons from the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:clear() removes all subject and clip polygons from the engine--&amp;gt;&lt;br /&gt;
[[Clipper:getBounds]] &#039;&#039;returns the bounding rectangle of all polygons added to the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getBounds() returns the bounding rectangle of all polygons added to the engine--&amp;gt;&lt;br /&gt;
[[Clipper:getDifference]] &#039;&#039;computes the subject polygons minus the clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getDifference(fillType1, fillType2) computes the subject polygons minus the clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getExclusion]] &#039;&#039;computes the symmetric difference (XOR) of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getExclusion(fillType1, fillType2) computes the symmetric difference (XOR) of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getIntersection]] &#039;&#039;computes the intersection of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getIntersection(fillType1, fillType2) computes the intersection of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getUnion]] &#039;&#039;computes the union of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getUnion(fillType1, fillType2) computes the union of the subject and clip polygons--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
=== Constants ===&lt;br /&gt;
The following constants are fields of the Polygon table.&lt;br /&gt;
&lt;br /&gt;
Fill rules (PolyFillType):&lt;br /&gt;
 Polygon.FILL_EVEN_ODD&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD even-odd rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NON_ZERO&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD non-zero winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_POSITIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD positive winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NEGATIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD negative winding rule--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Join types (JoinType), used by getPolygonOffset and getLineOffset:&lt;br /&gt;
 Polygon.JOINT_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_MITER&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) mitered joins--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
End types (EndType), used by getLineOffset:&lt;br /&gt;
 Polygon.END_CLOSED&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) closed path--&amp;gt;&lt;br /&gt;
 Polygon.END_BUTT&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) butt end--&amp;gt;&lt;br /&gt;
 Polygon.END_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) square end--&amp;gt;&lt;br /&gt;
 Polygon.END_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded end--&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:getUnion&amp;diff=25551</id>
		<title>Clipper:getUnion</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:getUnion&amp;diff=25551"/>
		<updated>2026-11-14T22:07:47Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Computes the union of the subject and clip polygons.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Clipper:getUnion(fillType1,fillType2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;fillType1&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the subject polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;fillType2&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the clip polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of Polygon objects (1 indexed) with the resulting polygons. May be empty when there is no overlap&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local res = clipper:getUnion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:addPoint&amp;diff=25550</id>
		<title>Polygon:addPoint</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:addPoint&amp;diff=25550"/>
		<updated>2026-11-14T22:06:00Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Appends a vertex to the polygon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Polygon:addPoint(x,y)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Points are stored in the order they are added; the polygon is implicitly closed (last point to first point) when used by Clipper or by getArea().&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;x&#039;&#039;&#039;: (number) horizontal coordinate, stored as an integer&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;y&#039;&#039;&#039;: (number) vertical coordinate, stored as an integer&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:getBounds&amp;diff=25549</id>
		<title>Clipper:getBounds</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:getBounds&amp;diff=25549"/>
		<updated>2026-11-14T22:04:54Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Returns the bounding rectangle of all polygons added to the engine....&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Returns the bounding rectangle of all polygons added to the engine.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(number), (number), (number), (number) = Clipper:getBounds()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (number, number, number, number) left, top, width, height&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local left, top, w, h = clipper:getBounds()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:getExclusion&amp;diff=25548</id>
		<title>Clipper:getExclusion</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:getExclusion&amp;diff=25548"/>
		<updated>2026-11-14T22:01:59Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Computes the symmetric difference (XOR) of the subject and clip pol...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Computes the symmetric difference (XOR) of the subject and clip polygons.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Clipper:getExclusion(fillType1,fillType2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;fillType1&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the subject polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;fillType2&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the clip polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of Polygon objects (1 indexed) with the resulting polygons. May be empty when there is no overlap&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local res = clipper:getExclusion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:getIntersection&amp;diff=25547</id>
		<title>Clipper:getIntersection</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:getIntersection&amp;diff=25547"/>
		<updated>2026-11-14T22:00:34Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Computes the intersection of the subject and clip polygons.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Clipper:getIntersection(fillType1,fillType2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;fillType1&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the subject polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;fillType2&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the clip polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of Polygon objects (1 indexed) with the resulting polygons. May be empty when there is no overlap&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local res = clipper:getIntersection(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:getDifference&amp;diff=25546</id>
		<title>Clipper:getDifference</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:getDifference&amp;diff=25546"/>
		<updated>2026-11-14T22:00:14Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Computes the subject polygons minus the clip polygons (subject - cl...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Computes the subject polygons minus the clip polygons (subject - clip).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Clipper:getDifference(fillType1,fillType2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;fillType1&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the subject polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;fillType2&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the clip polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of Polygon objects (1 indexed) with the resulting polygons. May be empty when there is no overlap&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local res = clipper:getDifference(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:getUnion&amp;diff=25545</id>
		<title>Clipper:getUnion</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:getUnion&amp;diff=25545"/>
		<updated>2026-11-14T21:58:45Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Computes the union of the subject and clip polygons. &amp;lt;syntaxhighlig...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Computes the union of the subject and clip polygons.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Clipper:getUnion(fillType1, fillType2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;fillType1&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the subject polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;fillType2&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the clip polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of Polygon objects (1 indexed) with the resulting polygons. May be empty when there is no overlap&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local res = clipper:getUnion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:getIntersection&amp;diff=25544</id>
		<title>Clipper:getIntersection</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:getIntersection&amp;diff=25544"/>
		<updated>2026-11-14T21:56:12Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Computes the intersection of the subject and clip polygons. &amp;lt;syntax...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Computes the intersection of the subject and clip polygons.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Clipper:getIntersection(fillType1, fillType2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;fillType1&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the subject polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;fillType2&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) fill rule for the clip polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of Polygon objects (1 indexed) with the resulting polygons. May be empty when there is no overlap&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local res = clipper:getIntersection(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:clear&amp;diff=25543</id>
		<title>Clipper:clear</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:clear&amp;diff=25543"/>
		<updated>2026-11-14T21:53:28Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Removes all subject and clip polygons from the engine so it can be...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Removes all subject and clip polygons from the engine so it can be reused for another operation.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Clipper:clear()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
clipper:clear()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:addClipPolygon&amp;diff=25542</id>
		<title>Clipper:addClipPolygon</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:addClipPolygon&amp;diff=25542"/>
		<updated>2026-11-14T19:12:54Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Adds a polygon to the clip set. Several clip polygons can be added...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Adds a polygon to the clip set. Several clip polygons can be added before executing an operation.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Clipper:addClipPolygon(poly)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;poly&#039;&#039;&#039;: (Polygon) the polygon to add&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper:addSubjectPolygon&amp;diff=25541</id>
		<title>Clipper:addSubjectPolygon</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper:addSubjectPolygon&amp;diff=25541"/>
		<updated>2026-11-14T19:11:23Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Adds a polygon to the subject set. Several subject polygons can be...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Adds a polygon to the subject set. Several subject polygons can be added before executing an operation.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Clipper:addSubjectPolygon(poly)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;poly&#039;&#039;&#039;: (Polygon) the polygon to add&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper.new&amp;diff=25540</id>
		<title>Clipper.new</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper.new&amp;diff=25540"/>
		<updated>2026-11-14T19:08:47Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Creates a new clipping engine. &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; (Clippe...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Creates a new clipping engine.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(Clipper) = Clipper.new()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Clipper combines subject and clip polygons and computes their boolean result.&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (Clipper) a new engine&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local clipper = Clipper.new()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:getLineOffset&amp;diff=25539</id>
		<title>Polygon:getLineOffset</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:getLineOffset&amp;diff=25539"/>
		<updated>2026-11-14T19:06:20Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Offsets an open polyline (a polygon treated as an open path) by del...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Polygon:getLineOffset(delta,joinType,endType,limit)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;delta&#039;&#039;&#039;: (number) offset distance in units&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;joinType&#039;&#039;&#039;: (number, optional, default = Polygon.JOINT_SQUARE) one of JOINT_SQUARE, JOINT_ROUND, JOINT_MITER&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;endType&#039;&#039;&#039;: (number, optional, default = Polygon.END_SQUARE) one of END_CLOSED, END_BUTT, END_SQUARE, END_ROUND&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;limit&#039;&#039;&#039;: (number, optional, default = 0) miter limit&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of Polygon objects (1 indexed), each one an offset polyline&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local lines = poly:getLineOffset(6, Polygon.JOINT_ROUND, Polygon.END_ROUND, 2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:getPolygonOffset&amp;diff=25538</id>
		<title>Polygon:getPolygonOffset</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:getPolygonOffset&amp;diff=25538"/>
		<updated>2026-11-14T18:37:41Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Offsets (insets or outsets) the polygon by delta units. &amp;lt;syntaxhigh...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Offsets (insets or outsets) the polygon by delta units.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Polygon:getPolygonOffset(delta,joinType,limit,autoFix)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A positive delta grows the polygon outward, a negative delta shrinks it inward.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;delta&#039;&#039;&#039;: (number) offset distance in units&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;joinType&#039;&#039;&#039;: (number, optional, default = Polygon.JOINT_SQUARE) one of JOINT_SQUARE, JOINT_ROUND, JOINT_MITER&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;limit&#039;&#039;&#039;: (number, optional, default = 0) miter limit, used only with JOINT_MITER&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;autoFix&#039;&#039;&#039;: (boolean, optional, default = true) whether to fix self-intersections in the result&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of Polygon objects (1 indexed). The result may contain several polygons&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Note ===&lt;br /&gt;
In this version of the plugin the joinType argument is ignored by the C++ binding and square joins are always used.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local grown = poly:getPolygonOffset(8, Polygon.JOINT_ROUND, 2, true)&lt;br /&gt;
local shrunk = poly:getPolygonOffset(-4)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:simplify&amp;diff=25537</id>
		<title>Polygon:simplify</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:simplify&amp;diff=25537"/>
		<updated>2026-11-14T18:24:07Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Simplifies the polygon by removing redundant vertices and resolving...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Polygon:simplify(fillType)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;fillType&#039;&#039;&#039;: (number, optional, default = Polygon.FILL_EVEN_ODD) one of Polygon.FILL_EVEN_ODD, FILL_NON_ZERO, FILL_POSITIVE, FILL_NEGATIVE&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of Polygon objects (1 indexed). The result may contain several polygons when the input is self-intersecting&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local res = poly:simplify(Polygon.FILL_EVEN_ODD)&lt;br /&gt;
for i = 1, #res do&lt;br /&gt;
	print(&amp;quot;simplified polygon&amp;quot;, i, &amp;quot;area&amp;quot;, res[i]:getArea())&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:reverse&amp;diff=25536</id>
		<title>Polygon:reverse</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:reverse&amp;diff=25536"/>
		<updated>2026-11-14T18:19:05Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Reverses the order of the vertices in place, which flips the orient...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Reverses the order of the vertices in place, which flips the orientation of the polygon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Polygon:reverse()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
poly:reverse()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:clean&amp;diff=25535</id>
		<title>Polygon:clean</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:clean&amp;diff=25535"/>
		<updated>2026-11-14T18:17:07Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Removes self-intersections and very close vertices from the polygon...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Removes self-intersections and very close vertices from the polygon in place.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Polygon:clean(distance)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The polygon is replaced by its cleaned version.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;distance&#039;&#039;&#039;: (number, optional, default = 1.415) minimum distance between vertices; vertices closer than this are merged&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
poly:clean(1.415)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:isClockwise&amp;diff=25534</id>
		<title>Polygon:isClockwise</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:isClockwise&amp;diff=25534"/>
		<updated>2026-11-14T18:13:04Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Returns the orientation of the polygon. &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Returns the orientation of the polygon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(bool) = Polygon:isClockwise()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (boolean) true if the vertices are clockwise&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
if poly:isClockwise() then&lt;br /&gt;
	poly:reverse()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:getArea&amp;diff=25533</id>
		<title>Polygon:getArea</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:getArea&amp;diff=25533"/>
		<updated>2026-11-14T18:10:53Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Returns the signed area of the polygon. The sign follows the orient...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Returns the signed area of the polygon. The sign follows the orientation of the vertices (positive for counter clockwise, negative for clockwise).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(number) = Polygon:getArea()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (number) signed area in square units&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local area = poly:getArea()&lt;br /&gt;
print(&amp;quot;area =&amp;quot;, math.abs(area))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:getPoints&amp;diff=25532</id>
		<title>Polygon:getPoints</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:getPoints&amp;diff=25532"/>
		<updated>2026-11-14T18:08:04Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Returns all vertices of the polygon as a Lua table. &amp;lt;syntaxhighligh...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Returns all vertices of the polygon as a Lua table.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = Polygon:getPoints()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) array of points, each point is a table { 1 = x, 2 = y }, indexed from 1&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local pts = poly:getPoints()&lt;br /&gt;
for i = 1, #pts do&lt;br /&gt;
	print(pts[i][1], pts[i][2])&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25531</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25531"/>
		<updated>2026-11-14T04:34:55Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: /* Full Demo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
*Coordinates are integers. Fractional values passed to addPoint are truncated to integers by the C++ binding&lt;br /&gt;
*Polygons are implicitly closed: the last vertex connects back to the first. getArea(), simplify() and the Clipper operations all assume closed polygons&lt;br /&gt;
*clean(), reverse() and the offset methods that return a single polygon modify or replace data in place where stated; offset and simplify always return new Polygon objects and never modify the original&lt;br /&gt;
*Offset and simplify can produce several polygons (for example when a polygon splits into multiple parts); always iterate over the returned table&lt;br /&gt;
*getPolygonOffset currently ignores its joinType argument and always uses square joins, because of a bug in the C++ binding&lt;br /&gt;
*The Clipper engine keeps references to the polygons added to it, so they must not be garbage collected before execute is called. In practice the Lua wrappers stay alive as long as you hold them&lt;br /&gt;
*Boolean operations on empty polygon sets return an empty table, they do not raise an error&lt;br /&gt;
*Fill rules follow the Clipper library conventions; FILL_EVEN_ODD and FILL_NON_ZERO are the most commonly used&lt;br /&gt;
&lt;br /&gt;
=== Full Demo ===&lt;br /&gt;
&#039;&#039;&#039;[[Clipper Demo]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&#039;&#039;&#039;Boolean operations on two polygons&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local subject = Polygon.new()&lt;br /&gt;
subject:addPoint(0, 0)&lt;br /&gt;
subject:addPoint(200, 0)&lt;br /&gt;
subject:addPoint(200, 200)&lt;br /&gt;
subject:addPoint(0, 200)&lt;br /&gt;
&lt;br /&gt;
local clip = Polygon.new()&lt;br /&gt;
clip:addPoint(100, 50)&lt;br /&gt;
clip:addPoint(250, 150)&lt;br /&gt;
clip:addPoint(100, 250)&lt;br /&gt;
clip:addPoint(-50, 150)&lt;br /&gt;
&lt;br /&gt;
local c = Clipper.new()&lt;br /&gt;
c:addSubjectPolygon(subject)&lt;br /&gt;
c:addClipPolygon(clip)&lt;br /&gt;
&lt;br /&gt;
local inter = c:getIntersection(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local uni   = c:getUnion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local diff  = c:getDifference(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local xor   = c:getExclusion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;intersection polygons:&amp;quot;, #inter)&lt;br /&gt;
print(&amp;quot;union polygons:&amp;quot;, #uni)&lt;br /&gt;
print(&amp;quot;difference polygons:&amp;quot;, #diff)&lt;br /&gt;
print(&amp;quot;exclusion polygons:&amp;quot;, #xor)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Polygon.new]] &#039;&#039;creates an empty polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon.new() creates an empty polygon--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Polygon:addPoint]] &#039;&#039;appends a vertex to the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:getPoints]] &#039;&#039;returns all vertices of the polygon as a Lua table&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table--&amp;gt;&lt;br /&gt;
[[Polygon:getArea]] &#039;&#039;returns the signed area of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:isClockwise]] &#039;&#039;returns the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:clean]] &#039;&#039;removes self-intersections and very close vertices from the polygon in place&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place--&amp;gt;&lt;br /&gt;
[[Polygon:reverse]] &#039;&#039;reverses the order of the vertices in place, which flips the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:simplify]] &#039;&#039;simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:simplify(fillType) simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule--&amp;gt;&lt;br /&gt;
[[Polygon:getPolygonOffset]] &#039;&#039;offsets (insets or outsets) the polygon by delta units&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPolygonOffset(delta, joinType, limit, autoFix) offsets (insets or outsets) the polygon by delta units--&amp;gt;&lt;br /&gt;
[[Polygon:getLineOffset]] &#039;&#039;offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getLineOffset(delta, joinType, endType, limit) offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines--&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Clipper.new]] &#039;&#039;creates a new clipping engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper.new() creates a new clipping engine--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Clipper:addSubjectPolygon]] &#039;&#039;adds a polygon to the subject set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addSubjectPolygon(poly) adds a polygon to the subject set--&amp;gt;&lt;br /&gt;
[[Clipper:addClipPolygon]] &#039;&#039;adds a polygon to the clip set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addClipPolygon(poly) adds a polygon to the clip set--&amp;gt;&lt;br /&gt;
[[Clipper:clear]] &#039;&#039;removes all subject and clip polygons from the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:clear() removes all subject and clip polygons from the engine--&amp;gt;&lt;br /&gt;
[[Clipper:getIntersection]] &#039;&#039;computes the intersection of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getIntersection(fillType1, fillType2) computes the intersection of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getUnion]] &#039;&#039;computes the union of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getUnion(fillType1, fillType2) computes the union of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getDifference]] &#039;&#039;computes the subject polygons minus the clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getDifference(fillType1, fillType2) computes the subject polygons minus the clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getExclusion]] &#039;&#039;computes the symmetric difference (XOR) of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getExclusion(fillType1, fillType2) computes the symmetric difference (XOR) of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getBounds]] &#039;&#039;returns the bounding rectangle of all polygons added to the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getBounds() returns the bounding rectangle of all polygons added to the engine--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
=== Constants ===&lt;br /&gt;
The following constants are fields of the Polygon table.&lt;br /&gt;
&lt;br /&gt;
Fill rules (PolyFillType):&lt;br /&gt;
 Polygon.FILL_EVEN_ODD&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD even-odd rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NON_ZERO&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD non-zero winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_POSITIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD positive winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NEGATIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD negative winding rule--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Join types (JoinType), used by getPolygonOffset and getLineOffset:&lt;br /&gt;
 Polygon.JOINT_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_MITER&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) mitered joins--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
End types (EndType), used by getLineOffset:&lt;br /&gt;
 Polygon.END_CLOSED&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) closed path--&amp;gt;&lt;br /&gt;
 Polygon.END_BUTT&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) butt end--&amp;gt;&lt;br /&gt;
 Polygon.END_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) square end--&amp;gt;&lt;br /&gt;
 Polygon.END_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded end--&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25530</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25530"/>
		<updated>2026-11-14T04:34:37Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
*Coordinates are integers. Fractional values passed to addPoint are truncated to integers by the C++ binding&lt;br /&gt;
*Polygons are implicitly closed: the last vertex connects back to the first. getArea(), simplify() and the Clipper operations all assume closed polygons&lt;br /&gt;
*clean(), reverse() and the offset methods that return a single polygon modify or replace data in place where stated; offset and simplify always return new Polygon objects and never modify the original&lt;br /&gt;
*Offset and simplify can produce several polygons (for example when a polygon splits into multiple parts); always iterate over the returned table&lt;br /&gt;
*getPolygonOffset currently ignores its joinType argument and always uses square joins, because of a bug in the C++ binding&lt;br /&gt;
*The Clipper engine keeps references to the polygons added to it, so they must not be garbage collected before execute is called. In practice the Lua wrappers stay alive as long as you hold them&lt;br /&gt;
*Boolean operations on empty polygon sets return an empty table, they do not raise an error&lt;br /&gt;
*Fill rules follow the Clipper library conventions; FILL_EVEN_ODD and FILL_NON_ZERO are the most commonly used&lt;br /&gt;
&lt;br /&gt;
=== Full Demo ===&lt;br /&gt;
[[Clipper Demo]]&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&#039;&#039;&#039;Boolean operations on two polygons&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local subject = Polygon.new()&lt;br /&gt;
subject:addPoint(0, 0)&lt;br /&gt;
subject:addPoint(200, 0)&lt;br /&gt;
subject:addPoint(200, 200)&lt;br /&gt;
subject:addPoint(0, 200)&lt;br /&gt;
&lt;br /&gt;
local clip = Polygon.new()&lt;br /&gt;
clip:addPoint(100, 50)&lt;br /&gt;
clip:addPoint(250, 150)&lt;br /&gt;
clip:addPoint(100, 250)&lt;br /&gt;
clip:addPoint(-50, 150)&lt;br /&gt;
&lt;br /&gt;
local c = Clipper.new()&lt;br /&gt;
c:addSubjectPolygon(subject)&lt;br /&gt;
c:addClipPolygon(clip)&lt;br /&gt;
&lt;br /&gt;
local inter = c:getIntersection(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local uni   = c:getUnion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local diff  = c:getDifference(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local xor   = c:getExclusion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;intersection polygons:&amp;quot;, #inter)&lt;br /&gt;
print(&amp;quot;union polygons:&amp;quot;, #uni)&lt;br /&gt;
print(&amp;quot;difference polygons:&amp;quot;, #diff)&lt;br /&gt;
print(&amp;quot;exclusion polygons:&amp;quot;, #xor)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Polygon.new]] &#039;&#039;creates an empty polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon.new() creates an empty polygon--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Polygon:addPoint]] &#039;&#039;appends a vertex to the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:getPoints]] &#039;&#039;returns all vertices of the polygon as a Lua table&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table--&amp;gt;&lt;br /&gt;
[[Polygon:getArea]] &#039;&#039;returns the signed area of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:isClockwise]] &#039;&#039;returns the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:clean]] &#039;&#039;removes self-intersections and very close vertices from the polygon in place&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place--&amp;gt;&lt;br /&gt;
[[Polygon:reverse]] &#039;&#039;reverses the order of the vertices in place, which flips the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:simplify]] &#039;&#039;simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:simplify(fillType) simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule--&amp;gt;&lt;br /&gt;
[[Polygon:getPolygonOffset]] &#039;&#039;offsets (insets or outsets) the polygon by delta units&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPolygonOffset(delta, joinType, limit, autoFix) offsets (insets or outsets) the polygon by delta units--&amp;gt;&lt;br /&gt;
[[Polygon:getLineOffset]] &#039;&#039;offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getLineOffset(delta, joinType, endType, limit) offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines--&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Clipper.new]] &#039;&#039;creates a new clipping engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper.new() creates a new clipping engine--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Clipper:addSubjectPolygon]] &#039;&#039;adds a polygon to the subject set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addSubjectPolygon(poly) adds a polygon to the subject set--&amp;gt;&lt;br /&gt;
[[Clipper:addClipPolygon]] &#039;&#039;adds a polygon to the clip set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addClipPolygon(poly) adds a polygon to the clip set--&amp;gt;&lt;br /&gt;
[[Clipper:clear]] &#039;&#039;removes all subject and clip polygons from the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:clear() removes all subject and clip polygons from the engine--&amp;gt;&lt;br /&gt;
[[Clipper:getIntersection]] &#039;&#039;computes the intersection of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getIntersection(fillType1, fillType2) computes the intersection of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getUnion]] &#039;&#039;computes the union of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getUnion(fillType1, fillType2) computes the union of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getDifference]] &#039;&#039;computes the subject polygons minus the clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getDifference(fillType1, fillType2) computes the subject polygons minus the clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getExclusion]] &#039;&#039;computes the symmetric difference (XOR) of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getExclusion(fillType1, fillType2) computes the symmetric difference (XOR) of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getBounds]] &#039;&#039;returns the bounding rectangle of all polygons added to the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getBounds() returns the bounding rectangle of all polygons added to the engine--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
=== Constants ===&lt;br /&gt;
The following constants are fields of the Polygon table.&lt;br /&gt;
&lt;br /&gt;
Fill rules (PolyFillType):&lt;br /&gt;
 Polygon.FILL_EVEN_ODD&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD even-odd rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NON_ZERO&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD non-zero winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_POSITIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD positive winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NEGATIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD negative winding rule--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Join types (JoinType), used by getPolygonOffset and getLineOffset:&lt;br /&gt;
 Polygon.JOINT_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_MITER&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) mitered joins--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
End types (EndType), used by getLineOffset:&lt;br /&gt;
 Polygon.END_CLOSED&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) closed path--&amp;gt;&lt;br /&gt;
 Polygon.END_BUTT&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) butt end--&amp;gt;&lt;br /&gt;
 Polygon.END_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) square end--&amp;gt;&lt;br /&gt;
 Polygon.END_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded end--&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper_Demo&amp;diff=25529</id>
		<title>Clipper Demo</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper_Demo&amp;diff=25529"/>
		<updated>2026-11-14T04:33:46Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Full Clipper demo for Gideros. &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; -- Clip...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Full Clipper demo for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Clipper demo for Gideros (Luau)&lt;br /&gt;
-- Boolean operations, offsets, cleaning, simplifying and reversing&lt;br /&gt;
-- of polygons, built on top of the Clipper plugin.&lt;br /&gt;
&lt;br /&gt;
local clipperOk = pcall(require, &amp;quot;clipper&amp;quot;)&lt;br /&gt;
if not clipperOk or not Polygon or not Clipper then&lt;br /&gt;
    local t = TextField.new(nil, &amp;quot;Clipper plugin not enabled&amp;quot;)&lt;br /&gt;
    t:setTextColor(0xff0000)&lt;br /&gt;
    t:setPosition(10, 40)&lt;br /&gt;
    stage:addChild(t)&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Palette and layout&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local C = {&lt;br /&gt;
    bg = 0xf4f4f4, card = 0xffffff, line = 0xcccccc,&lt;br /&gt;
    subject = 0x2a6fdb, clip = 0xe05252, result = 0x2faa4a,&lt;br /&gt;
    bounds = 0xffb000, text = 0x222222, dim = 0x666666,&lt;br /&gt;
    accent = 0x2a6fdb, btn = 0xe8e8e8, btnActive = 0xcfe3ff,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local DESIGN_W, DESIGN_H = 320, 480&lt;br /&gt;
local CANVAS_X, CANVAS_Y = 10, 70&lt;br /&gt;
local CANVAS_W, CANVAS_H = 300, 250&lt;br /&gt;
&lt;br /&gt;
local screenW, screenH = application:getContentWidth(), application:getContentHeight()&lt;br /&gt;
application:setBackgroundColor(C.bg)&lt;br /&gt;
&lt;br /&gt;
local ui = Sprite.new()&lt;br /&gt;
ui:setPosition(math.floor((screenW - DESIGN_W) / 2), math.floor((screenH - DESIGN_H) / 2))&lt;br /&gt;
stage:addChild(ui)&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- UI helpers&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function addPanel(parent, x, y, w, h, color)&lt;br /&gt;
    local p = Pixel.new(color, 1, w, h)&lt;br /&gt;
    p:setPosition(x, y)&lt;br /&gt;
    parent:addChild(p)&lt;br /&gt;
    return p&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function addText(parent, text, x, y, color, scale)&lt;br /&gt;
    local t = TextField.new(nil, text)&lt;br /&gt;
    t:setTextColor(color)&lt;br /&gt;
    t:setPosition(x, y)&lt;br /&gt;
    if scale then t:setScale(scale) end&lt;br /&gt;
    parent:addChild(t)&lt;br /&gt;
    return t&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function centerX(t, y)&lt;br /&gt;
    t:setPosition(math.floor((DESIGN_W - t:getWidth()) / 2), y)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local buttonRegistry = {}&lt;br /&gt;
&lt;br /&gt;
local function makeButton(x, y, w, h, label, onClick)&lt;br /&gt;
    local root = Sprite.new()&lt;br /&gt;
    root:setPosition(x, y)&lt;br /&gt;
&lt;br /&gt;
    local bg = Pixel.new(C.btn, 1, w, h)&lt;br /&gt;
    root:addChild(bg)&lt;br /&gt;
&lt;br /&gt;
    local txt = TextField.new(nil, label)&lt;br /&gt;
    txt:setTextColor(C.text)&lt;br /&gt;
    txt:setPosition(math.floor((w - txt:getWidth()) / 2),&lt;br /&gt;
        math.floor((h - txt:getHeight()) / 2))&lt;br /&gt;
    root:addChild(txt)&lt;br /&gt;
&lt;br /&gt;
    local active = false&lt;br /&gt;
    local function refresh(down)&lt;br /&gt;
        bg:setColor(down and C.btnActive or (active and C.btnActive or C.btn))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    function root:setText(s)&lt;br /&gt;
        txt:setText(s)&lt;br /&gt;
        txt:setPosition(math.floor((w - txt:getWidth()) / 2),&lt;br /&gt;
            math.floor((h - txt:getHeight()) / 2))&lt;br /&gt;
    end&lt;br /&gt;
    function root:setActive(v)&lt;br /&gt;
        active = v&lt;br /&gt;
        refresh(false)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local entry = {root = root, x = x, y = y, w = w, h = h,&lt;br /&gt;
        onClick = onClick, refresh = refresh, active = function(v) active = v end}&lt;br /&gt;
    table.insert(buttonRegistry, entry)&lt;br /&gt;
&lt;br /&gt;
    ui:addChild(root)&lt;br /&gt;
    return root&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Polygon helpers&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function makePolygon(points)&lt;br /&gt;
    local p = Polygon.new()&lt;br /&gt;
    for _, pt in ipairs(points) do&lt;br /&gt;
        p:addPoint(pt[1], pt[2])&lt;br /&gt;
    end&lt;br /&gt;
    return p&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function pointsFromPoly(poly)&lt;br /&gt;
    local pts = poly:getPoints()&lt;br /&gt;
    local out = {}&lt;br /&gt;
    for i = 1, #pts do&lt;br /&gt;
        out[i] = { pts[i][1], pts[i][2] }&lt;br /&gt;
    end&lt;br /&gt;
    return out&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function pointsFromPolys(polys)&lt;br /&gt;
    local out = {}&lt;br /&gt;
    for i = 1, #polys do&lt;br /&gt;
        out[i] = pointsFromPoly(polys[i])&lt;br /&gt;
    end&lt;br /&gt;
    return out&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function polyArea(points)&lt;br /&gt;
    if #points &amp;lt; 3 then return 0 end&lt;br /&gt;
    local p = makePolygon(points)&lt;br /&gt;
    return p:getArea()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function boundsOf(points)&lt;br /&gt;
    if #points == 0 then return 0, 0, 0, 0 end&lt;br /&gt;
    local minX, minY = points[1][1], points[1][2]&lt;br /&gt;
    local maxX, maxY = minX, minY&lt;br /&gt;
    for i = 2, #points do&lt;br /&gt;
        local x, y = points[i][1], points[i][2]&lt;br /&gt;
        if x &amp;lt; minX then minX = x end&lt;br /&gt;
        if y &amp;lt; minY then minY = y end&lt;br /&gt;
        if x &amp;gt; maxX then maxX = x end&lt;br /&gt;
        if y &amp;gt; maxY then maxY = y end&lt;br /&gt;
    end&lt;br /&gt;
    return minX, minY, maxX - minX, maxY - minY&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- State&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local subjectPoints = { {80, 80}, {230, 90}, {220, 230}, {90, 220} }&lt;br /&gt;
local clipPoints = { {150, 60}, {270, 170}, {160, 290}, {40, 180} }&lt;br /&gt;
&lt;br /&gt;
local active = &amp;quot;subject&amp;quot;          -- &amp;quot;subject&amp;quot; or &amp;quot;clip&amp;quot;&lt;br /&gt;
local currentOp = &amp;quot;intersection&amp;quot;  -- intersection / union / difference / exclusion&lt;br /&gt;
local fillRule = Polygon.FILL_EVEN_ODD&lt;br /&gt;
local showResult = true&lt;br /&gt;
&lt;br /&gt;
local resultPolys = {}   -- list of point-lists&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Canvas and shapes&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
addPanel(ui, CANVAS_X - 2, CANVAS_Y - 2, CANVAS_W + 4, CANVAS_H + 4, C.line)&lt;br /&gt;
local canvasBg = addPanel(ui, CANVAS_X, CANVAS_Y, CANVAS_W, CANVAS_H, C.card)&lt;br /&gt;
&lt;br /&gt;
local subjShape = Shape.new()&lt;br /&gt;
local clipShape = Shape.new()&lt;br /&gt;
local resShape = Shape.new()&lt;br /&gt;
local boundsShape = Shape.new()&lt;br /&gt;
local lineShape = nil&lt;br /&gt;
&lt;br /&gt;
local canvas = Sprite.new()&lt;br /&gt;
canvas:setPosition(CANVAS_X, CANVAS_Y)&lt;br /&gt;
ui:addChild(canvas)&lt;br /&gt;
canvas:addChild(subjShape)&lt;br /&gt;
canvas:addChild(clipShape)&lt;br /&gt;
canvas:addChild(resShape)&lt;br /&gt;
canvas:addChild(boundsShape)&lt;br /&gt;
&lt;br /&gt;
local function drawPolygon(shape, points, fillColor, fillAlpha, lineColor, lineWidth)&lt;br /&gt;
    shape:clear()&lt;br /&gt;
    if #points &amp;lt; 2 then return end&lt;br /&gt;
    if #points &amp;lt; 3 then&lt;br /&gt;
        shape:setLineStyle(lineWidth or 2, lineColor, 1)&lt;br /&gt;
        shape:beginPath()&lt;br /&gt;
        shape:moveTo(points[1][1], points[1][2])&lt;br /&gt;
        for i = 2, #points do&lt;br /&gt;
            shape:lineTo(points[i][1], points[i][2])&lt;br /&gt;
        end&lt;br /&gt;
        shape:endPath()&lt;br /&gt;
        return&lt;br /&gt;
    end&lt;br /&gt;
    shape:setFillStyle(Shape.SOLID, fillColor, fillAlpha or 0.4)&lt;br /&gt;
    shape:setLineStyle(lineWidth or 2, lineColor, 1)&lt;br /&gt;
    shape:beginPath()&lt;br /&gt;
    shape:moveTo(points[1][1], points[1][2])&lt;br /&gt;
    for i = 2, #points do&lt;br /&gt;
        shape:lineTo(points[i][1], points[i][2])&lt;br /&gt;
    end&lt;br /&gt;
    shape:closePath()&lt;br /&gt;
    shape:endPath()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function drawPolys(shape, polys, fillColor, fillAlpha, lineColor, lineWidth)&lt;br /&gt;
    shape:clear()&lt;br /&gt;
    for _, pts in ipairs(polys) do&lt;br /&gt;
        if #pts &amp;gt;= 3 then&lt;br /&gt;
            shape:setFillStyle(Shape.SOLID, fillColor, fillAlpha or 0.4)&lt;br /&gt;
            shape:setLineStyle(lineWidth or 2, lineColor, 1)&lt;br /&gt;
            shape:beginPath()&lt;br /&gt;
            shape:moveTo(pts[1][1], pts[1][2])&lt;br /&gt;
            for i = 2, #pts do&lt;br /&gt;
                shape:lineTo(pts[i][1], pts[i][2])&lt;br /&gt;
            end&lt;br /&gt;
            shape:closePath()&lt;br /&gt;
            shape:endPath()&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local infoLabel = addText(ui, &amp;quot;&amp;quot;, 10, 322, C.dim)&lt;br /&gt;
&lt;br /&gt;
local function rebuild()&lt;br /&gt;
    local subjPts = subjectPoints&lt;br /&gt;
    local clipPts = clipPoints&lt;br /&gt;
&lt;br /&gt;
    drawPolygon(subjShape, subjPts, C.subject, 0.25, C.subject, 2)&lt;br /&gt;
    drawPolygon(clipShape, clipPts, C.clip, 0.20, C.clip, 2)&lt;br /&gt;
&lt;br /&gt;
    -- clear the transient line-offset shape&lt;br /&gt;
    if lineShape then&lt;br /&gt;
        lineShape:removeFromParent()&lt;br /&gt;
        lineShape = nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- run the boolean operation&lt;br /&gt;
    resultPolys = {}&lt;br /&gt;
    if #subjPts &amp;gt;= 3 and #clipPts &amp;gt;= 3 then&lt;br /&gt;
        local c = Clipper.new()&lt;br /&gt;
        c:addSubjectPolygon(makePolygon(subjPts))&lt;br /&gt;
        c:addClipPolygon(makePolygon(clipPts))&lt;br /&gt;
        local raw&lt;br /&gt;
        if currentOp == &amp;quot;intersection&amp;quot; then&lt;br /&gt;
            raw = c:getIntersection(fillRule, fillRule)&lt;br /&gt;
        elseif currentOp == &amp;quot;union&amp;quot; then&lt;br /&gt;
            raw = c:getUnion(fillRule, fillRule)&lt;br /&gt;
        elseif currentOp == &amp;quot;difference&amp;quot; then&lt;br /&gt;
            raw = c:getDifference(fillRule, fillRule)&lt;br /&gt;
        else&lt;br /&gt;
            raw = c:getExclusion(fillRule, fillRule)&lt;br /&gt;
        end&lt;br /&gt;
        resultPolys = pointsFromPolys(raw)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if showResult then&lt;br /&gt;
        drawPolys(resShape, resultPolys, C.result, 0.45, 0x1f7a33, 2)&lt;br /&gt;
    else&lt;br /&gt;
        resShape:clear()&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- bounds of the active polygon&lt;br /&gt;
    boundsShape:clear()&lt;br /&gt;
    local activePts = (active == &amp;quot;subject&amp;quot;) and subjPts or clipPts&lt;br /&gt;
    local bx, by, bw, bh = boundsOf(activePts)&lt;br /&gt;
    if bw &amp;gt; 0 and bh &amp;gt; 0 then&lt;br /&gt;
        boundsShape:setLineStyle(2, C.bounds, 1)&lt;br /&gt;
        boundsShape:beginPath()&lt;br /&gt;
        boundsShape:moveTo(bx, by)&lt;br /&gt;
        boundsShape:lineTo(bx + bw, by)&lt;br /&gt;
        boundsShape:lineTo(bx + bw, by + bh)&lt;br /&gt;
        boundsShape:lineTo(bx, by + bh)&lt;br /&gt;
        boundsShape:closePath()&lt;br /&gt;
        boundsShape:endPath()&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- info text&lt;br /&gt;
    local subjArea = polyArea(subjPts)&lt;br /&gt;
    local clipArea = polyArea(clipPts)&lt;br /&gt;
    local resArea = 0&lt;br /&gt;
    for _, rp in ipairs(resultPolys) do&lt;br /&gt;
        resArea = resArea + polyArea(rp)&lt;br /&gt;
    end&lt;br /&gt;
    infoLabel:setText(string.format(&lt;br /&gt;
        &amp;quot;subj %d pts  %.0f px2   clip %d pts  %.0f px2   result %d poly  %.0f px2&amp;quot;,&lt;br /&gt;
        #subjPts, subjArea, #clipPts, clipArea, #resultPolys, resArea))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Touch: add points to the active polygon&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- canvas touches are handled by the single dispatcher below&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Controls&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- Header&lt;br /&gt;
addPanel(ui, 16, 12, 4, 24, C.accent)&lt;br /&gt;
addText(ui, &amp;quot;Clipper&amp;quot;, 28, 10, C.text, 2)&lt;br /&gt;
addText(ui, &amp;quot;polygon boolean operations and offsets&amp;quot;, 16, 40, C.dim)&lt;br /&gt;
addPanel(ui, 16, 58, 288, 1, C.line)&lt;br /&gt;
&lt;br /&gt;
local activeBtn&lt;br /&gt;
activeBtn = makeButton(10, 332, 92, 30, &amp;quot;EDIT: SUBJECT&amp;quot;, function()&lt;br /&gt;
    active = (active == &amp;quot;subject&amp;quot;) and &amp;quot;clip&amp;quot; or &amp;quot;subject&amp;quot;&lt;br /&gt;
    activeBtn:setText(&amp;quot;EDIT: &amp;quot; .. active:upper())&lt;br /&gt;
    rebuild()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
local undoBtn = makeButton(108, 332, 62, 30, &amp;quot;UNDO&amp;quot;, function()&lt;br /&gt;
    local pts = (active == &amp;quot;subject&amp;quot;) and subjectPoints or clipPoints&lt;br /&gt;
    if #pts &amp;gt; 0 then pts[#pts] = nil end&lt;br /&gt;
    rebuild()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
local clearBtn = makeButton(176, 332, 62, 30, &amp;quot;CLEAR&amp;quot;, function()&lt;br /&gt;
    if active == &amp;quot;subject&amp;quot; then subjectPoints = {} else clipPoints = {} end&lt;br /&gt;
    rebuild()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
local fillBtn&lt;br /&gt;
fillBtn = makeButton(244, 332, 66, 30, &amp;quot;FILL EO&amp;quot;, function()&lt;br /&gt;
    if fillRule == Polygon.FILL_EVEN_ODD then&lt;br /&gt;
        fillRule = Polygon.FILL_NON_ZERO&lt;br /&gt;
        fillBtn:setText(&amp;quot;FILL NZ&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
        fillRule = Polygon.FILL_EVEN_ODD&lt;br /&gt;
        fillBtn:setText(&amp;quot;FILL EO&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    rebuild()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
-- Operation buttons&lt;br /&gt;
local function opButton(label, opName, x)&lt;br /&gt;
    return makeButton(x, 368, 72, 30, label, function()&lt;br /&gt;
        currentOp = opName&lt;br /&gt;
        rebuild()&lt;br /&gt;
    end)&lt;br /&gt;
end&lt;br /&gt;
opButton(&amp;quot;INTERSECT&amp;quot;, &amp;quot;intersection&amp;quot;, 10)&lt;br /&gt;
opButton(&amp;quot;UNION&amp;quot;, &amp;quot;union&amp;quot;, 88)&lt;br /&gt;
opButton(&amp;quot;DIFFERENCE&amp;quot;, &amp;quot;difference&amp;quot;, 166)&lt;br /&gt;
opButton(&amp;quot;XOR&amp;quot;, &amp;quot;exclusion&amp;quot;, 244)&lt;br /&gt;
&lt;br /&gt;
-- Offset / clean / reverse / simplify&lt;br /&gt;
local function offsetActive(delta)&lt;br /&gt;
    local pts = (active == &amp;quot;subject&amp;quot;) and subjectPoints or clipPoints&lt;br /&gt;
    if #pts &amp;lt; 3 then return end&lt;br /&gt;
    local poly = makePolygon(pts)&lt;br /&gt;
    local res = poly:getPolygonOffset(delta, Polygon.JOINT_ROUND, 2, true)&lt;br /&gt;
    if res and #res &amp;gt; 0 then&lt;br /&gt;
        local newPts = pointsFromPoly(res[1])&lt;br /&gt;
        if #newPts &amp;gt;= 3 then&lt;br /&gt;
            if active == &amp;quot;subject&amp;quot; then subjectPoints = newPts&lt;br /&gt;
            else clipPoints = newPts end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    rebuild()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
makeButton(10, 404, 58, 30, &amp;quot;OFF+&amp;quot;, function() offsetActive(8) end)&lt;br /&gt;
makeButton(74, 404, 58, 30, &amp;quot;OFF-&amp;quot;, function() offsetActive(-8) end)&lt;br /&gt;
&lt;br /&gt;
makeButton(138, 404, 58, 30, &amp;quot;CLEAN&amp;quot;, function()&lt;br /&gt;
    local pts = (active == &amp;quot;subject&amp;quot;) and subjectPoints or clipPoints&lt;br /&gt;
    if #pts &amp;lt; 3 then return end&lt;br /&gt;
    local poly = makePolygon(pts)&lt;br /&gt;
    poly:clean(1.415)&lt;br /&gt;
    local newPts = pointsFromPoly(poly)&lt;br /&gt;
    if active == &amp;quot;subject&amp;quot; then subjectPoints = newPts&lt;br /&gt;
    else clipPoints = newPts end&lt;br /&gt;
    rebuild()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
makeButton(202, 404, 58, 30, &amp;quot;REVERSE&amp;quot;, function()&lt;br /&gt;
    local pts = (active == &amp;quot;subject&amp;quot;) and subjectPoints or clipPoints&lt;br /&gt;
    if #pts &amp;lt; 3 then return end&lt;br /&gt;
    local poly = makePolygon(pts)&lt;br /&gt;
    poly:reverse()&lt;br /&gt;
    local newPts = pointsFromPoly(poly)&lt;br /&gt;
    if active == &amp;quot;subject&amp;quot; then subjectPoints = newPts&lt;br /&gt;
    else clipPoints = newPts end&lt;br /&gt;
    rebuild()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
makeButton(266, 404, 44, 30, &amp;quot;SIMPL&amp;quot;, function()&lt;br /&gt;
    local pts = (active == &amp;quot;subject&amp;quot;) and subjectPoints or clipPoints&lt;br /&gt;
    if #pts &amp;lt; 3 then return end&lt;br /&gt;
    local poly = makePolygon(pts)&lt;br /&gt;
    local res = poly:simplify(fillRule)&lt;br /&gt;
    if res and #res &amp;gt; 0 then&lt;br /&gt;
        local newPts = pointsFromPoly(res[1])&lt;br /&gt;
        if #newPts &amp;gt;= 3 then&lt;br /&gt;
            if active == &amp;quot;subject&amp;quot; then subjectPoints = newPts&lt;br /&gt;
            else clipPoints = newPts end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    rebuild()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
-- Show / hide result&lt;br /&gt;
local showBtn&lt;br /&gt;
showBtn = makeButton(10, 440, 96, 30, &amp;quot;RESULT: ON&amp;quot;, function()&lt;br /&gt;
    showResult = not showResult&lt;br /&gt;
    showBtn:setText(showResult and &amp;quot;RESULT: ON&amp;quot; or &amp;quot;RESULT: OFF&amp;quot;)&lt;br /&gt;
    rebuild()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
-- Line offset demo: offsets the active polygon as a polyline (open shape)&lt;br /&gt;
makeButton(112, 440, 96, 30, &amp;quot;LINE OFF&amp;quot;, function()&lt;br /&gt;
    local pts = (active == &amp;quot;subject&amp;quot;) and subjectPoints or clipPoints&lt;br /&gt;
    if #pts &amp;lt; 2 then return end&lt;br /&gt;
    local poly = makePolygon(pts)&lt;br /&gt;
    local res = poly:getLineOffset(6, Polygon.JOINT_ROUND, Polygon.END_ROUND, 2)&lt;br /&gt;
    if lineShape then lineShape:removeFromParent() end&lt;br /&gt;
    lineShape = Shape.new()&lt;br /&gt;
    lineShape:setLineStyle(2, 0xffb000, 1)&lt;br /&gt;
    for _, lp in ipairs(pointsFromPolys(res)) do&lt;br /&gt;
        if #lp &amp;gt;= 2 then&lt;br /&gt;
            lineShape:beginPath()&lt;br /&gt;
            lineShape:moveTo(lp[1][1], lp[1][2])&lt;br /&gt;
            for i = 2, #lp do&lt;br /&gt;
                lineShape:lineTo(lp[i][1], lp[i][2])&lt;br /&gt;
            end&lt;br /&gt;
            lineShape:endPath()&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    canvas:addChild(lineShape)&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
local legend = addText(ui, &amp;quot;blue = subject   red = clip   green = result   yellow = bounds&amp;quot;, 10, 474, C.dim)&lt;br /&gt;
legend:setScale(0.85)&lt;br /&gt;
&lt;br /&gt;
-- Single touch dispatcher: avoids Gideros delivering one touch to several sprites.&lt;br /&gt;
local pressedButton = nil&lt;br /&gt;
&lt;br /&gt;
local function findButtonAt(px, py)&lt;br /&gt;
    for i = #buttonRegistry, 1, -1 do&lt;br /&gt;
        local b = buttonRegistry[i]&lt;br /&gt;
        if px &amp;gt;= b.x and px &amp;lt;= b.x + b.w and py &amp;gt;= b.y and py &amp;lt;= b.y + b.h then&lt;br /&gt;
            return b&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
ui:addEventListener(Event.TOUCHES_BEGIN, function(e)&lt;br /&gt;
    local ux, uy = ui:globalToLocal(e.touch.x, e.touch.y)&lt;br /&gt;
    local b = findButtonAt(ux, uy)&lt;br /&gt;
    if b then&lt;br /&gt;
        pressedButton = b&lt;br /&gt;
        b.refresh(true)&lt;br /&gt;
    else&lt;br /&gt;
        pressedButton = nil&lt;br /&gt;
        -- canvas tap: add a point to the active polygon&lt;br /&gt;
        local cx, cy = canvas:globalToLocal(e.touch.x, e.touch.y)&lt;br /&gt;
        if cx &amp;gt;= 0 and cy &amp;gt;= 0 and cx &amp;lt;= CANVAS_W and cy &amp;lt;= CANVAS_H then&lt;br /&gt;
            local pts = (active == &amp;quot;subject&amp;quot;) and subjectPoints or clipPoints&lt;br /&gt;
            pts[#pts + 1] = { math.floor(cx), math.floor(cy) }&lt;br /&gt;
            rebuild()&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return true&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
ui:addEventListener(Event.TOUCHES_END, function(e)&lt;br /&gt;
    if pressedButton then&lt;br /&gt;
        pressedButton.refresh(false)&lt;br /&gt;
        if pressedButton.onClick then pressedButton.onClick() end&lt;br /&gt;
        pressedButton = nil&lt;br /&gt;
    end&lt;br /&gt;
    return true&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
ui:addEventListener(Event.TOUCHES_CANCEL, function(e)&lt;br /&gt;
    if pressedButton then&lt;br /&gt;
        pressedButton.refresh(false)&lt;br /&gt;
        pressedButton = nil&lt;br /&gt;
    end&lt;br /&gt;
    return true&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
rebuild()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon.new&amp;diff=25528</id>
		<title>Polygon.new</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon.new&amp;diff=25528"/>
		<updated>2026-11-14T03:44:04Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Creates an empty polygon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(Polygon) = Polygon.new()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (Polygon) the new polygon&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local poly = Polygon.new()&lt;br /&gt;
poly:addPoint(0, 0)&lt;br /&gt;
poly:addPoint(100, 0)&lt;br /&gt;
poly:addPoint(100, 100)&lt;br /&gt;
poly:addPoint(0, 100)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon:addPoint&amp;diff=25527</id>
		<title>Polygon:addPoint</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon:addPoint&amp;diff=25527"/>
		<updated>2026-11-14T03:41:13Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Appends a vertex to the polygon. &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; Polyg...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Appends a vertex to the polygon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Polygon:addPoint(x, y)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Points are stored in the order they are added; the polygon is implicitly closed (last point to first point) when used by Clipper or by getArea().&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;x&#039;&#039;&#039;: (number) horizontal coordinate, stored as an integer&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;y&#039;&#039;&#039;: (number) vertical coordinate, stored as an integer&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25526</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25526"/>
		<updated>2026-11-14T03:36:49Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
*Coordinates are integers. Fractional values passed to addPoint are truncated to integers by the C++ binding&lt;br /&gt;
*Polygons are implicitly closed: the last vertex connects back to the first. getArea(), simplify() and the Clipper operations all assume closed polygons&lt;br /&gt;
*clean(), reverse() and the offset methods that return a single polygon modify or replace data in place where stated; offset and simplify always return new Polygon objects and never modify the original&lt;br /&gt;
*Offset and simplify can produce several polygons (for example when a polygon splits into multiple parts); always iterate over the returned table&lt;br /&gt;
*getPolygonOffset currently ignores its joinType argument and always uses square joins, because of a bug in the C++ binding&lt;br /&gt;
*The Clipper engine keeps references to the polygons added to it, so they must not be garbage collected before execute is called. In practice the Lua wrappers stay alive as long as you hold them&lt;br /&gt;
*Boolean operations on empty polygon sets return an empty table, they do not raise an error&lt;br /&gt;
*Fill rules follow the Clipper library conventions; FILL_EVEN_ODD and FILL_NON_ZERO are the most commonly used&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&#039;&#039;&#039;Boolean operations on two polygons&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local subject = Polygon.new()&lt;br /&gt;
subject:addPoint(0, 0)&lt;br /&gt;
subject:addPoint(200, 0)&lt;br /&gt;
subject:addPoint(200, 200)&lt;br /&gt;
subject:addPoint(0, 200)&lt;br /&gt;
&lt;br /&gt;
local clip = Polygon.new()&lt;br /&gt;
clip:addPoint(100, 50)&lt;br /&gt;
clip:addPoint(250, 150)&lt;br /&gt;
clip:addPoint(100, 250)&lt;br /&gt;
clip:addPoint(-50, 150)&lt;br /&gt;
&lt;br /&gt;
local c = Clipper.new()&lt;br /&gt;
c:addSubjectPolygon(subject)&lt;br /&gt;
c:addClipPolygon(clip)&lt;br /&gt;
&lt;br /&gt;
local inter = c:getIntersection(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local uni   = c:getUnion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local diff  = c:getDifference(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local xor   = c:getExclusion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;intersection polygons:&amp;quot;, #inter)&lt;br /&gt;
print(&amp;quot;union polygons:&amp;quot;, #uni)&lt;br /&gt;
print(&amp;quot;difference polygons:&amp;quot;, #diff)&lt;br /&gt;
print(&amp;quot;exclusion polygons:&amp;quot;, #xor)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Polygon.new]] &#039;&#039;creates an empty polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon.new() creates an empty polygon--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Polygon:addPoint]] &#039;&#039;appends a vertex to the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:getPoints]] &#039;&#039;returns all vertices of the polygon as a Lua table&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table--&amp;gt;&lt;br /&gt;
[[Polygon:getArea]] &#039;&#039;returns the signed area of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:isClockwise]] &#039;&#039;returns the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:clean]] &#039;&#039;removes self-intersections and very close vertices from the polygon in place&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place--&amp;gt;&lt;br /&gt;
[[Polygon:reverse]] &#039;&#039;reverses the order of the vertices in place, which flips the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:simplify]] &#039;&#039;simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:simplify(fillType) simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule--&amp;gt;&lt;br /&gt;
[[Polygon:getPolygonOffset]] &#039;&#039;offsets (insets or outsets) the polygon by delta units&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPolygonOffset(delta, joinType, limit, autoFix) offsets (insets or outsets) the polygon by delta units--&amp;gt;&lt;br /&gt;
[[Polygon:getLineOffset]] &#039;&#039;offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getLineOffset(delta, joinType, endType, limit) offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines--&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Clipper.new]] &#039;&#039;creates a new clipping engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper.new() creates a new clipping engine--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Clipper:addSubjectPolygon]] &#039;&#039;adds a polygon to the subject set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addSubjectPolygon(poly) adds a polygon to the subject set--&amp;gt;&lt;br /&gt;
[[Clipper:addClipPolygon]] &#039;&#039;adds a polygon to the clip set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addClipPolygon(poly) adds a polygon to the clip set--&amp;gt;&lt;br /&gt;
[[Clipper:clear]] &#039;&#039;removes all subject and clip polygons from the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:clear() removes all subject and clip polygons from the engine--&amp;gt;&lt;br /&gt;
[[Clipper:getIntersection]] &#039;&#039;computes the intersection of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getIntersection(fillType1, fillType2) computes the intersection of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getUnion]] &#039;&#039;computes the union of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getUnion(fillType1, fillType2) computes the union of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getDifference]] &#039;&#039;computes the subject polygons minus the clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getDifference(fillType1, fillType2) computes the subject polygons minus the clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getExclusion]] &#039;&#039;computes the symmetric difference (XOR) of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getExclusion(fillType1, fillType2) computes the symmetric difference (XOR) of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getBounds]] &#039;&#039;returns the bounding rectangle of all polygons added to the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getBounds() returns the bounding rectangle of all polygons added to the engine--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
=== Constants ===&lt;br /&gt;
The following constants are fields of the Polygon table.&lt;br /&gt;
&lt;br /&gt;
Fill rules (PolyFillType):&lt;br /&gt;
 Polygon.FILL_EVEN_ODD&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD even-odd rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NON_ZERO&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD non-zero winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_POSITIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD positive winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NEGATIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD negative winding rule--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Join types (JoinType), used by getPolygonOffset and getLineOffset:&lt;br /&gt;
 Polygon.JOINT_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_MITER&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) mitered joins--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
End types (EndType), used by getLineOffset:&lt;br /&gt;
 Polygon.END_CLOSED&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) closed path--&amp;gt;&lt;br /&gt;
 Polygon.END_BUTT&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) butt end--&amp;gt;&lt;br /&gt;
 Polygon.END_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) square end--&amp;gt;&lt;br /&gt;
 Polygon.END_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded end--&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Polygon.new&amp;diff=25525</id>
		<title>Polygon.new</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Polygon.new&amp;diff=25525"/>
		<updated>2026-11-14T03:34:51Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Clipper&amp;lt;br/&amp;gt;  === Description === Creates a new clipping engine. &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; (Clippe...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Clipper]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Creates a new clipping engine.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(Clipper) = Clipper.new()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Clipper combines subject and clip polygons and computes their boolean result.&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (Clipper) the new engine&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Clipper}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Template:Spout&amp;diff=25524</id>
		<title>Template:Spout</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Template:Spout&amp;diff=25524"/>
		<updated>2026-11-14T03:33:55Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
----&lt;br /&gt;
{{Special:PrefixIndex/Spout}}&lt;br /&gt;
&lt;br /&gt;
{{Gideros deco stars01}}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Spout]]&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Category:Clipper&amp;diff=25523</id>
		<title>Category:Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Category:Clipper&amp;diff=25523"/>
		<updated>2026-11-14T03:31:41Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Redirected page to Clipper&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Clipper]]&lt;br /&gt;
[[Category:Plugins]]&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Sprite.new&amp;diff=25522</id>
		<title>Sprite.new</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Sprite.new&amp;diff=25522"/>
		<updated>2026-11-14T03:28:54Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2011.6&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Sprite]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Creates a new Sprite object.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(Sprite) = Sprite.new()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (Sprite) the new Sprite object&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Sprite}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Template:Clipper&amp;diff=25521</id>
		<title>Template:Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Template:Clipper&amp;diff=25521"/>
		<updated>2026-11-14T03:28:28Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot; ---- *Clipper {{Special:PrefixIndex/Polygon}} {{Special:PrefixIndex/Clipper}}  {{Gideros deco stars01}}  {{GIDEROS IMPORTANT LINKS}}  Category:Clipper&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
----&lt;br /&gt;
*[[Clipper]]&lt;br /&gt;
{{Special:PrefixIndex/Polygon}}&lt;br /&gt;
{{Special:PrefixIndex/Clipper}}&lt;br /&gt;
&lt;br /&gt;
{{Gideros deco stars01}}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Clipper]]&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25520</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25520"/>
		<updated>2026-11-14T03:19:54Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: wip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
*Coordinates are integers. Fractional values passed to addPoint are truncated to integers by the C++ binding&lt;br /&gt;
*Polygons are implicitly closed: the last vertex connects back to the first. getArea(), simplify() and the Clipper operations all assume closed polygons&lt;br /&gt;
*clean(), reverse() and the offset methods that return a single polygon modify or replace data in place where stated; offset and simplify always return new Polygon objects and never modify the original&lt;br /&gt;
*Offset and simplify can produce several polygons (for example when a polygon splits into multiple parts); always iterate over the returned table&lt;br /&gt;
*getPolygonOffset currently ignores its joinType argument and always uses square joins, because of a bug in the C++ binding&lt;br /&gt;
*The Clipper engine keeps references to the polygons added to it, so they must not be garbage collected before execute is called. In practice the Lua wrappers stay alive as long as you hold them&lt;br /&gt;
*Boolean operations on empty polygon sets return an empty table, they do not raise an error&lt;br /&gt;
*Fill rules follow the Clipper library conventions; FILL_EVEN_ODD and FILL_NON_ZERO are the most commonly used&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&#039;&#039;&#039;Boolean operations on two polygons&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local subject = Polygon.new()&lt;br /&gt;
subject:addPoint(0, 0)&lt;br /&gt;
subject:addPoint(200, 0)&lt;br /&gt;
subject:addPoint(200, 200)&lt;br /&gt;
subject:addPoint(0, 200)&lt;br /&gt;
&lt;br /&gt;
local clip = Polygon.new()&lt;br /&gt;
clip:addPoint(100, 50)&lt;br /&gt;
clip:addPoint(250, 150)&lt;br /&gt;
clip:addPoint(100, 250)&lt;br /&gt;
clip:addPoint(-50, 150)&lt;br /&gt;
&lt;br /&gt;
local c = Clipper.new()&lt;br /&gt;
c:addSubjectPolygon(subject)&lt;br /&gt;
c:addClipPolygon(clip)&lt;br /&gt;
&lt;br /&gt;
local inter = c:getIntersection(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local uni   = c:getUnion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local diff  = c:getDifference(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local xor   = c:getExclusion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;intersection polygons:&amp;quot;, #inter)&lt;br /&gt;
print(&amp;quot;union polygons:&amp;quot;, #uni)&lt;br /&gt;
print(&amp;quot;difference polygons:&amp;quot;, #diff)&lt;br /&gt;
print(&amp;quot;exclusion polygons:&amp;quot;, #xor)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Polygon.new]] &#039;&#039;creates an empty polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon.new() creates an empty polygon--&amp;gt;&lt;br /&gt;
[[Polygon:addPoint]] &#039;&#039;appends a vertex to the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:getPoints]] &#039;&#039;returns all vertices of the polygon as a Lua table&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table--&amp;gt;&lt;br /&gt;
[[Polygon:getArea]] &#039;&#039;returns the signed area of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:isClockwise]] &#039;&#039;returns the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:clean]] &#039;&#039;removes self-intersections and very close vertices from the polygon in place&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place--&amp;gt;&lt;br /&gt;
[[Polygon:reverse]] &#039;&#039;reverses the order of the vertices in place, which flips the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:simplify]] &#039;&#039;simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:simplify(fillType) simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule--&amp;gt;&lt;br /&gt;
[[Polygon:getPolygonOffset]] &#039;&#039;offsets (insets or outsets) the polygon by delta units&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPolygonOffset(delta, joinType, limit, autoFix) offsets (insets or outsets) the polygon by delta units--&amp;gt;&lt;br /&gt;
[[Polygon:getLineOffset]] &#039;&#039;offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getLineOffset(delta, joinType, endType, limit) offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Clipper.new]] &#039;&#039;creates a new clipping engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper.new() creates a new clipping engine--&amp;gt;&lt;br /&gt;
[[Clipper:addSubjectPolygon]] &#039;&#039;adds a polygon to the subject set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addSubjectPolygon(poly) adds a polygon to the subject set--&amp;gt;&lt;br /&gt;
[[Clipper:addClipPolygon]] &#039;&#039;adds a polygon to the clip set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addClipPolygon(poly) adds a polygon to the clip set--&amp;gt;&lt;br /&gt;
[[Clipper:clear]] &#039;&#039;removes all subject and clip polygons from the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:clear() removes all subject and clip polygons from the engine--&amp;gt;&lt;br /&gt;
[[Clipper:getIntersection]] &#039;&#039;computes the intersection of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getIntersection(fillType1, fillType2) computes the intersection of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getUnion]] &#039;&#039;computes the union of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getUnion(fillType1, fillType2) computes the union of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getDifference]] &#039;&#039;computes the subject polygons minus the clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getDifference(fillType1, fillType2) computes the subject polygons minus the clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getExclusion]] &#039;&#039;computes the symmetric difference (XOR) of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getExclusion(fillType1, fillType2) computes the symmetric difference (XOR) of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getBounds]] &#039;&#039;returns the bounding rectangle of all polygons added to the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getBounds() returns the bounding rectangle of all polygons added to the engine--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
=== Constants ===&lt;br /&gt;
The following constants are fields of the Polygon table.&lt;br /&gt;
&lt;br /&gt;
Fill rules (PolyFillType):&lt;br /&gt;
 Polygon.FILL_EVEN_ODD&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD even-odd rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NON_ZERO&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD non-zero winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_POSITIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD positive winding rule--&amp;gt;&lt;br /&gt;
 Polygon.FILL_NEGATIVE&amp;lt;!--GIDEROSCST:Polygon.FILL_EVEN_ODD negative winding rule--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Join types (JoinType), used by getPolygonOffset and getLineOffset:&lt;br /&gt;
 Polygon.JOINT_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded joins--&amp;gt;&lt;br /&gt;
 Polygon.JOINT_MITER&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) mitered joins--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
End types (EndType), used by getLineOffset:&lt;br /&gt;
 Polygon.END_CLOSED&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) closed path--&amp;gt;&lt;br /&gt;
 Polygon.END_BUTT&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) butt end--&amp;gt;&lt;br /&gt;
 Polygon.END_SQUARE&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) square end--&amp;gt;&lt;br /&gt;
 Polygon.END_ROUND&amp;lt;!--GIDEROSCST:Polygon.JOINT_SQUARE square (mitered) rounded end--&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25519</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25519"/>
		<updated>2026-11-14T03:08:10Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: wip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
*Coordinates are integers. Fractional values passed to addPoint are truncated to integers by the C++ binding&lt;br /&gt;
*Polygons are implicitly closed: the last vertex connects back to the first. getArea(), simplify() and the Clipper operations all assume closed polygons&lt;br /&gt;
*clean(), reverse() and the offset methods that return a single polygon modify or replace data in place where stated; offset and simplify always return new Polygon objects and never modify the original&lt;br /&gt;
*Offset and simplify can produce several polygons (for example when a polygon splits into multiple parts); always iterate over the returned table&lt;br /&gt;
*getPolygonOffset currently ignores its joinType argument and always uses square joins, because of a bug in the C++ binding&lt;br /&gt;
*The Clipper engine keeps references to the polygons added to it, so they must not be garbage collected before execute is called. In practice the Lua wrappers stay alive as long as you hold them&lt;br /&gt;
*Boolean operations on empty polygon sets return an empty table, they do not raise an error&lt;br /&gt;
*Fill rules follow the Clipper library conventions; FILL_EVEN_ODD and FILL_NON_ZERO are the most commonly used&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&#039;&#039;&#039;Boolean operations on two polygons&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local subject = Polygon.new()&lt;br /&gt;
subject:addPoint(0, 0)&lt;br /&gt;
subject:addPoint(200, 0)&lt;br /&gt;
subject:addPoint(200, 200)&lt;br /&gt;
subject:addPoint(0, 200)&lt;br /&gt;
&lt;br /&gt;
local clip = Polygon.new()&lt;br /&gt;
clip:addPoint(100, 50)&lt;br /&gt;
clip:addPoint(250, 150)&lt;br /&gt;
clip:addPoint(100, 250)&lt;br /&gt;
clip:addPoint(-50, 150)&lt;br /&gt;
&lt;br /&gt;
local c = Clipper.new()&lt;br /&gt;
c:addSubjectPolygon(subject)&lt;br /&gt;
c:addClipPolygon(clip)&lt;br /&gt;
&lt;br /&gt;
local inter = c:getIntersection(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local uni   = c:getUnion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local diff  = c:getDifference(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
local xor   = c:getExclusion(Polygon.FILL_EVEN_ODD, Polygon.FILL_EVEN_ODD)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;intersection polygons:&amp;quot;, #inter)&lt;br /&gt;
print(&amp;quot;union polygons:&amp;quot;, #uni)&lt;br /&gt;
print(&amp;quot;difference polygons:&amp;quot;, #diff)&lt;br /&gt;
print(&amp;quot;exclusion polygons:&amp;quot;, #xor)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Polygon.new]] &#039;&#039;creates an empty polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon.new() creates an empty polygon--&amp;gt;&lt;br /&gt;
[[Polygon:addPoint]] &#039;&#039;appends a vertex to the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:getPoints]] &#039;&#039;returns all vertices of the polygon as a Lua table&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table--&amp;gt;&lt;br /&gt;
[[Polygon:getArea]] &#039;&#039;returns the signed area of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:isClockwise]] &#039;&#039;returns the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:clean]] &#039;&#039;removes self-intersections and very close vertices from the polygon in place&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place--&amp;gt;&lt;br /&gt;
[[Polygon:reverse]] &#039;&#039;reverses the order of the vertices in place, which flips the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:simplify]] &#039;&#039;simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:simplify(fillType) simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule--&amp;gt;&lt;br /&gt;
[[Polygon:getPolygonOffset]] &#039;&#039;offsets (insets or outsets) the polygon by delta units&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPolygonOffset(delta, joinType, limit, autoFix) offsets (insets or outsets) the polygon by delta units--&amp;gt;&lt;br /&gt;
[[Polygon:getLineOffset]] &#039;&#039;offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getLineOffset(delta, joinType, endType, limit) offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Clipper.new]] &#039;&#039;creates a new clipping engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper.new() creates a new clipping engine--&amp;gt;&lt;br /&gt;
[[Clipper:addSubjectPolygon]] &#039;&#039;adds a polygon to the subject set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addSubjectPolygon(poly) adds a polygon to the subject set--&amp;gt;&lt;br /&gt;
[[Clipper:addClipPolygon]] &#039;&#039;adds a polygon to the clip set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addClipPolygon(poly) adds a polygon to the clip set--&amp;gt;&lt;br /&gt;
[[Clipper:clear]] &#039;&#039;removes all subject and clip polygons from the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:clear() removes all subject and clip polygons from the engine--&amp;gt;&lt;br /&gt;
[[Clipper:getIntersection]] &#039;&#039;computes the intersection of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getIntersection(fillType1, fillType2) computes the intersection of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getUnion]] &#039;&#039;computes the union of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getUnion(fillType1, fillType2) computes the union of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getDifference]] &#039;&#039;computes the subject polygons minus the clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getDifference(fillType1, fillType2) computes the subject polygons minus the clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getExclusion]] &#039;&#039;computes the symmetric difference (XOR) of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getExclusion(fillType1, fillType2) computes the symmetric difference (XOR) of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getBounds]] &#039;&#039;returns the bounding rectangle of all polygons added to the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getBounds() returns the bounding rectangle of all polygons added to the engine--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
=== Constants ===&lt;br /&gt;
&#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25518</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25518"/>
		<updated>2026-11-14T02:52:31Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: wip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Polygon.new]] &#039;&#039;creates an empty polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon.new() creates an empty polygon--&amp;gt;&lt;br /&gt;
[[Polygon:addPoint]] &#039;&#039;appends a vertex to the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:getPoints]] &#039;&#039;returns all vertices of the polygon as a Lua table&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table--&amp;gt;&lt;br /&gt;
[[Polygon:getArea]] &#039;&#039;returns the signed area of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:isClockwise]] &#039;&#039;returns the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:clean]] &#039;&#039;removes self-intersections and very close vertices from the polygon in place&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place--&amp;gt;&lt;br /&gt;
[[Polygon:reverse]] &#039;&#039;reverses the order of the vertices in place, which flips the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:simplify]] &#039;&#039;simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:simplify(fillType) simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule--&amp;gt;&lt;br /&gt;
[[Polygon:getPolygonOffset]] &#039;&#039;offsets (insets or outsets) the polygon by delta units&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPolygonOffset(delta, joinType, limit, autoFix) offsets (insets or outsets) the polygon by delta units--&amp;gt;&lt;br /&gt;
[[Polygon:getLineOffset]] &#039;&#039;offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getLineOffset(delta, joinType, endType, limit) offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Clipper.new]] &#039;&#039;creates a new clipping engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper.new() creates a new clipping engine--&amp;gt;&lt;br /&gt;
[[Clipper:addSubjectPolygon]] &#039;&#039;adds a polygon to the subject set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addSubjectPolygon(poly) adds a polygon to the subject set--&amp;gt;&lt;br /&gt;
[[Clipper:addClipPolygon]] &#039;&#039;adds a polygon to the clip set&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:addClipPolygon(poly) adds a polygon to the clip set--&amp;gt;&lt;br /&gt;
[[Clipper:clear]] &#039;&#039;removes all subject and clip polygons from the engine&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:clear() removes all subject and clip polygons from the engine--&amp;gt;&lt;br /&gt;
[[Clipper:getIntersection]] &#039;&#039;computes the intersection of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getIntersection(fillType1, fillType2) computes the intersection of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getUnion]] &#039;&#039;computes the union of the subject and clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getUnion(fillType1, fillType2) computes the union of the subject and clip polygons--&amp;gt;&lt;br /&gt;
[[Clipper:getDifference]] &#039;&#039;computes the subject polygons minus the clip polygons&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Clipper:getDifference(fillType1, fillType2) computes the subject polygons minus the clip polygons--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
[[Event.CONNECTED]]&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSEVT:Event.CONNECTED connected--&amp;gt;&lt;br /&gt;
=== Constants ===&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25517</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25517"/>
		<updated>2026-11-14T02:44:32Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: wip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Polygon.new]] &#039;&#039;creates an empty polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon.new() creates an empty polygon--&amp;gt;&lt;br /&gt;
[[Polygon:addPoint]] &#039;&#039;appends a vertex to the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:getPoints]] &#039;&#039;returns all vertices of the polygon as a Lua table&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table--&amp;gt;&lt;br /&gt;
[[Polygon:getArea]] &#039;&#039;returns the signed area of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:isClockwise]] &#039;&#039;returns the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:clean]] &#039;&#039;removes self-intersections and very close vertices from the polygon in place&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place--&amp;gt;&lt;br /&gt;
[[Polygon:reverse]] &#039;&#039;reverses the order of the vertices in place, which flips the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Polygon:simplify]] &#039;&#039;simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:simplify(fillType) simplifies the polygon by removing redundant vertices and resolving self-intersections, using the given fill rule--&amp;gt;&lt;br /&gt;
[[Polygon:getPolygonOffset]] &#039;&#039;offsets (insets or outsets) the polygon by delta units&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPolygonOffset(delta, joinType, limit, autoFix) offsets (insets or outsets) the polygon by delta units--&amp;gt;&lt;br /&gt;
[[Polygon:getLineOffset]] &#039;&#039;offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getLineOffset(delta, joinType, endType, limit) offsets an open polyline (a polygon treated as an open path) by delta units, producing one or more parallel polylines--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
[[Event.CONNECTED]]&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSEVT:Event.CONNECTED connected--&amp;gt;&lt;br /&gt;
=== Constants ===&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25516</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25516"/>
		<updated>2026-11-14T02:14:17Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: wip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Clipper.Polygon.new]] &#039;&#039;creates an empty polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon.new() creates an empty polygon--&amp;gt;&lt;br /&gt;
[[Clipper.Polygon:addPoint]] &#039;&#039;appends a vertex to the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:addPoint(x, y) appends a vertex to the polygon--&amp;gt;&lt;br /&gt;
[[Clipper.Polygon:getPoints]] &#039;&#039;returns all vertices of the polygon as a Lua table&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getPoints() returns all vertices of the polygon as a Lua table--&amp;gt;&lt;br /&gt;
[[Clipper.Polygon:getArea]] &#039;&#039;returns the signed area of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:getArea() returns the signed area of the polygon--&amp;gt;&lt;br /&gt;
[[Clipper.Polygon:isClockwise]] &#039;&#039;returns the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:isClockwise() returns the orientation of the polygon--&amp;gt;&lt;br /&gt;
[[Clipper.Polygon:clean]] &#039;&#039;removes self-intersections and very close vertices from the polygon in place&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:clean(distance) removes self-intersections and very close vertices from the polygon in place--&amp;gt;&lt;br /&gt;
[[Clipper.Polygon:reverse]] &#039;&#039;reverses the order of the vertices in place, which flips the orientation of the polygon&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Polygon:reverse() reverses the order of the vertices in place, which flips the orientation of the polygon--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
[[Event.CONNECTED]]&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSEVT:Event.CONNECTED connected--&amp;gt;&lt;br /&gt;
=== Constants ===&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25515</id>
		<title>Clipper</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Clipper&amp;diff=25515"/>
		<updated>2026-11-14T02:01:17Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt; {{PLATFORMS ALL}} &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;  === Description === The Clipper plugin wraps the Clipper polygon clippi...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Clipper --&amp;gt;&lt;br /&gt;
{{PLATFORMS ALL}}&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2015.03.22&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The Clipper plugin wraps the Clipper polygon clipping library for Gideros.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;clipper&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Clipper in Gideros Studio -&amp;gt; Plugins before use. This makes the two classes Polygon and Clipper available as globals.&lt;br /&gt;
&lt;br /&gt;
It provides two classes:&lt;br /&gt;
*&#039;&#039;&#039;Polygon&#039;&#039;&#039;: a single polygon (a list of integer points). It can be created, edited, measured, cleaned, reversed, simplified and offset (inset/outset)&lt;br /&gt;
*&#039;&#039;&#039;Clipper&#039;&#039;&#039;: a clipping engine that combines one or more subject polygons with one or more clip polygons using boolean operations (intersection, union, difference, exclusion)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Controller:getControllerName]] &#039;&#039;gets the name of the controller&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Controller:getControllerName(id) gets the name of the controller--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
[[Event.CONNECTED]]&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSEVT:Event.CONNECTED connected--&amp;gt;&lt;br /&gt;
=== Constants ===&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Plugins&amp;diff=25514</id>
		<title>Plugins</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Plugins&amp;diff=25514"/>
		<updated>2026-11-14T01:44:58Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;&lt;br /&gt;
*[[Ads]]&lt;br /&gt;
*[[Age signal]] &#039;&#039;WIP&#039;&#039;&lt;br /&gt;
*[[bit]]&lt;br /&gt;
*[[camera]]&lt;br /&gt;
*[[bump|cbump (bump)]]&lt;br /&gt;
*[[Chroma]]&lt;br /&gt;
*[[Clipper]] &#039;&#039;&#039;&#039;&#039;NEW&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*[[Controller]]&lt;br /&gt;
*[[cute_c2]]&lt;br /&gt;
*[[Dear ImGui]]&lt;br /&gt;
*[[Easing]]&lt;br /&gt;
*[[Facebook Instant Games]]&lt;br /&gt;
*[[FastNoise]]&lt;br /&gt;
*&#039;&#039;&#039;Firebase&#039;&#039;&#039; (undocumented)&lt;br /&gt;
*[[Gaming]] &#039;&#039;googleplay&#039;&#039;, &#039;&#039;gamekit&#039;&#039;&lt;br /&gt;
*[[GTween]] &#039;&#039;class&#039;&#039;&lt;br /&gt;
*[[Iab]]&lt;br /&gt;
*[[json]]&lt;br /&gt;
*[[LiquidFun|LiquidFun (Box2D)]]&lt;br /&gt;
*[[lpeg]]&lt;br /&gt;
*[[lfs|Lua File System (LFS)]]&lt;br /&gt;
*[[Lua Midi]]&lt;br /&gt;
*[[Lua Socket]]&lt;br /&gt;
*[[Media|Media (gmedia)]]&lt;br /&gt;
*[[Microphone]]&lt;br /&gt;
*[[Ogg|Ogg (Theora)]]&lt;br /&gt;
*[[ReactPhysics3D]]&lt;br /&gt;
*[[SceneManager]]&lt;br /&gt;
*[[Share]]&lt;br /&gt;
*[[Spine]]&lt;br /&gt;
*[[Spout]] &#039;&#039;&#039;&#039;&#039;NEW&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*[[Sqlite3|Sqlite3 (LuaSQLite3)]]&lt;br /&gt;
*[[StoreReview]]&lt;br /&gt;
*[[TTS]]&lt;br /&gt;
*[[TntVirtualPad]]&lt;br /&gt;
*[[Wax|Wax (iPhone)]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Microphone:writeAudio&amp;diff=25513</id>
		<title>Microphone:writeAudio</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Microphone:writeAudio&amp;diff=25513"/>
		<updated>2026-11-14T01:16:57Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2025.7&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Microphone]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Writes microphone output to buffer.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Microphone:writeAudio(b)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;b&#039;&#039;&#039;: (buffer) the buffer name&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&#039;&#039;&#039;Encoding an audio file from lua generated data&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
require &amp;quot;microphone&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local microphone = Microphone.new(8000, 1, 16)&lt;br /&gt;
microphone:setOutputFile(&amp;quot;|D|test.wav&amp;quot;)&lt;br /&gt;
microphone:start()&lt;br /&gt;
&lt;br /&gt;
local b = buffer.create(8000*2)&lt;br /&gt;
buffer.setarrayaccess(b, &amp;quot;i16&amp;quot;)&lt;br /&gt;
for i = 0, 8000-1 do&lt;br /&gt;
	b[i] = math.sin(i/3)*30000&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
microphone:writeAudio(b)&lt;br /&gt;
microphone:stop()&lt;br /&gt;
&lt;br /&gt;
local snd = Sound.new(&amp;quot;|D|test.wav&amp;quot;)&lt;br /&gt;
snd:play()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Microphone}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Ogg&amp;diff=25512</id>
		<title>Ogg</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Ogg&amp;diff=25512"/>
		<updated>2026-11-14T00:38:17Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Ogg --&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Supported platforms:&#039;&#039;&#039; [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform winrt.png]][[File:Platform win32.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2017.10&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Adds support for Ogg audio and video (Theora) to Gideros.&lt;br /&gt;
&lt;br /&gt;
There are two ways to use the Ogg plugin:&lt;br /&gt;
*to read Ogg files use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local theora = require &amp;quot;Theora&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*to encode/decode Ogg files use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Theora system&lt;br /&gt;
local theora = require &amp;quot;theora.core&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Ogg in Gideros Studio -&amp;gt; Plugins before use.&lt;br /&gt;
&lt;br /&gt;
==== Theora ====&lt;br /&gt;
&amp;lt;del&amp;gt;Theora is a subclass of Sound, so every Sound and SoundChannel method also works on a Theora object and on the channel it returns. Because the plugin also registers an Ogg decoder with the sound system, plain Ogg Vorbis audio files can simply be loaded with Theora.new() as well&amp;lt;/del&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
One Ogg file may contain an Ogg Vorbis audio stream, an Ogg Theora video stream, or both of them together. Theora:play() starts the sound part and Theora:getVideo() displays the video part.&lt;br /&gt;
&lt;br /&gt;
==== Theora.core ====&lt;br /&gt;
The theora.core table gives direct access to the Ogg streams behind a sound channel. Its functions raise a Lua error when the stream id is invalid, so they should be called inside pcall when the input is not guaranteed.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
*The encoder only accepts frame sizes that are multiples of 16, so round width and height up before creating the RenderTarget&lt;br /&gt;
*Image format 3 (YUV420) is the only format supported by the encoder at the moment&lt;br /&gt;
*The video is decoded on the CPU and uploaded to textures, so large videos are expensive on low end devices; prefer sizes close to what is really displayed&lt;br /&gt;
*Theora:play() creates new textures for every playback, so stop the channel instead of keeping many channels alive&lt;br /&gt;
*theora.core functions throw Lua errors on invalid stream ids; use pcall if the stream may not exist&lt;br /&gt;
*Video frames are drawn by the plugin renderer when their timestamp is due, which keeps them in step with the audio stream of the same file&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&#039;&#039;&#039;Recording your mic and camera to an .ogg video file&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Microphone plugin, for recording in gideros&lt;br /&gt;
require &amp;quot;microphone&amp;quot;&lt;br /&gt;
-- Camera plugin, to get images from&lt;br /&gt;
require &amp;quot;camera&amp;quot;&lt;br /&gt;
-- Theora system (from ogg plugin)&lt;br /&gt;
local theora = require &amp;quot;theora.core&amp;quot;&lt;br /&gt;
&lt;br /&gt;
--Locate available cameras&lt;br /&gt;
lst=Camera.availableDevices()&lt;br /&gt;
for k,cam in ipairs(lst) do&lt;br /&gt;
	print(&amp;quot;#&amp;quot;..k..&amp;quot; Desc:&amp;quot;..cam.description..&amp;quot; Pos:&amp;quot;..cam.position..&amp;quot; Dev:&amp;quot;..cam.name)&lt;br /&gt;
end&lt;br /&gt;
-- Pick the first available&lt;br /&gt;
local cname=lst[1].name&lt;br /&gt;
&lt;br /&gt;
cw,ch=640,480&lt;br /&gt;
--Theora needs full 16x16 blocks&lt;br /&gt;
ch=(ch+15)&amp;amp;~15&lt;br /&gt;
cw=(cw+15)&amp;amp;~15&lt;br /&gt;
--Create texture and start camera&lt;br /&gt;
Camera.texture=RenderTarget.new(cw,ch)&lt;br /&gt;
Camera.start(Camera.texture,cname)&lt;br /&gt;
&lt;br /&gt;
--Set our stage size&lt;br /&gt;
application:setLogicalDimensions(cw,ch)&lt;br /&gt;
--Show our live video&lt;br /&gt;
local b=Bitmap.new(Camera.texture)&lt;br /&gt;
stage:addChild(b)&lt;br /&gt;
&lt;br /&gt;
--Prepare for recording&lt;br /&gt;
local mic=Microphone.new(&amp;quot;&amp;quot;,24000,2,16)&lt;br /&gt;
mic:setOutputFile(&amp;quot;|T|mic.ogg&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
--Launch recording process&lt;br /&gt;
Core.asyncCall(function()&lt;br /&gt;
	--Wait a frame and disable auto yield&lt;br /&gt;
	Core.yield(true)&lt;br /&gt;
	--Start recording and get recording stream id&lt;br /&gt;
	mic:start()&lt;br /&gt;
	local id=mic:getStreamId()&lt;br /&gt;
	--Encode video header immediately, before audio data gets encoded&lt;br /&gt;
	--Parameters are:&lt;br /&gt;
	-- stream id, codec name, frame rate, image width, image height,&lt;br /&gt;
	-- image format (use 3 for now, nothing else is supported), image quality&lt;br /&gt;
	theora.beginVideo(id,&amp;quot;theora&amp;quot;,30,cw,ch,3,0.6)&lt;br /&gt;
	-- Now encode 120 video frames, every other gideros frame (60fps-&amp;gt;30fps)&lt;br /&gt;
	for i=1,120 do&lt;br /&gt;
		--Parameters:&lt;br /&gt;
		-- stream id, frame id (zero based), image texture, end of stream indicator&lt;br /&gt;
		theora.encodeVideoFrame(id,(i-1),Camera.texture,(i==120))&lt;br /&gt;
		Core.yield(true)&lt;br /&gt;
		Core.yield(true)&lt;br /&gt;
	end&lt;br /&gt;
	-- Stop recording&lt;br /&gt;
	mic:stop()&lt;br /&gt;
	-- For testing, read encoded file and print its size&lt;br /&gt;
	local f=io.open(&amp;quot;|T|mic.ogg&amp;quot;,&amp;quot;rb&amp;quot;)&lt;br /&gt;
	local ct=f:read(&amp;quot;*all&amp;quot;)&lt;br /&gt;
	f:close()&lt;br /&gt;
	print(&amp;quot;Ended&amp;quot;,#ct) &lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example 2&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local theora = require &amp;quot;theora.core&amp;quot;&lt;br /&gt;
require &amp;quot;microphone&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
local texw, texh = 120*16, 68*16&lt;br /&gt;
local tex = RenderTarget.new(texw, texh)&lt;br /&gt;
local dot = Pixel.new(0xFF0000, 16, 16)&lt;br /&gt;
dot:setAnchorPoint(.5,.5)&lt;br /&gt;
&lt;br /&gt;
local microphone = Microphone.new(8000, 1, 16)&lt;br /&gt;
microphone:setOutputFile(&amp;quot;|D|test.ogg&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Core.asyncCall(function()&lt;br /&gt;
	microphone:start()&lt;br /&gt;
	theora.beginVideo(microphone:getStreamId(),&amp;quot;theora&amp;quot;,30,texw,texh,3,0.6)&lt;br /&gt;
&lt;br /&gt;
	for i = 1, 360, 2 do&lt;br /&gt;
		tex:clear(0x303030)&lt;br /&gt;
		tex:draw(dot, math.cos(^&amp;lt;i)*texh*.4+texw/2, math.sin(^&amp;lt;i)*texh*.4+texh/2)&lt;br /&gt;
		theora.encodeVideoFrame(microphone:getStreamId(), (i-1), tex, (i==360))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	microphone:stop()&lt;br /&gt;
	print(&amp;quot;Finished&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Theora.new]] &#039;&#039;creates a new Ogg/Theora object&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Theora.new(path) creates a new Ogg/Theora object--&amp;gt;&lt;br /&gt;
[[Theora:getVideo]] &#039;&#039;reads video from an Ogg/Theora stream object&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Theora:getVideo() reads video from an Ogg/Theora stream object--&amp;gt;&lt;br /&gt;
[[Theora:play]] &#039;&#039;creates a new Ogg/Theora stream object&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Theora:play(startTime, looping, paused) creates a new Ogg/Theora stream object--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[theora.core.beginVideo]] &#039;&#039;starts the video encoder of an encoding (recording) stream&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.beginVideo(streamId, codec, frameRate, width, height, format, quality) starts the video encoder of an encoding (recording) stream--&amp;gt;&lt;br /&gt;
[[theora.core.encodeVideoFrame]] &#039;&#039;encodes one video frame taken from a render target and writes it into the recording file&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.encodeVideoFrame(streamId, framePosition, renderTarget, endOfStream) encodes one video frame taken from a render target and writes it into the recording file--&amp;gt;&lt;br /&gt;
[[theora.core.getVideoInfo]] &#039;&#039;reads the properties of the video stream attached to a channel&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.getVideoInfo(streamId) reads the properties of the video stream attached to a channel--&amp;gt;&lt;br /&gt;
[[theora.core.setVideoSurface]] &#039;&#039;attaches the textures that receive the decoded Y, U and V planes of a video stream&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.setVideoSurface(streamId, yTexture, uTexture, vTexture) attaches the textures that receive the decoded Y, U and V planes of a video stream--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
&amp;lt;!--[[Event.COMPLETE]]&amp;lt;br/&amp;gt;--&amp;gt;&lt;br /&gt;
[[Theora_Event.COMPLETE]]&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSEVT:Event.COMPLETE complete--&amp;gt;&lt;br /&gt;
=== Constants ===&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Theora_Event.COMPLETE&amp;diff=25511</id>
		<title>Theora Event.COMPLETE</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Theora_Event.COMPLETE&amp;diff=25511"/>
		<updated>2026-11-13T22:29:01Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2017.10&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Value:&amp;#039;&amp;#039;&amp;#039; complete&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Defined by:&amp;#039;&amp;#039;&amp;#039; Ogg&amp;lt;br/&amp;gt;  === Description === This event is dispatched by the channel returned by...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2017.10&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Value:&#039;&#039;&#039; complete&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Defined by:&#039;&#039;&#039; [[Ogg]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
This event is dispatched by the channel returned by Theora:play() when the stream reaches its end. With looping enabled the stream restarts instead of finishing.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
	local ok, err = pcall(function()&lt;br /&gt;
		local channel = videoSource:play(0, looping)&lt;br /&gt;
		videoChannel = channel&lt;br /&gt;
		readLength()&lt;br /&gt;
&lt;br /&gt;
		local info&lt;br /&gt;
		if theoraCore then&lt;br /&gt;
			info = theoraCore.getVideoInfo(channel:getStreamId())&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if info then&lt;br /&gt;
			-- Fit the video inside the card, keeping its aspect ratio.&lt;br /&gt;
			local maxW, maxH = VIDEO_W - VIDEO_PAD * 2, VIDEO_H - VIDEO_PAD * 2&lt;br /&gt;
			local scale = math.min(maxW / info.width, maxH / info.height)&lt;br /&gt;
			local w = math.floor(info.width * scale)&lt;br /&gt;
			local h = math.floor(info.height * scale)&lt;br /&gt;
&lt;br /&gt;
			videoMesh = channel:getVideo(w, h)&lt;br /&gt;
			videoMesh:setPosition(&lt;br /&gt;
				math.floor(VIDEO_X + (VIDEO_W - w) / 2),&lt;br /&gt;
				math.floor(VIDEO_Y + (VIDEO_H - h) / 2))&lt;br /&gt;
			videoMesh:addEventListener(Event.TOUCHES_BEGIN, function()&lt;br /&gt;
				togglePlay()&lt;br /&gt;
				return true&lt;br /&gt;
			end)&lt;br /&gt;
			videoLayer:addChild(videoMesh)&lt;br /&gt;
&lt;br /&gt;
			local parts = { string.format(&amp;quot;%d x %d&amp;quot;, info.width, info.height) }&lt;br /&gt;
			if info.fps then&lt;br /&gt;
				table.insert(parts, string.format(&amp;quot;%d fps&amp;quot;, math.floor(info.fps + 0.5)))&lt;br /&gt;
			end&lt;br /&gt;
			if videoLength &amp;gt; 0 then&lt;br /&gt;
				table.insert(parts, string.format(&amp;quot;%.1f s&amp;quot;, videoLength / 1000))&lt;br /&gt;
			end&lt;br /&gt;
			metaLabel:setText(table.concat(parts, &amp;quot;   &amp;quot;))&lt;br /&gt;
			centerX(metaLabel, 334)&lt;br /&gt;
&lt;br /&gt;
			print(&amp;quot;[theora] playing&amp;quot;, VIDEO_PATH,&lt;br /&gt;
				info.width .. &amp;quot;x&amp;quot; .. info.height,&lt;br /&gt;
				&amp;quot;fps=&amp;quot; .. tostring(info.fps),&lt;br /&gt;
				&amp;quot;length=&amp;quot; .. tostring(videoLength))&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		channel:addEventListener(Event.COMPLETE, function()&lt;br /&gt;
			if videoChannel == channel then&lt;br /&gt;
				fallbackState = &amp;quot;Finished&amp;quot;&lt;br /&gt;
				refreshPlayButton()&lt;br /&gt;
				refreshStatus()&lt;br /&gt;
			end&lt;br /&gt;
		end)&lt;br /&gt;
	end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Ogg}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Theora.core.encodeVideoFrame&amp;diff=25510</id>
		<title>Theora.core.encodeVideoFrame</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Theora.core.encodeVideoFrame&amp;diff=25510"/>
		<updated>2026-11-13T22:22:47Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2017.10&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Ogg&amp;lt;br/&amp;gt;  === Description === Encodes one video frame taken from a render target and writes it into the...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2017.10&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Ogg]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Encodes one video frame taken from a render target and writes it into the recording file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
theora.core.encodeVideoFrame(streamId,framePosition,renderTarget,endOfStream)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;streamId&#039;&#039;&#039;: (number) stream id of the recording sound&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;framePosition&#039;&#039;&#039;: (number) zero based position of the frame, in frames&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;renderTarget&#039;&#039;&#039;: (RenderTarget) the picture to encode, it must have the width and height given to beginVideo()&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;endOfStream&#039;&#039;&#039;: (boolean) true for the last frame of the recording&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Ogg}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Theora.core.setVideoSurface&amp;diff=25509</id>
		<title>Theora.core.setVideoSurface</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Theora.core.setVideoSurface&amp;diff=25509"/>
		<updated>2026-11-13T22:18:34Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2017.10&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Ogg&amp;lt;br/&amp;gt;  === Description === Attaches the textures that receive the decoded Y, U and V planes of a vide...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2017.10&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Ogg]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Attaches the textures that receive the decoded Y, U and V planes of a video stream. Theora:play() calls this automatically with three textures created for the stream; it only needs to be called when the video is drawn by custom code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
theora.core.setVideoSurface(streamId,yTexture,uTexture,vTexture)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Y texture may define a _videoSizeUpdated(width, height) method. The plugin calls it whenever the decoded picture size changes, which lets the receiving meshes fix their texture coordinates.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;streamId&#039;&#039;&#039;: (number) the id returned by channel:getStreamId()&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;yTexture&#039;&#039;&#039;: (TextureBase) full size luma surface&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;uTexture&#039;&#039;&#039;: (TextureBase) chroma surface, half width and half height&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;vTexture&#039;&#039;&#039;: (TextureBase) chroma surface, half width and half height&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Ogg}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Theora.core.getVideoInfo&amp;diff=25508</id>
		<title>Theora.core.getVideoInfo</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Theora.core.getVideoInfo&amp;diff=25508"/>
		<updated>2026-11-13T22:13:14Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2017.10&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Ogg&amp;lt;br/&amp;gt;  === Description === Reads the properties of the video stream attached to a channel. &amp;lt;syntaxhig...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2017.10&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Ogg]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Reads the properties of the video stream attached to a channel.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
(table) = theora.core.getVideoInfo(streamId)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;streamId&#039;&#039;&#039;: (number) the id returned by channel:getStreamId()&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&#039;&#039;&#039;Returns&#039;&#039;&#039; (table) width, height, surfaceWidth, surfaceHeight, fps, format, or nil if the stream has no video&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
width and height are the coded size of the video frame, while surfaceWidth and surfaceHeight are the size of the decoded Y plane (they can be larger because of block padding).&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local info = theora.core.getVideoInfo(channel:getStreamId())&lt;br /&gt;
print(info.width, info.height, info.fps, info.format)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Ogg}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Ogg&amp;diff=25507</id>
		<title>Ogg</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Ogg&amp;diff=25507"/>
		<updated>2026-11-13T22:07:04Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Ogg --&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Supported platforms:&#039;&#039;&#039; [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform winrt.png]][[File:Platform win32.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2017.10&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Adds support for Ogg audio and video (Theora) to Gideros.&lt;br /&gt;
&lt;br /&gt;
There are two ways to use the Ogg plugin:&lt;br /&gt;
*to read Ogg files use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local theora = require &amp;quot;Theora&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*to encode/decode Ogg files use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Theora system&lt;br /&gt;
local theora = require &amp;quot;theora.core&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Ogg in Gideros Studio -&amp;gt; Plugins before use.&lt;br /&gt;
&lt;br /&gt;
==== Theora ====&lt;br /&gt;
Theora is a subclass of Sound, so every Sound and SoundChannel method also works on a Theora object and on the channel it returns. Because the plugin also registers an Ogg decoder with the sound system, plain Ogg Vorbis audio files can simply be loaded with Theora.new() as well.&lt;br /&gt;
&lt;br /&gt;
One Ogg file may contain an Ogg Vorbis audio stream, an Ogg Theora video stream, or both of them together. Theora:play() starts the sound part and Theora:getVideo() displays the video part.&lt;br /&gt;
&lt;br /&gt;
==== Theora.core ====&lt;br /&gt;
The theora.core table gives direct access to the Ogg streams behind a sound channel. Its functions raise a Lua error when the stream id is invalid, so they should be called inside pcall when the input is not guaranteed.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&#039;&#039;&#039;Recording your mic and camera to an .ogg video file&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Microphone plugin, for recording in gideros&lt;br /&gt;
require &amp;quot;microphone&amp;quot;&lt;br /&gt;
-- Camera plugin, to get images from&lt;br /&gt;
require &amp;quot;camera&amp;quot;&lt;br /&gt;
-- Theora system (from ogg plugin)&lt;br /&gt;
local theora = require &amp;quot;theora.core&amp;quot;&lt;br /&gt;
&lt;br /&gt;
--Locate available cameras&lt;br /&gt;
lst=Camera.availableDevices()&lt;br /&gt;
for k,cam in ipairs(lst) do&lt;br /&gt;
	print(&amp;quot;#&amp;quot;..k..&amp;quot; Desc:&amp;quot;..cam.description..&amp;quot; Pos:&amp;quot;..cam.position..&amp;quot; Dev:&amp;quot;..cam.name)&lt;br /&gt;
end&lt;br /&gt;
-- Pick the first available&lt;br /&gt;
local cname=lst[1].name&lt;br /&gt;
&lt;br /&gt;
cw,ch=640,480&lt;br /&gt;
--Theora needs full 16x16 blocks&lt;br /&gt;
ch=(ch+15)&amp;amp;~15&lt;br /&gt;
cw=(cw+15)&amp;amp;~15&lt;br /&gt;
--Create texture and start camera&lt;br /&gt;
Camera.texture=RenderTarget.new(cw,ch)&lt;br /&gt;
Camera.start(Camera.texture,cname)&lt;br /&gt;
&lt;br /&gt;
--Set our stage size&lt;br /&gt;
application:setLogicalDimensions(cw,ch)&lt;br /&gt;
--Show our live video&lt;br /&gt;
local b=Bitmap.new(Camera.texture)&lt;br /&gt;
stage:addChild(b)&lt;br /&gt;
&lt;br /&gt;
--Prepare for recording&lt;br /&gt;
local mic=Microphone.new(&amp;quot;&amp;quot;,24000,2,16)&lt;br /&gt;
mic:setOutputFile(&amp;quot;|T|mic.ogg&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
--Launch recording process&lt;br /&gt;
Core.asyncCall(function()&lt;br /&gt;
	--Wait a frame and disable auto yield&lt;br /&gt;
	Core.yield(true)&lt;br /&gt;
	--Start recording and get recording stream id&lt;br /&gt;
	mic:start()&lt;br /&gt;
	local id=mic:getStreamId()&lt;br /&gt;
	--Encode video header immediately, before audio data gets encoded&lt;br /&gt;
	--Parameters are:&lt;br /&gt;
	-- stream id, codec name, frame rate, image width, image height,&lt;br /&gt;
	-- image format (use 3 for now, nothing else is supported), image quality&lt;br /&gt;
	theora.beginVideo(id,&amp;quot;theora&amp;quot;,30,cw,ch,3,0.6)&lt;br /&gt;
	-- Now encode 120 video frames, every other gideros frame (60fps-&amp;gt;30fps)&lt;br /&gt;
	for i=1,120 do&lt;br /&gt;
		--Parameters:&lt;br /&gt;
		-- stream id, frame id (zero based), image texture, end of stream indicator&lt;br /&gt;
		theora.encodeVideoFrame(id,(i-1),Camera.texture,(i==120))&lt;br /&gt;
		Core.yield(true)&lt;br /&gt;
		Core.yield(true)&lt;br /&gt;
	end&lt;br /&gt;
	-- Stop recording&lt;br /&gt;
	mic:stop()&lt;br /&gt;
	-- For testing, read encoded file and print its size&lt;br /&gt;
	local f=io.open(&amp;quot;|T|mic.ogg&amp;quot;,&amp;quot;rb&amp;quot;)&lt;br /&gt;
	local ct=f:read(&amp;quot;*all&amp;quot;)&lt;br /&gt;
	f:close()&lt;br /&gt;
	print(&amp;quot;Ended&amp;quot;,#ct) &lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example 2&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local theora = require &amp;quot;theora.core&amp;quot;&lt;br /&gt;
require &amp;quot;microphone&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
local texw, texh = 120*16, 68*16&lt;br /&gt;
local tex = RenderTarget.new(texw, texh)&lt;br /&gt;
local dot = Pixel.new(0xFF0000, 16, 16)&lt;br /&gt;
dot:setAnchorPoint(.5,.5)&lt;br /&gt;
&lt;br /&gt;
local microphone = Microphone.new(8000, 1, 16)&lt;br /&gt;
microphone:setOutputFile(&amp;quot;|D|test.ogg&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Core.asyncCall(function()&lt;br /&gt;
	microphone:start()&lt;br /&gt;
	theora.beginVideo(microphone:getStreamId(),&amp;quot;theora&amp;quot;,30,texw,texh,3,0.6)&lt;br /&gt;
&lt;br /&gt;
	for i = 1, 360, 2 do&lt;br /&gt;
		tex:clear(0x303030)&lt;br /&gt;
		tex:draw(dot, math.cos(^&amp;lt;i)*texh*.4+texw/2, math.sin(^&amp;lt;i)*texh*.4+texh/2)&lt;br /&gt;
		theora.encodeVideoFrame(microphone:getStreamId(), (i-1), tex, (i==360))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	microphone:stop()&lt;br /&gt;
	print(&amp;quot;Finished&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Theora.new]] &#039;&#039;creates a new Ogg/Theora object&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Theora.new(path) creates a new Ogg/Theora object--&amp;gt;&lt;br /&gt;
[[Theora:getVideo]] &#039;&#039;reads video from an Ogg/Theora stream object&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Theora:getVideo() reads video from an Ogg/Theora stream object--&amp;gt;&lt;br /&gt;
[[Theora:play]] &#039;&#039;creates a new Ogg/Theora stream object&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Theora:play(startTime, looping, paused) creates a new Ogg/Theora stream object--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[theora.core.beginVideo]] &#039;&#039;starts the video encoder of an encoding (recording) stream&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.beginVideo(streamId, codec, frameRate, width, height, format, quality) starts the video encoder of an encoding (recording) stream--&amp;gt;&lt;br /&gt;
[[theora.core.encodeVideoFrame]] &#039;&#039;encodes one video frame taken from a render target and writes it into the recording file&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.encodeVideoFrame(streamId, framePosition, renderTarget, endOfStream) encodes one video frame taken from a render target and writes it into the recording file--&amp;gt;&lt;br /&gt;
[[theora.core.getVideoInfo]] &#039;&#039;reads the properties of the video stream attached to a channel&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.getVideoInfo(streamId) reads the properties of the video stream attached to a channel--&amp;gt;&lt;br /&gt;
[[theora.core.setVideoSurface]] &#039;&#039;attaches the textures that receive the decoded Y, U and V planes of a video stream&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.setVideoSurface(streamId, yTexture, uTexture, vTexture) attaches the textures that receive the decoded Y, U and V planes of a video stream--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
&amp;lt;!--[[Event.COMPLETE]]&amp;lt;br/&amp;gt;--&amp;gt;&lt;br /&gt;
[[Theora_Event.COMPLETE]]&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSEVT:Event.COMPLETE complete--&amp;gt;&lt;br /&gt;
=== Constants ===&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Template:Ogg&amp;diff=25506</id>
		<title>Template:Ogg</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Template:Ogg&amp;diff=25506"/>
		<updated>2026-11-13T22:03:50Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
----&lt;br /&gt;
{{Special:PrefixIndex/Ogg}}&lt;br /&gt;
{{Special:PrefixIndex/Theora}}&lt;br /&gt;
&lt;br /&gt;
{{Gideros deco stars01}}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Ogg]]&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Theora.core.beginVideo&amp;diff=25505</id>
		<title>Theora.core.beginVideo</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Theora.core.beginVideo&amp;diff=25505"/>
		<updated>2026-11-13T22:02:18Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: Created page with &amp;quot;__NOTOC__ &amp;#039;&amp;#039;&amp;#039;Available since:&amp;#039;&amp;#039;&amp;#039; Gideros 2017.10&amp;lt;br/&amp;gt; &amp;#039;&amp;#039;&amp;#039;Class:&amp;#039;&amp;#039;&amp;#039; Ogg&amp;lt;br/&amp;gt;  === Description === Starts the video encoder of an encoding (recording) stream. &amp;lt;syntaxhighlig...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2017.10&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Class:&#039;&#039;&#039; [[Ogg]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Starts the video encoder of an encoding (recording) stream.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
theora.core.beginVideo(streamId,codec,frameRate,width,height,format,quality)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The video header is written into the same file as the audio stream, so beginVideo() must be called before the first audio packet is encoded.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&#039;&#039;&#039;streamId&#039;&#039;&#039;: (number) stream id of the recording sound, for example mic:getStreamId()&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;codec&#039;&#039;&#039;: (string) codec name, &amp;quot;theora&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;frameRate&#039;&#039;&#039;: (number) frames per second, for example 30&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;width&#039;&#039;&#039;: (number) frame width, must be a multiple of 16&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;height&#039;&#039;&#039;: (number) frame height, must be a multiple of 16&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;format&#039;&#039;&#039;: (number) image format, 3 (YUV420) is the only supported value&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;quality&#039;&#039;&#039;: (number) encoder quality from 0 to 1, for example 0.6&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Ogg}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Ogg&amp;diff=25504</id>
		<title>Ogg</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Ogg&amp;diff=25504"/>
		<updated>2026-11-13T21:54:58Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&amp;lt;!-- GIDEROSOBJ:Ogg --&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Supported platforms:&#039;&#039;&#039; [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform winrt.png]][[File:Platform win32.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Available since:&#039;&#039;&#039; Gideros 2017.10&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Adds support for Ogg audio and video (Theora) to Gideros.&lt;br /&gt;
&lt;br /&gt;
There are two ways to use the Ogg plugin:&lt;br /&gt;
*to read Ogg files use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local theora = require &amp;quot;Theora&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*to encode/decode Ogg files use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Theora system&lt;br /&gt;
local theora = require &amp;quot;theora.core&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable Ogg in Gideros Studio -&amp;gt; Plugins before use.&lt;br /&gt;
&lt;br /&gt;
Theora is a subclass of Sound, so every Sound and SoundChannel method also works on a Theora object and on the channel it returns. Because the plugin also registers an Ogg decoder with the sound system, plain Ogg Vorbis audio files can simply be loaded with Theora.new() as well.&lt;br /&gt;
&lt;br /&gt;
One Ogg file may contain an Ogg Vorbis audio stream, an Ogg Theora video stream, or both of them together. Theora:play() starts the sound part and Theora:getVideo() displays the video part.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&#039;&#039;&#039;Recording your mic and camera to an .ogg video file&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Microphone plugin, for recording in gideros&lt;br /&gt;
require &amp;quot;microphone&amp;quot;&lt;br /&gt;
-- Camera plugin, to get images from&lt;br /&gt;
require &amp;quot;camera&amp;quot;&lt;br /&gt;
-- Theora system (from ogg plugin)&lt;br /&gt;
local theora = require &amp;quot;theora.core&amp;quot;&lt;br /&gt;
&lt;br /&gt;
--Locate available cameras&lt;br /&gt;
lst=Camera.availableDevices()&lt;br /&gt;
for k,cam in ipairs(lst) do&lt;br /&gt;
	print(&amp;quot;#&amp;quot;..k..&amp;quot; Desc:&amp;quot;..cam.description..&amp;quot; Pos:&amp;quot;..cam.position..&amp;quot; Dev:&amp;quot;..cam.name)&lt;br /&gt;
end&lt;br /&gt;
-- Pick the first available&lt;br /&gt;
local cname=lst[1].name&lt;br /&gt;
&lt;br /&gt;
cw,ch=640,480&lt;br /&gt;
--Theora needs full 16x16 blocks&lt;br /&gt;
ch=(ch+15)&amp;amp;~15&lt;br /&gt;
cw=(cw+15)&amp;amp;~15&lt;br /&gt;
--Create texture and start camera&lt;br /&gt;
Camera.texture=RenderTarget.new(cw,ch)&lt;br /&gt;
Camera.start(Camera.texture,cname)&lt;br /&gt;
&lt;br /&gt;
--Set our stage size&lt;br /&gt;
application:setLogicalDimensions(cw,ch)&lt;br /&gt;
--Show our live video&lt;br /&gt;
local b=Bitmap.new(Camera.texture)&lt;br /&gt;
stage:addChild(b)&lt;br /&gt;
&lt;br /&gt;
--Prepare for recording&lt;br /&gt;
local mic=Microphone.new(&amp;quot;&amp;quot;,24000,2,16)&lt;br /&gt;
mic:setOutputFile(&amp;quot;|T|mic.ogg&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
--Launch recording process&lt;br /&gt;
Core.asyncCall(function()&lt;br /&gt;
	--Wait a frame and disable auto yield&lt;br /&gt;
	Core.yield(true)&lt;br /&gt;
	--Start recording and get recording stream id&lt;br /&gt;
	mic:start()&lt;br /&gt;
	local id=mic:getStreamId()&lt;br /&gt;
	--Encode video header immediately, before audio data gets encoded&lt;br /&gt;
	--Parameters are:&lt;br /&gt;
	-- stream id, codec name, frame rate, image width, image height,&lt;br /&gt;
	-- image format (use 3 for now, nothing else is supported), image quality&lt;br /&gt;
	theora.beginVideo(id,&amp;quot;theora&amp;quot;,30,cw,ch,3,0.6)&lt;br /&gt;
	-- Now encode 120 video frames, every other gideros frame (60fps-&amp;gt;30fps)&lt;br /&gt;
	for i=1,120 do&lt;br /&gt;
		--Parameters:&lt;br /&gt;
		-- stream id, frame id (zero based), image texture, end of stream indicator&lt;br /&gt;
		theora.encodeVideoFrame(id,(i-1),Camera.texture,(i==120))&lt;br /&gt;
		Core.yield(true)&lt;br /&gt;
		Core.yield(true)&lt;br /&gt;
	end&lt;br /&gt;
	-- Stop recording&lt;br /&gt;
	mic:stop()&lt;br /&gt;
	-- For testing, read encoded file and print its size&lt;br /&gt;
	local f=io.open(&amp;quot;|T|mic.ogg&amp;quot;,&amp;quot;rb&amp;quot;)&lt;br /&gt;
	local ct=f:read(&amp;quot;*all&amp;quot;)&lt;br /&gt;
	f:close()&lt;br /&gt;
	print(&amp;quot;Ended&amp;quot;,#ct) &lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example 2&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local theora = require &amp;quot;theora.core&amp;quot;&lt;br /&gt;
require &amp;quot;microphone&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
local texw, texh = 120*16, 68*16&lt;br /&gt;
local tex = RenderTarget.new(texw, texh)&lt;br /&gt;
local dot = Pixel.new(0xFF0000, 16, 16)&lt;br /&gt;
dot:setAnchorPoint(.5,.5)&lt;br /&gt;
&lt;br /&gt;
local microphone = Microphone.new(8000, 1, 16)&lt;br /&gt;
microphone:setOutputFile(&amp;quot;|D|test.ogg&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Core.asyncCall(function()&lt;br /&gt;
	microphone:start()&lt;br /&gt;
	theora.beginVideo(microphone:getStreamId(),&amp;quot;theora&amp;quot;,30,texw,texh,3,0.6)&lt;br /&gt;
&lt;br /&gt;
	for i = 1, 360, 2 do&lt;br /&gt;
		tex:clear(0x303030)&lt;br /&gt;
		tex:draw(dot, math.cos(^&amp;lt;i)*texh*.4+texw/2, math.sin(^&amp;lt;i)*texh*.4+texh/2)&lt;br /&gt;
		theora.encodeVideoFrame(microphone:getStreamId(), (i-1), tex, (i==360))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	microphone:stop()&lt;br /&gt;
	print(&amp;quot;Finished&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|-&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Methods ===&lt;br /&gt;
[[Theora.new]] &#039;&#039;creates a new Ogg/Theora object&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Theora.new(path) creates a new Ogg/Theora object--&amp;gt;&lt;br /&gt;
[[Theora:getVideo]] &#039;&#039;reads video from an Ogg/Theora stream object&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Theora:getVideo() reads video from an Ogg/Theora stream object--&amp;gt;&lt;br /&gt;
[[Theora:play]] &#039;&#039;creates a new Ogg/Theora stream object&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:Theora:play(startTime, looping, paused) creates a new Ogg/Theora stream object--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[theora.core.beginVideo]] &#039;&#039;starts the video encoder of an encoding (recording) stream&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.beginVideo(streamId, codec, frameRate, width, height, format, quality) starts the video encoder of an encoding (recording) stream--&amp;gt;&lt;br /&gt;
[[theora.core.encodeVideoFrame]] &#039;&#039;encodes one video frame taken from a render target and writes it into the recording file&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.encodeVideoFrame(streamId, framePosition, renderTarget, endOfStream) encodes one video frame taken from a render target and writes it into the recording file--&amp;gt;&lt;br /&gt;
[[theora.core.getVideoInfo]] &#039;&#039;reads the properties of the video stream attached to a channel&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.getVideoInfo(streamId) reads the properties of the video stream attached to a channel--&amp;gt;&lt;br /&gt;
[[theora.core.setVideoSurface]] &#039;&#039;attaches the textures that receive the decoded Y, U and V planes of a video stream&#039;&#039;&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSMTD:theora.core.setVideoSurface(streamId, yTexture, uTexture, vTexture) attaches the textures that receive the decoded Y, U and V planes of a video stream--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;width: 50%; vertical-align:top;&amp;quot;|&lt;br /&gt;
=== Events ===&lt;br /&gt;
&amp;lt;!--[[Event.COMPLETE]]&amp;lt;br/&amp;gt;--&amp;gt;&lt;br /&gt;
[[Theora_Event.COMPLETE]]&amp;lt;br/&amp;gt;&amp;lt;!--GIDEROSEVT:Event.COMPLETE complete--&amp;gt;&lt;br /&gt;
=== Constants ===&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Gideros_LOSC&amp;diff=25503</id>
		<title>Gideros LOSC</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Gideros_LOSC&amp;diff=25503"/>
		<updated>2026-11-13T04:20:41Z</updated>

		<summary type="html">&lt;p&gt;MoKaLux: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== OSC ===&lt;br /&gt;
OpenSoundControl: &#039;&#039;&#039;https://ccrma.stanford.edu/groups/osc/index.html&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 From &#039;&#039;&#039;&#039;&#039;Wikipedia&#039;&#039;&#039;&#039;&#039;, the free encyclopedia&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Open Sound Control (OSC) is a protocol for networking sound synthesizers, computers, and other multimedia devices for purposes such as musical performance or show control. OSC&#039;s advantages include interoperability, accuracy, flexibility and enhanced organization and documentation. Its disadvantages include inefficient coding of information, increased load on embedded processors, and lack of standardized messages/interoperability. The first specification was released in March 2002.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== LOSC ====&lt;br /&gt;
OSC 1.0 implementation for lua. Github: &#039;&#039;&#039;https://github.com/davidgranstrom/losc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;License&#039;&#039;&#039;:&lt;br /&gt;
* MIT License&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Features&#039;&#039;&#039;:&lt;br /&gt;
* implements the complete OSC 1.0 specification&lt;br /&gt;
* pure lua implementation, no platform dependent libraries&lt;br /&gt;
* support for extended OSC types&lt;br /&gt;
* plugin system for transport layers&lt;br /&gt;
* address pattern matching&lt;br /&gt;
* scheduled bundle evaluation (plugin dependent)&lt;br /&gt;
&lt;br /&gt;
==== LOSC Gideros Demos ====&lt;br /&gt;
These are Gideros demos you can learn from: &#039;&#039;&#039;[[Media:Losc_demos.zip]]&#039;&#039;&#039; (&#039;&#039;&#039;tip&#039;&#039;&#039;: right click and Save Link As).&lt;br /&gt;
&lt;br /&gt;
=== Gideros LOSC ===&lt;br /&gt;
You can download the Gideros LOSC bundle here: &#039;&#039;&#039;[[Media:Losc.zip]]&#039;&#039;&#039; (&#039;&#039;&#039;tip&#039;&#039;&#039;: right click and Save Link As).&lt;br /&gt;
&lt;br /&gt;
To use LOSC in your project, copy the Gideros LOSC bundle in your project &#039;&#039;&#039;assets&#039;&#039;&#039; folder.&lt;br /&gt;
&lt;br /&gt;
For documentation regarding LOSC you can refer to this link: &#039;&#039;&#039;https://davidgranstrom.github.io/losc/index.html&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
@&#039;&#039;&#039;keszegh&#039;&#039;&#039; initiated LOSC thread on Gideros forum here: &#039;&#039;&#039;https://forum.gideros.rocks/discussion/4975/how-can-i-communicate-with-other-apps-using-osc/p1&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There is also plenty of comments in each LOSC files, feel free to read them.&lt;br /&gt;
&lt;br /&gt;
==== Example 1 ====&lt;br /&gt;
A simple example of a server and a client.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
example=&amp;quot;client&amp;quot;&lt;br /&gt;
--example=&amp;quot;server&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local losc = require&amp;quot;losc&amp;quot;&lt;br /&gt;
local plugin = require&amp;quot;losc.plugins.udp-socket&amp;quot;&lt;br /&gt;
local Packet = require&amp;quot;losc.packet&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if example==&amp;quot;client&amp;quot; then&lt;br /&gt;
	-----------------&lt;br /&gt;
	-- Simple client.&lt;br /&gt;
	-- Uses the udp-socket plugin.&lt;br /&gt;
	local udp = plugin.new {sendAddr = &amp;quot;localhost&amp;quot;, sendPort = 9000}&lt;br /&gt;
	local osc = losc.new {plugin = udp}&lt;br /&gt;
&lt;br /&gt;
	local message = losc.new_message {&lt;br /&gt;
		address = &amp;quot;/foo/bar&amp;quot;,&lt;br /&gt;
		types = &amp;quot;ifsb&amp;quot;,&lt;br /&gt;
		123, 1.2345, &amp;quot;hi&amp;quot;, &amp;quot;blobdata&amp;quot;,&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	osc:send(message)&lt;br /&gt;
&lt;br /&gt;
	stage:addEventListener(Event.KEY_DOWN, function(e)&lt;br /&gt;
		if e.keyCode == KeyCode.M then&lt;br /&gt;
			osc:send(message)&lt;br /&gt;
		end&lt;br /&gt;
	end)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if example==&amp;quot;server&amp;quot; then&lt;br /&gt;
	-----------------&lt;br /&gt;
	-- Simple server.&lt;br /&gt;
	-- Uses the udp-socket plugin.&lt;br /&gt;
	local udp = plugin.new {&lt;br /&gt;
		recvAddr = &amp;quot;localhost&amp;quot;,&lt;br /&gt;
		recvPort = 9000,&lt;br /&gt;
		ignore_late = true, -- ignore late bundles&lt;br /&gt;
		non_blocking = true, -- do not block on :open(), :poll() handles processing&lt;br /&gt;
	}&lt;br /&gt;
	local osc = losc.new {plugin = udp}&lt;br /&gt;
&lt;br /&gt;
	local function print_data(data)&lt;br /&gt;
		local msg = data.message&lt;br /&gt;
		print(&amp;quot;address: &amp;quot; .. msg.address, &amp;quot;timestamp: &amp;quot; .. data.timestamp)&lt;br /&gt;
		for index, argument in ipairs(msg) do&lt;br /&gt;
			print(&amp;quot;index: &amp;quot; .. index, &amp;quot;arg: &amp;quot; .. argument)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local function print_message(msg)&lt;br /&gt;
		local text = TextField.new(nil, msg.address)&lt;br /&gt;
		stage:addChild(text)&lt;br /&gt;
		text:setPosition(math.random(400), math.random(400))&lt;br /&gt;
		print(&amp;quot;address: &amp;quot; .. msg.address, &amp;quot;time: &amp;quot;..plugin:now():timestamp(plugin.precision))&lt;br /&gt;
		for index, argument in ipairs(msg) do&lt;br /&gt;
			print(&amp;quot;index: &amp;quot; .. index, &amp;quot;arg: &amp;quot; .. argument)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	osc:add_handler(&amp;quot;/foo/bar&amp;quot;, function(data)&lt;br /&gt;
		print_data(data)&lt;br /&gt;
	end)&lt;br /&gt;
	osc:add_handler(&amp;quot;/foo/bar2&amp;quot;, function(data)&lt;br /&gt;
		print_data(data)&lt;br /&gt;
	end)&lt;br /&gt;
&lt;br /&gt;
	osc:open() -- non blocking call :)&lt;br /&gt;
	isopened=true&lt;br /&gt;
&lt;br /&gt;
	function onEnterFrame()&lt;br /&gt;
		local status, data = osc:poll()&lt;br /&gt;
		if status and data then&lt;br /&gt;
			local message = Packet.unpack(data)&lt;br /&gt;
			print_message(message)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)&lt;br /&gt;
&lt;br /&gt;
	stage:addEventListener(Event.KEY_DOWN, function(e)&lt;br /&gt;
		if e.keyCode == KeyCode.S then&lt;br /&gt;
			if not isopened then&lt;br /&gt;
				print(&amp;quot;server opened&amp;quot;)&lt;br /&gt;
				osc:open()&lt;br /&gt;
				isopened = true&lt;br /&gt;
			end&lt;br /&gt;
		elseif e.keyCode == KeyCode.P then&lt;br /&gt;
			if isopened then&lt;br /&gt;
				print(&amp;quot;server closed&amp;quot;)&lt;br /&gt;
				isopened = false&lt;br /&gt;
				osc:close()&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This as a Gideros project: &#039;&#039;&#039;[[Media:Loscdemo.zip]]&#039;&#039;&#039; (&#039;&#039;&#039;tip&#039;&#039;&#039;: right click and Save Link As).&lt;br /&gt;
&lt;br /&gt;
To test the &#039;&#039;&#039;LOSC&#039;&#039;&#039; protocol:&lt;br /&gt;
* uncomment &#039;&#039;example=&amp;quot;server&amp;quot;&#039;&#039;&lt;br /&gt;
* and comment &#039;&#039;example=&amp;quot;client&amp;quot;&#039;&#039;&lt;br /&gt;
* compile the server as an executable then launch it&lt;br /&gt;
* in Gideros:&lt;br /&gt;
* uncomment &#039;&#039;example=&amp;quot;client&amp;quot;&#039;&#039;&lt;br /&gt;
* and comment &#039;&#039;example=&amp;quot;server&amp;quot;&#039;&#039;&lt;br /&gt;
* run the client in Gideros Player&lt;br /&gt;
* the communication should be established between the server and the client&lt;br /&gt;
&lt;br /&gt;
==== Example 2 ====&lt;br /&gt;
Drag your mouse on the clients to draw Pixels on the server.&lt;br /&gt;
&lt;br /&gt;
[[File:Losc_demo4_ss.png]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;client.lua&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
print(&amp;quot;----&amp;quot;)&lt;br /&gt;
print(&amp;quot;LOSC GIDEROS DEMO&amp;quot;)&lt;br /&gt;
print(&amp;quot;LOSC CLIENT&amp;quot;)&lt;br /&gt;
print(&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local losc = require &amp;quot;losc&amp;quot;&lt;br /&gt;
local plugin = require &amp;quot;losc.plugins.udp-socket&amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- simple client, uses the udp-socket plugin&lt;br /&gt;
local udp = plugin.new { sendAddr=&amp;quot;localhost&amp;quot;, sendPort=9000, }&lt;br /&gt;
local osc = losc.new { plugin=udp, }&lt;br /&gt;
&lt;br /&gt;
-- send message&lt;br /&gt;
local message&lt;br /&gt;
local mousex, mousey = 0, 0&lt;br /&gt;
stage:addEventListener(Event.MOUSE_MOVE, function(e)&lt;br /&gt;
	mousex, mousey = e.x, e.y&lt;br /&gt;
	message = losc.new_message {&lt;br /&gt;
		address=&amp;quot;/foo/bar2&amp;quot;, -- &amp;quot;/foo/bar&amp;quot;&lt;br /&gt;
		types=&amp;quot;ii&amp;quot;, -- &amp;quot;ifsb&amp;quot;&lt;br /&gt;
		mousex, mousey, -- 123, 1.2345, &amp;quot;hi&amp;quot;, &amp;quot;blobdata&amp;quot;&lt;br /&gt;
	}&lt;br /&gt;
	osc:send(message)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;server.lua&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
print(&amp;quot;----&amp;quot;)&lt;br /&gt;
print(&amp;quot;LOSC GIDEROS DEMO&amp;quot;)&lt;br /&gt;
print(&amp;quot;LOSC SERVER&amp;quot;)&lt;br /&gt;
print(&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local losc = require &amp;quot;losc&amp;quot;&lt;br /&gt;
local plugin = require &amp;quot;losc.plugins.udp-socket&amp;quot;&lt;br /&gt;
local packet = require &amp;quot;losc.packet&amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- simple server, uses the udp-socket plugin&lt;br /&gt;
local udp = plugin.new {&lt;br /&gt;
	recvAddr=&amp;quot;localhost&amp;quot;,&lt;br /&gt;
	recvPort=9000,&lt;br /&gt;
	ignore_late=true, -- true, false, ignore late bundles&lt;br /&gt;
	non_blocking=true, -- true, false, do not block on :open(), :poll() handles processing&lt;br /&gt;
}&lt;br /&gt;
local osc = losc.new { plugin=udp }&lt;br /&gt;
&lt;br /&gt;
-- a pixel list&lt;br /&gt;
local pixels = {}&lt;br /&gt;
&lt;br /&gt;
-- open server&lt;br /&gt;
osc:open() -- non blocking call :)&lt;br /&gt;
print(&amp;quot;server opened&amp;quot;)&lt;br /&gt;
local isopened = true&lt;br /&gt;
&lt;br /&gt;
-- listeners&lt;br /&gt;
local function process_message(msg)&lt;br /&gt;
	local pixel = Pixel.new(math.random(0xffff00), 1, 32, 32)&lt;br /&gt;
	pixel:setAnchorPoint(0.5, 0.5)&lt;br /&gt;
	pixel:setPosition(msg[1] or 0, msg[2] or 0)&lt;br /&gt;
	pixels[#pixels+1] = pixel&lt;br /&gt;
	stage:addChild(pixel)&lt;br /&gt;
end&lt;br /&gt;
stage:addEventListener(Event.ENTER_FRAME, function(e)&lt;br /&gt;
	local status, data = osc:poll()&lt;br /&gt;
	if status and data then&lt;br /&gt;
		local message = packet.unpack(data)&lt;br /&gt;
		process_message(message)&lt;br /&gt;
	end&lt;br /&gt;
	for i = #pixels, 1, -1 do&lt;br /&gt;
		local pposx, pposy = pixels[i]:getPosition()&lt;br /&gt;
		pposy += 2&lt;br /&gt;
		pixels[i]:setPosition(pposx, pposy)&lt;br /&gt;
		if pposy &amp;gt; 200 then&lt;br /&gt;
			stage:removeChild(pixels[i])&lt;br /&gt;
			pixels[i] = nil&lt;br /&gt;
			table.remove(pixels, i)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end)&lt;br /&gt;
stage:addEventListener(Event.KEY_DOWN, function(e)&lt;br /&gt;
	isopened = not isopened&lt;br /&gt;
	if isopened then&lt;br /&gt;
		osc:open() -- non blocking call :)&lt;br /&gt;
		print(&amp;quot;server opened&amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		osc:close()&lt;br /&gt;
		print(&amp;quot;server closed&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This as a Gideros project: &#039;&#039;&#039;[[Media:Loscdemo4.zip]]&#039;&#039;&#039; (&#039;&#039;&#039;tip&#039;&#039;&#039;: right click and Save Link As).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[[Multiplayer]]&#039;&#039;&#039;&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
</feed>