UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

806 lines (805 loc) 98 kB
<!doctype html> <html class="default no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>MeshStyle | starling-framework</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../assets/css/main.css"> </head> <body> <header> <div class="tsd-page-toolbar"> <div class="container"> <div class="table-wrap"> <div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base=".."> <div class="field"> <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> <input id="tsd-search-field" type="text" /> </div> <ul class="results"> <li class="state loading">Preparing search index...</li> <li class="state failure">The search index is not available</li> </ul> <a href="../index.html" class="title">starling-framework</a> </div> <div class="table-cell" id="tsd-widgets"> <div id="tsd-filter"> <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> <div class="tsd-filter-group"> <div class="tsd-select" id="tsd-filter-visibility"> <span class="tsd-select-label">All</span> <ul class="tsd-select-list"> <li data-value="public">Public</li> <li data-value="protected">Public/Protected</li> <li data-value="private" class="selected">All</li> </ul> </div> <input type="checkbox" id="tsd-filter-inherited" checked /> <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label> <input type="checkbox" id="tsd-filter-externals" checked /> <label class="tsd-widget" for="tsd-filter-externals">Externals</label> <input type="checkbox" id="tsd-filter-only-exported" /> <label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label> </div> </div> <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> </div> </div> </div> </div> <div class="tsd-page-title"> <div class="container"> <ul class="tsd-breadcrumb"> <li> <a href="../index.html">starling</a> </li> <li> <a href="../modules/starling.styles.html">styles</a> </li> <li> <a href="starling.styles.meshstyle.html">MeshStyle</a> </li> </ul> <h1>Class MeshStyle</h1> </div> </div> </header> <div class="container container-main"> <div class="row"> <div class="col-8 col-content"> <section class="tsd-panel tsd-comment"> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>MeshStyles provide a means to completely modify the way a mesh is rendered. The base class provides Starling&#39;s standard mesh rendering functionality: colored and (optionally) textured meshes. Subclasses may add support for additional features like color transformations, normal mapping, etc.</p> </div> <p><strong>Using styles</strong></p> <p>First, create an instance of the desired style. Configure the style by updating its properties, then assign it to the mesh. Here is an example that uses a fictitious <code>ColorStyle</code>:</p> <listing> image:Image = new Image(heroTexture); colorStyle:ColorStyle = new ColorStyle(); colorStyle.redOffset = 0.5; colorStyle.redMultiplier = 2.0; image.style = colorStyle;</listing> <p>Beware:</p> <ul> <li>A style instance may only be used on one object at a time.</li> <li>A style might require the use of a specific vertex format; when the style is assigned, the mesh is converted to that format.</li> </ul> <p><strong>Creating your own styles</strong></p> <p>To create custom rendering code in Starling, you need to extend two classes: <code>MeshStyle</code> and <code>MeshEffect</code>. While the effect class contains the actual AGAL rendering code, the style provides the API that other developers will interact with.</p> <p>Subclasses of <code>MeshStyle</code> will add specific properties that configure the style&#39;s outcome, like the <code>redOffset</code> and <code>redMultiplier</code> properties in the sample above. Here&#39;s how to properly create such a class:</p> <ul> <li>Always provide a constructor that can be called without any arguments.</li> <li>Override <code>copyFrom</code> — that&#39;s necessary for batching.</li> <li>Override <code>createEffect</code> — this method must return the <code>MeshEffect</code> that will do the actual Stage3D rendering.</li> <li>Override <code>updateEffect</code> — this configures the effect created above right before rendering.</li> <li>Override <code>canBatchWith</code> if necessary — this method figures out if one instance of the style can be batched with another. If they all can, you can leave this out.</li> </ul> <p>If the style requires a custom vertex format, you must also:</p> <ul> <li>add a static constant called <code>VERTEX_FORMAT</code> to the class and</li> <li>override <code>get vertexFormat</code> and let it return exactly that format.</li> </ul> <p>When that&#39;s done, you can turn to the implementation of your <code>MeshEffect</code>; the <code>createEffect</code>-override will return an instance of this class. Directly before rendering begins, Starling will then call <code>updateEffect</code> to set it up.</p> <p> @see starling.rendering.MeshEffect @see starling.rendering.VertexDataFormat @see starling.display.Mesh</p> </div> </section> <section class="tsd-panel tsd-hierarchy"> <h3>Hierarchy</h3> <ul class="tsd-hierarchy"> <li> <a href="starling.events.eventdispatcher.html" class="tsd-signature-type">EventDispatcher</a> <ul class="tsd-hierarchy"> <li> <span class="target">MeshStyle</span> <ul class="tsd-hierarchy"> <li> <a href="starling.styles.distancefieldstyle.html" class="tsd-signature-type">DistanceFieldStyle</a> </li> </ul> </li> </ul> </li> </ul> </section> <section class="tsd-panel-group tsd-index-group"> <h2>Index</h2> <section class="tsd-panel tsd-index-panel"> <div class="tsd-index-content"> <section class="tsd-index-section tsd-is-external"> <h3>Constructors</h3> <ul class="tsd-index-list"> <li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite tsd-is-external"><a href="starling.styles.meshstyle.html#constructor" class="tsd-kind-icon">constructor</a></li> </ul> </section> <section class="tsd-index-section tsd-is-external"> <h3>Properties</h3> <ul class="tsd-index-list"> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#color" class="tsd-kind-icon">color</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#indexdata" class="tsd-kind-icon">index<wbr>Data</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#target" class="tsd-kind-icon">target</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#texture" class="tsd-kind-icon">texture</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#texturerepeat" class="tsd-kind-icon">texture<wbr>Repeat</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#texturesmoothing" class="tsd-kind-icon">texture<wbr>Smoothing</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#type" class="tsd-kind-icon">type</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#vertexdata" class="tsd-kind-icon">vertex<wbr>Data</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#vertexformat" class="tsd-kind-icon">vertex<wbr>Format</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-static tsd-is-external"><a href="starling.styles.meshstyle.html#vertex_format" class="tsd-kind-icon">VERTEX_<wbr>FORMAT</a></li> </ul> </section> <section class="tsd-index-section tsd-is-external"> <h3>Methods</h3> <ul class="tsd-index-list"> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-overwrite tsd-is-external"><a href="starling.styles.meshstyle.html#addeventlistener" class="tsd-kind-icon">add<wbr>Event<wbr>Listener</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#batchindexdata" class="tsd-kind-icon">batch<wbr>Index<wbr>Data</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#batchvertexdata" class="tsd-kind-icon">batch<wbr>Vertex<wbr>Data</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#canbatchwith" class="tsd-kind-icon">can<wbr>Batch<wbr>With</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#clone" class="tsd-kind-icon">clone</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#copyfrom" class="tsd-kind-icon">copy<wbr>From</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#createeffect" class="tsd-kind-icon">create<wbr>Effect</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.styles.meshstyle.html#dispatchevent" class="tsd-kind-icon">dispatch<wbr>Event</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.styles.meshstyle.html#dispatcheventwith" class="tsd-kind-icon">dispatch<wbr>Event<wbr>With</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#gettexcoords" class="tsd-kind-icon">get<wbr>Tex<wbr>Coords</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#getvertexalpha" class="tsd-kind-icon">get<wbr>Vertex<wbr>Alpha</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#getvertexcolor" class="tsd-kind-icon">get<wbr>Vertex<wbr>Color</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#getvertexposition" class="tsd-kind-icon">get<wbr>Vertex<wbr>Position</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#get_color" class="tsd-kind-icon">get_<wbr>color</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#get_indexdata" class="tsd-kind-icon">get_<wbr>index<wbr>Data</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#get_target" class="tsd-kind-icon">get_<wbr>target</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#get_texture" class="tsd-kind-icon">get_<wbr>texture</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#get_texturerepeat" class="tsd-kind-icon">get_<wbr>texture<wbr>Repeat</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#get_texturesmoothing" class="tsd-kind-icon">get_<wbr>texture<wbr>Smoothing</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#get_type" class="tsd-kind-icon">get_<wbr>type</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#get_vertexdata" class="tsd-kind-icon">get_<wbr>vertex<wbr>Data</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#get_vertexformat" class="tsd-kind-icon">get_<wbr>vertex<wbr>Format</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.styles.meshstyle.html#haseventlistener" class="tsd-kind-icon">has<wbr>Event<wbr>Listener</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-overwrite tsd-is-external"><a href="starling.styles.meshstyle.html#removeeventlistener" class="tsd-kind-icon">remove<wbr>Event<wbr>Listener</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.styles.meshstyle.html#removeeventlisteners" class="tsd-kind-icon">remove<wbr>Event<wbr>Listeners</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#settexcoords" class="tsd-kind-icon">set<wbr>Tex<wbr>Coords</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#setvertexalpha" class="tsd-kind-icon">set<wbr>Vertex<wbr>Alpha</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#setvertexcolor" class="tsd-kind-icon">set<wbr>Vertex<wbr>Color</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#setvertexposition" class="tsd-kind-icon">set<wbr>Vertex<wbr>Position</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#set_color" class="tsd-kind-icon">set_<wbr>color</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#set_texture" class="tsd-kind-icon">set_<wbr>texture</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#set_texturerepeat" class="tsd-kind-icon">set_<wbr>texture<wbr>Repeat</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.styles.meshstyle.html#set_texturesmoothing" class="tsd-kind-icon">set_<wbr>texture<wbr>Smoothing</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.styles.meshstyle.html#updateeffect" class="tsd-kind-icon">update<wbr>Effect</a></li> </ul> </section> </div> </section> </section> <section class="tsd-panel-group tsd-member-group tsd-is-external"> <h2>Constructors</h2> <section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite tsd-is-external"> <a name="constructor" class="tsd-anchor"></a> <h3>constructor</h3> <ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite tsd-is-external"> <li class="tsd-signature tsd-kind-icon">new <wbr>Mesh<wbr>Style<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Overrides <a href="starling.events.eventdispatcher.html">EventDispatcher</a>.<a href="starling.events.eventdispatcher.html#constructor">constructor</a></p> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L85">lib/starling/styles/MeshStyle.d.ts:85</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Creates a new MeshStyle instance. Subclasses must provide a constructor that can be called without any arguments.</p> </div> </div> <h4 class="tsd-returns-title">Returns <a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a></h4> </li> </ul> </section> </section> <section class="tsd-panel-group tsd-member-group tsd-is-external"> <h2>Properties</h2> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="color" class="tsd-anchor"></a> <h3>color</h3> <div class="tsd-signature tsd-kind-icon">color<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L201">lib/starling/styles/MeshStyle.d.ts:201</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Changes the color of all vertices to the same value. The getter simply returns the color of the first vertex.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="indexdata" class="tsd-anchor"></a> <h3>index<wbr>Data</h3> <div class="tsd-signature tsd-kind-icon">index<wbr>Data<span class="tsd-signature-symbol">:</span> <a href="starling.rendering.indexdata.html" class="tsd-signature-type">IndexData</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L192">lib/starling/styles/MeshStyle.d.ts:192</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns a reference to the index data of the assigned target (or <code>null</code> if there is no target). Beware: the style itself does not own any indices; it is limited to manipulating those of the target mesh.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="target" class="tsd-anchor"></a> <h3>target</h3> <div class="tsd-signature tsd-kind-icon">target<span class="tsd-signature-symbol">:</span> <a href="starling.display.mesh.html" class="tsd-signature-type">Mesh</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L226">lib/starling/styles/MeshStyle.d.ts:226</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The target the style is currently assigned to.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="texture" class="tsd-anchor"></a> <h3>texture</h3> <div class="tsd-signature tsd-kind-icon">texture<span class="tsd-signature-symbol">:</span> <a href="starling.textures.texture.html" class="tsd-signature-type">Texture</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L210">lib/starling/styles/MeshStyle.d.ts:210</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The texture that is mapped to the mesh (or <code>null</code>, if there is none).</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="texturerepeat" class="tsd-anchor"></a> <h3>texture<wbr>Repeat</h3> <div class="tsd-signature tsd-kind-icon">texture<wbr>Repeat<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L221">lib/starling/styles/MeshStyle.d.ts:221</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Indicates if pixels at the edges will be repeated or clamped. Only works for power-of-two textures. @default false</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="texturesmoothing" class="tsd-anchor"></a> <h3>texture<wbr>Smoothing</h3> <div class="tsd-signature tsd-kind-icon">texture<wbr>Smoothing<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L215">lib/starling/styles/MeshStyle.d.ts:215</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The smoothing filter that is used for the texture. @default bilinear</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="type" class="tsd-anchor"></a> <h3>type</h3> <div class="tsd-signature tsd-kind-icon">type<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L196">lib/starling/styles/MeshStyle.d.ts:196</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The actual class of this style.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="vertexdata" class="tsd-anchor"></a> <h3>vertex<wbr>Data</h3> <div class="tsd-signature tsd-kind-icon">vertex<wbr>Data<span class="tsd-signature-symbol">:</span> <a href="starling.rendering.vertexdata.html" class="tsd-signature-type">VertexData</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L186">lib/starling/styles/MeshStyle.d.ts:186</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns a reference to the vertex data of the assigned target (or <code>null</code> if there is no target). Beware: the style itself does not own any vertices; it is limited to manipulating those of the target mesh.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="vertexformat" class="tsd-anchor"></a> <h3>vertex<wbr>Format</h3> <div class="tsd-signature tsd-kind-icon">vertex<wbr>Format<span class="tsd-signature-symbol">:</span> <a href="starling.rendering.vertexdataformat.html" class="tsd-signature-type">VertexDataFormat</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L206">lib/starling/styles/MeshStyle.d.ts:206</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The format used to store the vertices.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-static tsd-is-external"> <a name="vertex_format" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagStatic">Static</span> VERTEX_<wbr>FORMAT</h3> <div class="tsd-signature tsd-kind-icon">VERTEX_<wbr>FORMAT<span class="tsd-signature-symbol">:</span> <a href="starling.rendering.vertexdataformat.html" class="tsd-signature-type">VertexDataFormat</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L85">lib/starling/styles/MeshStyle.d.ts:85</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The vertex format expected by this style (the same as found in the MeshEffect-class).</p> </div> </div> </section> </section> <section class="tsd-panel-group tsd-member-group tsd-is-external"> <h2>Methods</h2> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-overwrite tsd-is-external"> <a name="addeventlistener" class="tsd-anchor"></a> <h3>add<wbr>Event<wbr>Listener</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-overwrite tsd-is-external"> <li class="tsd-signature tsd-kind-icon">add<wbr>Event<wbr>Listener<span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, listener<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Overrides <a href="starling.events.eventdispatcher.html">EventDispatcher</a>.<a href="starling.events.eventdispatcher.html#addeventlistener">addEventListener</a></p> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L144">lib/starling/styles/MeshStyle.d.ts:144</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>type: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5>listener: <span class="tsd-signature-type">Function</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="batchindexdata" class="tsd-anchor"></a> <h3>batch<wbr>Index<wbr>Data</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">batch<wbr>Index<wbr>Data<span class="tsd-signature-symbol">(</span>targetStyle<span class="tsd-signature-symbol">: </span><a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a>, targetIndexID<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, offset<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, indexID<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, numIndices<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L139">lib/starling/styles/MeshStyle.d.ts:139</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Copies the index data of the style&#39;s current target to the target of another style. The given offset value will be added to all indices during the process.</p> </div> <p>This method is used when batching meshes together for rendering. The parameter <code>targetStyle</code> will point to the style of a <code>MeshBatch</code> (a subclass of <code>Mesh</code>). Subclasses may override this method if they need to modify the index data in that process.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>targetStyle: <a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> targetIndexID: <span class="tsd-signature-type">number</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> offset: <span class="tsd-signature-type">number</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> indexID: <span class="tsd-signature-type">number</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> numIndices: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="batchvertexdata" class="tsd-anchor"></a> <h3>batch<wbr>Vertex<wbr>Data</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">batch<wbr>Vertex<wbr>Data<span class="tsd-signature-symbol">(</span>targetStyle<span class="tsd-signature-symbol">: </span><a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a>, targetVertexID<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, matrix<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Matrix</span>, vertexID<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, numVertices<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L128">lib/starling/styles/MeshStyle.d.ts:128</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Copies the vertex data of the style&#39;s current target to the target of another style. If you pass a matrix, all vertices will be transformed during the process.</p> </div> <p>This method is used when batching meshes together for rendering. The parameter <code>targetStyle</code> will point to the style of a <code>MeshBatch</code> (a subclass of <code>Mesh</code>). Subclasses may override this method if they need to modify the vertex data in that process.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>targetStyle: <a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> targetVertexID: <span class="tsd-signature-type">number</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> matrix: <span class="tsd-signature-type">Matrix</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> vertexID: <span class="tsd-signature-type">number</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> numVertices: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="canbatchwith" class="tsd-anchor"></a> <h3>can<wbr>Batch<wbr>With</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">can<wbr>Batch<wbr>With<span class="tsd-signature-symbol">(</span>meshStyle<span class="tsd-signature-symbol">: </span><a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L118">lib/starling/styles/MeshStyle.d.ts:118</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Indicates if the current instance can be batched with the given style. To be overridden by subclasses if default behavior is not sufficient. The base implementation just checks if the styles are of the same type and if the textures are compatible.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>meshStyle: <a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="clone" class="tsd-anchor"></a> <h3>clone</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">clone<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L98">lib/starling/styles/MeshStyle.d.ts:98</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Creates a clone of this instance. The method will work for subclasses automatically, no need to override it.</p> </div> </div> <h4 class="tsd-returns-title">Returns <a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="copyfrom" class="tsd-anchor"></a> <h3>copy<wbr>From</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">copy<wbr>From<span class="tsd-signature-symbol">(</span>meshStyle<span class="tsd-signature-symbol">: </span><a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L94">lib/starling/styles/MeshStyle.d.ts:94</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Copies all properties of the given style to the current instance (or a subset, if the classes don&#39;t match). Must be overridden by all subclasses!</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>meshStyle: <a href="starling.styles.meshstyle.html" class="tsd-signature-type">MeshStyle</a></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="createeffect" class="tsd-anchor"></a> <h3>create<wbr>Effect</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">create<wbr>Effect<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="starling.rendering.mesheffect.html" class="tsd-signature-type">MeshEffect</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L103">lib/starling/styles/MeshStyle.d.ts:103</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Creates the effect that does the actual, low-level rendering. To be overridden by subclasses!</p> </div> </div> <h4 class="tsd-returns-title">Returns <a href="starling.rendering.mesheffect.html" class="tsd-signature-type">MeshEffect</a></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <a name="dispatchevent" class="tsd-anchor"></a> <h3>dispatch<wbr>Event</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <li class="tsd-signature tsd-kind-icon">dispatch<wbr>Event<span class="tsd-signature-symbol">(</span>event<span class="tsd-signature-symbol">: </span><a href="starling.events.event.html" class="tsd-signature-type">Event</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Inherited from <a href="starling.events.eventdispatcher.html">EventDispatcher</a>.<a href="starling.events.eventdispatcher.html#dispatchevent">dispatchEvent</a></p> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/events/EventDispatcher.d.ts#L45">lib/starling/events/EventDispatcher.d.ts:45</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Dispatches an event to all objects that have registered listeners for its type. If an event with enabled &#39;bubble&#39; property is dispatched to a display object, it will travel up along the line of parents, until it either hits the root object or someone stops its propagation manually.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>event: <a href="starling.events.event.html" class="tsd-signature-type">Event</a></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <a name="dispatcheventwith" class="tsd-anchor"></a> <h3>dispatch<wbr>Event<wbr>With</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <li class="tsd-signature tsd-kind-icon">dispatch<wbr>Event<wbr>With<span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, bubbles<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span>, data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Inherited from <a href="starling.events.eventdispatcher.html">EventDispatcher</a>.<a href="starling.events.eventdispatcher.html#dispatcheventwith">dispatchEventWith</a></p> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/events/EventDispatcher.d.ts#L50">lib/starling/events/EventDispatcher.d.ts:50</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Dispatches an event with the given parameters to all objects that have registered listeners for the given type. The method uses an internal pool of event objects to avoid allocations.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>type: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> bubbles: <span class="tsd-signature-type">boolean</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> data: <span class="tsd-signature-type">any</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="gettexcoords" class="tsd-anchor"></a> <h3>get<wbr>Tex<wbr>Coords</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">get<wbr>Tex<wbr>Coords<span class="tsd-signature-symbol">(</span>vertexID<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, out<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Point</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Point</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L176">lib/starling/styles/MeshStyle.d.ts:176</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the texture coordinates of the vertex at the specified index.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>vertexID: <span class="tsd-signature-type">number</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> out: <span class="tsd-signature-type">Point</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Point</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="getvertexalpha" class="tsd-anchor"></a> <h3>get<wbr>Vertex<wbr>Alpha</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">get<wbr>Vertex<wbr>Alpha<span class="tsd-signature-symbol">(</span>vertexID<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L164">lib/starling/styles/MeshStyle.d.ts:164</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the alpha value of the vertex at the specified index.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>vertexID: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="getvertexcolor" class="tsd-anchor"></a> <h3>get<wbr>Vertex<wbr>Color</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">get<wbr>Vertex<wbr>Color<span class="tsd-signature-symbol">(</span>vertexID<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L170">lib/starling/styles/MeshStyle.d.ts:170</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the RGB color of the vertex at the specified index.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>vertexID: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="getvertexposition" class="tsd-anchor"></a> <h3>get<wbr>Vertex<wbr>Position</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">get<wbr>Vertex<wbr>Position<span class="tsd-signature-symbol">(</span>vertexID<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, out<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Point</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Point</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/styles/MeshStyle.d.ts#L159">lib/starling/styles/MeshStyle.d.ts:159</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The position of the vertex at the specified index, in the mesh&#39;s local coordinate system.</p> </div> <p>Only modify the position of a vertex if you know exactly what you&#39;re doing, as some classes might not work correctly when their vertices are moved. E.g. the <code>Quad</code> class expects its vertices to spawn up a perfectly rectangular area; some of its optimized methods won&#39;t work correctly if that premise is no longer fulfilled or the original bounds change.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4>