starling-framework
Version:
A fast, productive library for 2D cross-platform development.
359 lines • 14.8 kB
TypeScript
import Painter from "../rendering/Painter";
import FragmentFilter from "../filters/FragmentFilter";
import EventDispatcher from "../events/EventDispatcher";
import Event from "../events/Event";
import Stage from "./Stage";
import DisplayObjectContainer from "./DisplayObjectContainer";
import Vector3D from "openfl/geom/Vector3D";
import Rectangle from "openfl/geom/Rectangle";
import Point from "openfl/geom/Point";
import Matrix3D from "openfl/geom/Matrix3D";
import Matrix from "openfl/geom/Matrix";
import BitmapData from "openfl/display/BitmapData";
declare namespace starling.display {
/**
* Dispatched when an object is added to a parent.
*/
export class DisplayObject extends EventDispatcher {
/**
* @private
*/
protected constructor();
/**
* Disposes all resources of the display object.
* * GPU buffers are released, event listeners are removed, filters and masks are disposed.
*/
dispose(): void;
/**
* Removes the object from its parent, if it has one, and optionally disposes it.
*/
removeFromParent(dispose?: boolean): void;
/**
* Creates a matrix that represents the transformation from the local coordinate system
* * to another. If you pass an <code>out</code>-matrix, the result will be stored in this matrix
* * instead of creating a new object.
*/
getTransformationMatrix(targetSpace: DisplayObject, out?: Matrix): Matrix;
/**
* Returns a rectangle that completely encloses the object as it appears in another
* * coordinate system. If you pass an <code>out</code>-rectangle, the result will be stored in this
* * rectangle instead of creating a new object.
*/
getBounds(targetSpace: DisplayObject, out?: Rectangle): Rectangle;
/**
* Returns the object that is found topmost beneath a point in local coordinates, or nil
* * if the test fails. Untouchable and invisible objects will cause the test to fail.
*/
hitTest(localPoint: Point): DisplayObject;
/**
* Checks if a certain point is inside the display object's mask. If there is no mask,
* * this method always returns <code>true</code> (because having no mask is equivalent
* * to having one that's infinitely big).
*/
hitTestMask(localPoint: Point): boolean;
/**
* Transforms a point from the local coordinate system to global (stage) coordinates.
* * If you pass an <code>out</code>-point, the result will be stored in this point instead of
* * creating a new object.
*/
localToGlobal(localPoint: Point, out?: Point): Point;
/**
* Transforms a point from global (stage) coordinates to the local coordinate system.
* * If you pass an <code>out</code>-point, the result will be stored in this point instead of
* * creating a new object.
*/
globalToLocal(globalPoint: Point, out?: Point): Point;
/**
* Renders the display object with the help of a painter object. Never call this method
* * directly, except from within another render method.
* *
* * @param painter Captures the current render state and provides utility functions
* * for rendering.
*
*/
render(painter: Painter): void;
/**
* Moves the pivot point to a certain position within the local coordinate system
* * of the object. If you pass no arguments, it will be centered.
*/
alignPivot(horizontalAlign?: string, verticalAlign?: string): void;
/**
* Draws the object into a BitmapData object.
* *
* * <p>This is achieved by drawing the object into the back buffer and then copying the
* * pixels of the back buffer into a texture. Beware: image sizes bigger than the back
* * buffer are only supported in AIR version 25 or higher and NOT in Flash Player.</p>
* *
* * @param out If you pass null, the object will be created for you.
* * If you pass a BitmapData object, it should have the size of the
* * object bounds, multiplied by the current contentScaleFactor.
* * @param color The RGB color value with which the bitmap will be initialized.
* * @param alpha The alpha value with which the bitmap will be initialized.
*
*/
drawToBitmapData(out?: BitmapData, color?: number, alpha?: number): BitmapData;
/**
* Creates a matrix that represents the transformation from the local coordinate system
* * to another. This method supports three dimensional objects created via 'Sprite3D'.
* * If you pass an <code>out</code>-matrix, the result will be stored in this matrix
* * instead of creating a new object.
*/
getTransformationMatrix3D(targetSpace: DisplayObject, out?: Matrix3D): Matrix3D;
/**
* Transforms a 3D point from the local coordinate system to global (stage) coordinates.
* * This is achieved by projecting the 3D point onto the (2D) view plane.
* *
* * <p>If you pass an <code>out</code>-point, the result will be stored in this point instead of
* * creating a new object.</p>
*/
local3DToGlobal(localPoint: Vector3D, out?: Point): Point;
/**
* Transforms a point from global (stage) coordinates to the 3D local coordinate system.
* * If you pass an <code>out</code>-vector, the result will be stored in this point instead of
* * creating a new object.
*/
globalToLocal3D(globalPoint: Point, out?: Vector3D): Vector3D;
/**
* Forces the object to be redrawn in the next frame.
* * This will prevent the object to be drawn from the render cache.
* *
* * <p>This method is called every time the object changes in any way. When creating
* * custom mesh styles or any other custom rendering code, call this method if the object
* * needs to be redrawn.</p>
* *
* * <p>If the object needs to be redrawn just because it does not support the render cache,
* * call <code>painter.excludeFromCache()</code> in the object's render method instead.
* * That way, Starling's <code>skipUnchangedFrames</code> policy won't be disrupted.</p>
*
*/
setRequiresRedraw(): void;
/**
* Indicates if the object needs to be redrawn in the upcoming frame, i.e. if it has
* * changed its location relative to the stage or some other aspect of its appearance
* * since it was last rendered.
*/
get requiresRedraw(): boolean;
/**
* @private
*/
override dispatchEvent(event: Event): void;
/**
* @inheritDoc
*/
override addEventListener(type: string, listener: Function): void;
/**
* @inheritDoc
*/
override removeEventListener(type: string, listener: Function): void;
/**
* @inheritDoc
*/
override removeEventListeners(type?: string): void;
/**
* The transformation matrix of the object relative to its parent.
* *
* * <p>If you assign a custom transformation matrix, Starling will try to figure out
* * suitable values for <code>x, y, scaleX, scaleY,</code> and <code>rotation</code>.
* * However, if the matrix was created in a different way, this might not be possible.
* * In that case, Starling will apply the matrix, but not update the corresponding
* * properties.</p>
* *
* * <p>CAUTION: not a copy, but the actual object!</p>
*/
get transformationMatrix(): Matrix;
set transformationMatrix(value: Matrix)
/**
* The 3D transformation matrix of the object relative to its parent.
* *
* * <p>For 2D objects, this property returns just a 3D version of the 2D transformation
* * matrix. Only the 'Sprite3D' class supports real 3D transformations.</p>
* *
* * <p>CAUTION: not a copy, but the actual object!</p>
*/
get transformationMatrix3D(): Matrix3D;
/**
* Indicates if this object or any of its parents is a 'Sprite3D' object.
*/
get is3D(): boolean;
/**
* Indicates if the mouse cursor should transform into a hand while it's over the sprite.
* * @default false
*/
get useHandCursor(): boolean;
set useHandCursor(value: boolean)
/**
* The bounds of the object relative to the local coordinates of the parent.
*/
get bounds(): Rectangle;
/**
* The width of the object in pixels.
* * Note that for objects in a 3D space (connected to a Sprite3D), this value might not
* * be accurate until the object is part of the display list.
*/
get width(): number;
set width(value: number)
/**
* The height of the object in pixels.
* * Note that for objects in a 3D space (connected to a Sprite3D), this value might not
* * be accurate until the object is part of the display list.
*/
get height(): number;
set height(value: number)
/**
* The x coordinate of the object relative to the local coordinates of the parent.
*/
get x(): number;
set x(value: number)
/**
* The y coordinate of the object relative to the local coordinates of the parent.
*/
get y(): number;
set y(value: number)
/**
* The x coordinate of the object's origin in its own coordinate space (default: 0).
*/
get pivotX(): number;
set pivotX(value: number)
/**
* The y coordinate of the object's origin in its own coordinate space (default: 0).
*/
get pivotY(): number;
set pivotY(value: number)
/**
* The horizontal scale factor. '1' means no scale, negative values flip the object.
* * @default 1
*/
get scaleX(): number;
set scaleX(value: number)
/**
* The vertical scale factor. '1' means no scale, negative values flip the object.
* * @default 1
*/
get scaleY(): number;
set scaleY(value: number)
/**
* Sets both 'scaleX' and 'scaleY' to the same value. The getter simply returns the
* * value of 'scaleX' (even if the scaling values are different). @default 1
*/
get scale(): number;
set scale(value: number)
/**
* The horizontal skew angle in radians.
*/
get skewX(): number;
set skewX(value: number)
/**
* The vertical skew angle in radians.
*/
get skewY(): number;
set skewY(value: number)
/**
* The rotation of the object in radians. (In Starling, all angles are measured
* * in radians.)
*/
get rotation(): number;
set rotation(value: number)
/**
* The opacity of the object. 0 = transparent, 1 = opaque. @default 1
*/
get alpha(): number;
set alpha(value: number)
/**
* The visibility of the object. An invisible object will be untouchable.
*/
get visible(): boolean;
set visible(value: boolean)
/**
* Indicates if this object (and its children) will receive touch events.
*/
get touchable(): boolean;
set touchable(value: boolean)
/**
* The blend mode determines how the object is blended with the objects underneath.
* * @default auto
* * @see starling.display.BlendMode
*/
get blendMode(): string;
set blendMode(value: string)
/**
* The name of the display object (default: null). Used by 'getChildByName()' of
* * display object containers.
*/
get name(): string;
set name(value: string)
/**
* The filter that is attached to the display object. The <code>starling.filters</code>
* * package contains several classes that define specific filters you can use. To combine
* * several filters, assign an instance of the <code>FilterChain</code> class; to remove
* * all filters, assign <code>null</code>.
* *
* * <p>Beware that a filter instance may only be used on one object at a time! Furthermore,
* * when you remove or replace a filter, it is NOT disposed automatically (since you might
* * want to reuse it on a different object).</p>
* *
* * @default null
* * @see starling.filters.FragmentFilter
* * @see starling.filters.FilterChain
*
*/
get filter(): FragmentFilter;
set filter(value: FragmentFilter)
/**
* The display object that acts as a mask for the current object.
* * Assign <code>null</code> to remove it.
* *
* * <p>A pixel of the masked display object will only be drawn if it is within one of the
* * mask's polygons. Texture pixels and alpha values of the mask are not taken into
* * account. The mask object itself is never visible.</p>
* *
* * <p>If the mask is part of the display list, masking will occur at exactly the
* * location it occupies on the stage. If it is not, the mask will be placed in the local
* * coordinate system of the target object (as if it was one of its children).</p>
* *
* * <p>For rectangular masks, you can use simple quads; for other forms (like circles
* * or arbitrary shapes) it is recommended to use a 'Canvas' instance.</p>
* *
* * <p><strong>Note:</strong> a mask will typically cause at least two additional draw
* * calls: one to draw the mask to the stencil buffer and one to erase it. However, if the
* * mask object is an instance of <code>starling.display.Quad</code> and is aligned
* * parallel to the stage axes, rendering will be optimized: instead of using the
* * stencil buffer, the object will be clipped using the scissor rectangle. That's
* * faster and reduces the number of draw calls, so make use of this when possible.</p>
* *
* * <p><strong>Note:</strong> AIR apps require the <code>depthAndStencil</code> node
* * in the application descriptor XMLs to be enabled! Otherwise, stencil masking won't
* * work.</p>
* *
* * @see Canvas
* * @default null
*
*/
get mask(): DisplayObject;
set mask(value: DisplayObject)
/**
* Indicates if the masked region of this object is set to be inverted.
*/
get maskInverted(): boolean;
set maskInverted(value: boolean)
/**
* The display object container that contains this display object.
*/
get parent(): DisplayObjectContainer;
/**
* The topmost object in the display tree the object is part of.
*/
get base(): DisplayObject;
/**
* The root object the display object is connected to (i.e. an instance of the class
* * that was passed to the Starling constructor), or null if the object is not connected
* * to the stage.
*/
get root(): DisplayObject;
/**
* The stage the display object is connected to, or null if it is not connected
* * to the stage.
*/
get stage(): Stage;
}
}
export default starling.display.DisplayObject;