import Texture from "../textures/Texture";
import MeshStyle from "../styles/MeshStyle";
import VertexDataFormat from "../rendering/VertexDataFormat";
import VertexData from "../rendering/VertexData";
import Painter from "../rendering/Painter";
import IndexData from "../rendering/IndexData";
import Polygon from "../geom/Polygon";
import DisplayObject from "./DisplayObject";
import Rectangle from "openfl/geom/Rectangle";
import Point from "openfl/geom/Point";
declare namespace starling.display {
	/**
	 *  The base class for all tangible (non-container) display objects, spawned up by a number
	 *  *  of triangles.
	 *  *
	 *  *  <p>Since Starling uses Stage3D for rendering, all rendered objects must be constructed
	 *  *  from triangles. A mesh stores the information of its triangles through VertexData and
	 *  *  IndexData structures. The default format stores position, color and texture coordinates
	 *  *  for each vertex.</p>
	 *  *
	 *  *  <p>How a mesh is rendered depends on its style. Per default, this is an instance
	 *  *  of the <code>MeshStyle</code> base class; however, subclasses may extend its behavior
	 *  *  to add support for color transformations, normal mapping, etc.</p>
	 *  *
	 *  *  @see MeshBatch
	 *  *  @see starling.styles.MeshStyle
	 *  *  @see starling.rendering.VertexData
	 *  *  @see starling.rendering.IndexData
	 *  
	 */
	export class Mesh extends DisplayObject {
		/**
		 *  Creates a new mesh with the given vertices and indices.
		 *      *  If you don't pass a style, an instance of <code>MeshStyle</code> will be created
		 *      *  for you. Note that the format of the vertex data will be matched to the
		 *      *  given style right away. 
		 */
		constructor(vertexData: VertexData, indexData: IndexData, style?: MeshStyle);
		/**
		 *  Creates a new instance of the current default MeshStyle. Internally, this method
		 *      *  calls either the <code>defaultStyleFactory</code> or (if no factory has been assigned)
		 *      *  instantiates <code>defaultStyle</code>.
		 *      
		 */
		static createDefaultStyle(instance?: Mesh): MeshStyle;
		/**
		 *  The default style used for meshes if no specific style is provided. The default is
		 *      *  <code>starling.rendering.MeshStyle</code>, and any assigned class must be a subclass
		 *      *  of the same. 
		 */
		static get defaultStyle(): any;
		static set defaultStyle(value: any)
		/**
		 *  A factory method that is used to create the 'MeshStyle' for a mesh if no specific
		 *      *  style is provided. That's useful if you are creating a hierarchy of objects, all
		 *      *  of which need to have a certain style. Different to the <code>defaultStyle</code>
		 *      *  property, this method allows plugging in custom logic and passing arguments to the
		 *      *  constructor. Return <code>null</code> to fall back to the default behavior (i.e.
		 *      *  to instantiate <code>defaultStyle</code>). The <code>mesh</code>-parameter is optional
		 *      *  and may be omitted.
		 *      *
		 *      *  <listing>
		 *      *  Mesh.defaultStyleFactory = function(mesh:Mesh):MeshStyle
		 *      *  {
		 *      *      return new ColorizeMeshStyle(Math.random() * 0xffffff);
		 *      *  }</listing>
		 *      
		 */
		static get defaultStyleFactory(): (arg0?: Mesh) => MeshStyle;
		static set defaultStyleFactory(value: (arg0?: Mesh) => MeshStyle)
		/**
		 *  Creates a mesh from the specified polygon.
		 *      *  Vertex positions and indices will be set up according to the polygon;
		 *      *  any other vertex attributes (e.g. texture coordinates) need to be set up manually.
		 *      
		 */
		static fromPolygon(polygon: Polygon, style?: MeshStyle): Mesh;
		/**
		 *  @inheritDoc 
		 */
		override dispose(): void;
		/**
		 *  @inheritDoc 
		 */
		override hitTest(localPoint: Point): DisplayObject;
		/**
		 *  @inheritDoc 
		 */
		override getBounds(targetSpace: DisplayObject, out?: Rectangle): Rectangle;
		/**
		 *  @inheritDoc 
		 */
		override render(painter: Painter): void;
		/**
		 *  Sets the style that is used to render the mesh. Styles (which are always subclasses of
		 *      *  <code>MeshStyle</code>) provide a means to completely modify the way a mesh is rendered.
		 *      *  For example, they may add support for color transformations or normal mapping.
		 *      *
		 *      *  <p>When assigning a new style, the vertex format will be changed to fit it.
		 *      *  Do not use the same style instance on multiple objects! Instead, make use of
		 *      *  <code>style.clone()</code> to assign an identical style to multiple meshes.</p>
		 *      *
		 *      *  @param meshStyle             the style to assign. If <code>null</code>, the default
		 *      *                               style will be created.
		 *      *  @param mergeWithPredecessor  if enabled, all attributes of the previous style will be
		 *      *                               be copied to the new one, if possible.
		 *      *  @see #defaultStyle
		 *      *  @see #defaultStyleFactory
		 *      
		 */
		setStyle(meshStyle?: MeshStyle, mergeWithPredecessor?: boolean): void;
		/**
		 *  This method is called whenever the mesh's vertex data was changed.
		 *      *  The base implementation simply forwards to <code>setRequiresRedraw</code>. 
		 */
		setVertexDataChanged(): void;
		/**
		 *  This method is called whenever the mesh's index data was changed.
		 *      *  The base implementation simply forwards to <code>setRequiresRedraw</code>. 
		 */
		setIndexDataChanged(): void;
		/**
		 *  The position of the vertex at the specified index, in the mesh's local coordinate
		 *      *  system.
		 *      *
		 *      *  <p>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
		 *      *  <code>Quad</code> 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.</p>
		 *      
		 */
		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;
		/**
		 *  The style that is used to render the mesh. Styles (which are always subclasses of
		 *      *  <code>MeshStyle</code>) provide a means to completely modify the way a mesh is rendered.
		 *      *  For example, they may add support for color transformations or normal mapping.
		 *      *  Beware: a style instance may only be used on one mesh at a time.
		 *      *
		 *      *  @default MeshStyle
		 *      *  @see #setStyle()
		 *      
		 */
		get style(): MeshStyle;
		set style(value: MeshStyle)
		/**
		 *  The texture that is mapped to the mesh (or <code>null</code>, if there is none). 
		 */
		get texture(): Texture;
		set texture(value: Texture)
		/**
		 *  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 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; for a solution that works with all kinds of textures,
		 *      *  see <code>Image.tileGrid</code>. @default false 
		 */
		get textureRepeat(): boolean;
		set textureRepeat(value: boolean)
		/**
		 *  Controls whether or not the instance snaps to the nearest pixel. This can prevent the
		 *      *  object from looking blurry when it's not exactly aligned with the pixels of the screen.
		 *      *  @default false 
		 */
		get pixelSnapping(): boolean;
		set pixelSnapping(value: boolean)
		/**
		 *  The total number of vertices in the mesh. 
		 */
		get numVertices(): number;
		/**
		 *  The total number of indices referencing vertices. 
		 */
		get numIndices(): number;
		/**
		 *  The total number of triangles in this mesh.
		 *      *  (In other words: the number of indices divided by three.) 
		 */
		get numTriangles(): number;
		/**
		 *  The format used to store the vertices. 
		 */
		get vertexFormat(): VertexDataFormat;
	}
}
export default starling.display.Mesh;