import Texture from "../textures/Texture"; import VertexDataFormat from "../rendering/VertexDataFormat"; import VertexData from "../rendering/VertexData"; import RenderState from "../rendering/RenderState"; import MeshEffect from "../rendering/MeshEffect"; import IndexData from "../rendering/IndexData"; import EventDispatcher from "../events/EventDispatcher"; import Mesh from "../display/Mesh"; import Point from "openfl/geom/Point"; import Matrix from "openfl/geom/Matrix"; declare namespace starling.styles { /** * Dispatched every frame on styles assigned to display objects connected to the stage. */ export class MeshStyle extends EventDispatcher { /** * Creates a new MeshStyle instance. * * Subclasses must provide a constructor that can be called without any arguments. */ constructor(); /** * The vertex format expected by this style (the same as found in the MeshEffect-class). */ static VERTEX_FORMAT: VertexDataFormat; /** * Copies all properties of the given style to the current instance (or a subset, if the * * classes don't match). Must be overridden by all subclasses! * */ copyFrom(meshStyle: MeshStyle): void; /** * Creates a clone of this instance. The method will work for subclasses automatically, * * no need to override it. */ clone(): MeshStyle; /** * Creates the effect that does the actual, low-level rendering. * * To be overridden by subclasses! * */ createEffect(): MeshEffect; /** * Updates the settings of the given effect to match the current style. * * The given effect will always match the class returned by * * createEffect. * * * *

To be overridden by subclasses!

* */ updateEffect(effect: MeshEffect, state: RenderState): void; /** * 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. * */ canBatchWith(meshStyle: MeshStyle): boolean; /** * Copies the vertex data of the style's current target to the target of another style. * * If you pass a matrix, all vertices will be transformed during the process. * * * *

This method is used when batching meshes together for rendering. The parameter * * targetStyle will point to the style of a MeshBatch (a * * subclass of Mesh). Subclasses may override this method if they need * * to modify the vertex data in that process.

* */ batchVertexData(targetStyle: MeshStyle, targetVertexID?: number, matrix?: Matrix, vertexID?: number, numVertices?: number): void; /** * Copies the index data of the style's current target to the target of another style. * * The given offset value will be added to all indices during the process. * * * *

This method is used when batching meshes together for rendering. The parameter * * targetStyle will point to the style of a MeshBatch (a * * subclass of Mesh). Subclasses may override this method if they need * * to modify the index data in that process.

* */ batchIndexData(targetStyle: MeshStyle, targetIndexID?: number, offset?: number, indexID?: number, numIndices?: number): void; override addEventListener(type: string, listener: Function): void; override removeEventListener(type: string, listener: Function): void; /** * The position of the vertex at the specified index, in the mesh's local coordinate * * system. * * * *

Only modify the position of a vertex if you know exactly what you're doing, as * * some classes might not work correctly when their vertices are moved. E.g. the * * Quad class expects its vertices to spawn up a perfectly rectangular * * area; some of its optimized methods won't work correctly if that premise is no longer * * fulfilled or the original bounds change.

* */ getVertexPosition(vertexID: number, out?: Point): Point; setVertexPosition(vertexID: number, x: number, y: number): void; /** * Returns the alpha value of the vertex at the specified index. */ getVertexAlpha(vertexID: number): number; /** * Sets the alpha value of the vertex at the specified index to a certain value. */ setVertexAlpha(vertexID: number, alpha: number): void; /** * Returns the RGB color of the vertex at the specified index. */ getVertexColor(vertexID: number): number; /** * Sets the RGB color of the vertex at the specified index to a certain value. */ setVertexColor(vertexID: number, color: number): void; /** * Returns the texture coordinates of the vertex at the specified index. */ getTexCoords(vertexID: number, out?: Point): Point; /** * Sets the texture coordinates of the vertex at the specified index to the given values. */ setTexCoords(vertexID: number, u: number, v: number): void; /** * Returns a reference to the vertex data of the assigned target (or null * * if there is no target). Beware: the style itself does not own any vertices; * * it is limited to manipulating those of the target mesh. */ get vertexData(): VertexData; /** * Returns a reference to the index data of the assigned target (or null * * if there is no target). Beware: the style itself does not own any indices; * * it is limited to manipulating those of the target mesh. */ get indexData(): IndexData; /** * The actual class of this style. */ get type(): any; /** * Changes the color of all vertices to the same value. * * The getter simply returns the color of the first vertex. */ get color(): number; set color(value: number) /** * The format used to store the vertices. */ get vertexFormat(): VertexDataFormat; /** * The texture that is mapped to the mesh (or null, if there is none). */ get texture(): Texture; set texture(value: Texture) /** * The smoothing filter that is used for the texture. @default bilinear */ get textureSmoothing(): string; set textureSmoothing(value: string) /** * Indicates if pixels at the edges will be repeated or clamped. * * Only works for power-of-two textures. @default false */ get textureRepeat(): boolean; set textureRepeat(value: boolean) /** * The target the style is currently assigned to. */ get target(): Mesh; } } export default starling.styles.MeshStyle;