UNPKG

starling-framework

Version:

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

63 lines 2.44 kB
import Texture from "../textures/Texture"; import Mesh from "./Mesh"; import DisplayObject from "./DisplayObject"; import Rectangle from "openfl/geom/Rectangle"; import Point from "openfl/geom/Point"; declare namespace starling.display { /** * A Quad represents a colored and/or textured rectangle. * * * * <p>Quads may have a color and a texture. When assigning a texture, the colors of the * * vertices will "tint" the texture, i.e. the vertex color will be multiplied with the color * * of the texture at the same position. That's why the default color of a quad is pure white: * * tinting with white does not change the texture color (that's a multiplication with one).</p> * * * * <p>A quad is, by definition, always rectangular. The basic quad class will always contain * * exactly four vertices, arranged like this:</p> * * * * <pre> * * 0 - 1 * * | / | * * 2 - 3 * * </pre> * * * * <p>You can set the color of each vertex individually; and since the colors will smoothly * * fade into each other over the area of the quad, you can use this to create simple linear * * color gradients (e.g. by assigning one color to vertices 0 and 1 and another to vertices * * 2 and 3).</p> * * * * <p>However, note that the number of vertices may be different in subclasses. * * Check the property <code>numVertices</code> if you are unsure.</p> * * * * @see starling.textures.Texture * * @see Image * */ export class Quad extends Mesh { /** * Creates a quad with a certain size and color. */ constructor(width: number, height: number, color?: number); /** * Creates a quad from the given texture. * * The quad will have the same size as the texture. */ static fromTexture(texture: Texture): Quad; /** * @inheritDoc */ override getBounds(targetSpace: DisplayObject, out?: Rectangle): Rectangle; /** * @inheritDoc */ override hitTest(localPoint: Point): DisplayObject; /** * Readjusts the dimensions of the quad. Use this method without any arguments to * * synchronize quad and texture size after assigning a texture with a different size. * * You can also force a certain width and height by passing positive, non-zero * * values for width and height. */ readjustSize(width?: number, height?: number): void; } } export default starling.display.Quad;