Static methods

statictakeControl(app:App, ?s3d:Scene):Void

Constructor

new(?parent:Object)

Variables

@:value(new Array<Int>())colors:Array<Int> = new Array<Int>()

@:value(true)displayTriangleCount:Bool = true

enable:Bool

@:value(false)estimateWait:Bool = false

@:value(16)height:Int = 16

@:value(false)measureCpu:Bool = false

@:value(1e9)recalTime:Float = 1e9

@:value(0.95)smoothTime:Float = 0.95

@:value(0)textColor:Int = 0

width:Null<Int>

Methods

@:value({ withVisual : true })begin(withVisual:Bool = true):Void

end():Void

getCurrentId():String

measure(name:String):Void

syncVisual():Void

Inherited Variables

Defined by Graphics

@:value(0.25)bevel:Float = 0.25

Adds bevel cut-off at line corners.

The value is a percentile in range of 0...1, dictating at which point edges get beveled based on their angle. Value of 0 being not beveled and 1 being always beveled.

tile:Tile

The Tile used as source of Texture to render.

Defined by Drawable

color:Vector4

The color multiplier for the drawable. Can be used to adjust individually each of the four channels R,G,B,A (default [1,1,1,1])

colorAdd:Null<Vector>

Setting colorAdd will add the amount of color of each channel R,G,B,A to the object pixels.

colorKey:Null<Int>

Setting a colorKey color value will discard all pixels that have this exact color in the tile.

colorMatrix:Null<Matrix>

Setting a colorMatrix will apply a color transformation. See also adjustColor.

smooth:Null<Bool>

By enabling smoothing, scaling the object up or down will use hardware bilinear filtering resulting in a less crisp aspect.

By default smooth is null in which case Scene.defaultSmooth value is used.

tileWrap:Bool

Enables texture uv wrap for this Drawable, causing tiles with uv exceeding the texture size to repeat instead of clamping on edges.

Note that tileWrap does not use the Tile region as a wrapping area but instead uses underlying h3d.mat.Texture size. This is due to implementation specifics, as it just sets the Texture.wrap to either Repeat or Clamp. Because of that, proper Tile tiling can be expected only when the tile covers an entire Texture area.

Defined by Object

private@:dox(show)allocated:Bool

A flag that indicates whether the object was allocated or not.

When adding children to allocated objects, onAdd is being called immediately, otherwise it's delayed until the whole tree is added to a currently active Scene.

@:value(1.)alpha:Float = 1.

The amount of transparency of the Object.

@:value(Alpha)blendMode:BlendMode = Alpha

The blending mode of the object.

If there is no Object.filter active, only applies to the current object (not inherited by children). Otherwise tells how the filter is blended with background.

filter:Filter

The post process filter for this object.

When set, Object.alpha value affects both filter and object transparency (use Drawable.color.a to set transparency only for the object).

name:String

The name of the object. Can be used to retrieve an object within a tree by using Object.getObjectByName.

read onlynumChildren:Int

How many immediate children this object has.

read onlyparent:Object

The parent object in the scene tree.

private@:dox(show)parentContainer:Object

The parent container of this object. See Object.contentChanged for more details.

private@:dox(show)posChanged:Bool

A flag that indicates that the object transform was modified and absolute position recalculation is required.

Automatically cleared on Object.sync and can be manually synced with the Object.syncPos.

@:value(0)rotation:Float = 0

The rotation angle of this object, in radians.

@:value(1)scaleX:Float = 1

The amount of horizontal scaling of this object.

@:value(1)scaleY:Float = 1

The amount of vertical scaling of this object.

@:value(true)visible:Bool = true

Is the object and its children are displayed on screen.

@:value(0)x:Float = 0

The x position (in pixels) of the object relative to its parent.

@:value(0)y:Float = 0

The y position (in pixels) of the object relative to its parent.

Inherited Methods

Defined by Graphics

@:value({ v : 0., u : 0. })addVertex(x:Float, y:Float, r:Float, g:Float, b:Float, a:Float, u:Float = 0., v:Float = 0.):Void

Advanced usage. Adds new vertex to the current polygon with given parameters and current line style.

Parameters:

x

Vertex X position

y

Vertex Y position

r

Red tint value of the vertex when performing fill operation.

g

Green tint value of the vertex when performing fill operation.

b

Blue tint value of the vertex when performing fill operation.

a

Alpha of the vertex when performing fill operation.

u

Normalized horizontal Texture position from the current Tile fill operation.

v

Normalized vertical Texture position from the current Tile fill operation.

@:value({ alpha : 1., color : 0 })beginFill(color:Int = 0, alpha:Float = 1.):Void

Begins a solid color fill.

Beginning new fill will finish previous fill operation without need to call Graphics.endFill.

Parameters:

color

An RGB color with which to fill the drawn shapes.

alpha

A transparency of the fill color.

beginTileFill(?dx:Float, ?dy:Float, ?scaleX:Float, ?scaleY:Float, ?tile:Tile):Void

Position a virtual tile at the given position and scale. Every draw will display a part of this tile relative to these coordinates.

Note that in by default, Tile is not wrapped, and in order to render a tiling texture, Drawable.tileWrap has to be set. Additionally, both Tile.dx and Tile.dy are ignored (use dx/dy arguments instead) as well as tile defined size of the tile through Tile.width and Tile.height (use scaleX/scaleY relative to texture size).

Beginning new fill will finish previous fill operation without need to call Graphics.endFill.

Parameters:

dx

An X offset of the Tile relative to Graphics.

dy

An Y offset of the Tile relative to Graphics.

scaleX

A horizontal scale factor applied to the Tile texture.

scaleY

A vertical scale factor applied to the Tile texture.

tile

The tile to fill with. If null, uses previously used Tile with beginTileFill or throws an error. Previous tile is remembered across Graphics.clear calls.

@:value({ nsegments : 40 })cubicCurveTo(bx:Float, by:Float, cx:Float, cy:Float, dx:Float, dy:Float, nsegments:Int = 40):Void

Draws a cubic Bezier curve from the current drawing position to the specified anchor point. IvanK Lib port ( http://lib.ivank.net )

Parameters:

bx

control X for start point

by

control Y for start point

cx

control X for end point

cy

control Y for end point

dx

end X

dy

end Y

nsegments

= 40

curveTo(bx:Float, by:Float, cx:Float, cy:Float):Void

Draws a quadratic Bezier curve using the current line style from the current drawing position to (cx, cy) and using the control point that (bx, by) specifies. IvanK Lib port ( http://lib.ivank.net )

@:value({ nsegments : 0 })drawCircle(cx:Float, cy:Float, radius:Float, nsegments:Int = 0):Void

Draws a circle centered at given position.

Parameters:

cx

X center position of the circle.

cy

Y center position of the circle.

radius

Radius of the circle.

nsegments

Amount of segments used to draw the circle. When 0, amount of segments calculated automatically.

@:value({ nsegments : 0, rotationAngle : 0 })drawEllipse(cx:Float, cy:Float, radiusX:Float, radiusY:Float, rotationAngle:Float = 0, nsegments:Int = 0):Void

Draws an ellipse centered at given position.

Parameters:

cx

X center position of the ellipse.

cy

Y center position of the ellipse.

radiusX

Horizontal radius of an ellipse.

radiusY

Vertical radius of an ellipse.

rotationAngle

Ellipse rotation in radians.

nsegments

Amount of segments used to draw an ellipse. When 0, amount of segments calculated automatically.

@:value({ nsegments : 0 })drawPie(cx:Float, cy:Float, radius:Float, angleStart:Float, angleLength:Float, nsegments:Int = 0):Void

Draws a pie centered at given position.

Parameters:

cx

X center position of the pie.

cy

Y center position of the pie.

radius

Radius of the pie.

angleStart

Starting angle of the pie in radians.

angleLength

The pie size in clockwise direction with 2*PI being full circle.

nsegments

Amount of segments used to draw the pie. When 0, amount of segments calculated automatically.

@:value({ nsegments : 0 })drawPieInner(cx:Float, cy:Float, radius:Float, innerRadius:Float, angleStart:Float, angleLength:Float, nsegments:Int = 0):Void

Draws a double-edged pie centered at given position.

Parameters:

cx

X center position of the pie.

cy

Y center position of the pie.

radius

The outer radius of the pie.

innerRadius

The inner radius of the pie.

angleStart

Starting angle of the pie in radians.

angleLength

The pie size in clockwise direction with 2*PI being full circle.

nsegments

Amount of segments used to draw the pie. When 0, amount of segments calculated automatically.

drawRect(x:Float, y:Float, w:Float, h:Float):Void

Draws a rectangle with given parameters.

Parameters:

x

The rectangle top-left corner X position.

y

The rectangle top-left corner Y position.

w

The rectangle width.

h

The rectangle height.

@:value({ nsegments : 0 })drawRectanglePie(cx:Float, cy:Float, width:Float, height:Float, angleStart:Float, angleLength:Float, nsegments:Int = 0):Void

Draws a rectangular pie centered at given position.

Parameters:

cx

X center position of the pie.

cy

Y center position of the pie.

width

Width of the pie.

height

Height of the pie.

angleStart

Starting angle of the pie in radians.

angleLength

The pie size in clockwise direction with 2*PI being solid rectangle.

nsegments

Amount of segments used to draw the pie. When 0, amount of segments calculated automatically.

@:value({ nsegments : 0 })drawRoundedRect(x:Float, y:Float, w:Float, h:Float, radius:Float, nsegments:Int = 0):Void

Draws a rounded rectangle with given parameters.

Parameters:

x

The rectangle top-left corner X position.

y

The rectangle top-left corner Y position.

w

The rectangle width.

h

The rectangle height.

radius

Radius of the rectangle corners.

nsegments

Amount of segments used for corners. When 0 segment count calculated automatically.

drawTile(x:Float, y:Float, tile:Tile):Void

Draws a Tile at given position. See Graphics.beginTileFill for limitations.

This methods ends current fill operation.

Parameters:

x

The X position of the tile.

y

The Y position of the tile.

tile

The tile to draw.

endFill():Void

Ends the current fill operation.

@:value({ alpha : 1., color : 0, size : 0 })lineStyle(size:Float = 0, color:Int = 0, alpha:Float = 1.):Void

Sets an outline style. Changing the line style ends the currently drawn line.

Parameters:

size

Width of the outline. Setting size to 0 will remove the outline.

color

An outline RGB color.

alpha

An outline transparency.

inlinelineTo(x:Float, y:Float):Void

Draws a straight line from the current drawing position to the given position.

inlinemoveTo(x:Float, y:Float):Void

Ends the current line and starts new one at given position.

@:value({ alpha : 1. })inlinesetColor(color:Int, alpha:Float = 1.):Void

Changes current fill color. Does not interrupt current fill operation and can be utilized to customize color per vertex. During tile fill operation, color serves as a tile color multiplier.

Parameters:

color

The new fill color.

alpha

The new fill transparency.

Defined by Drawable

addShader<T>(s:T):T

Add a shader to the drawable shaders.

Keep in mind, that as stated before, drawable children do not inherit Drawable properties, which includes shaders.

adjustColor(?col:Null<ColorAdjust>):Void

Set the Drawable.colorMatrix value by specifying which effects to apply. Calling adjustColor() without arguments will reset the colorMatrix to null.

getShader<T>(stype:Class<T>):T

Returns the first shader of the given shader class among the drawable shaders.

Parameters:

stype

The class of the shader to look up.

inlinegetShaders():ShaderIterator

Returns an iterator of all drawable shaders

removeShader(s:Shader):Bool

Remove a shader from the drawable shaders, returns true if found or false if it was not part of our shaders.

Defined by Object

private@:dox(show)addBounds(relativeTo:Object, out:Bounds, dx:Float, dy:Float, width:Float, height:Float):Void

Adds specified area in local coordinate space to the bounds. Expected to be used within Object.getBoundsRec.

Parameters:

relativeTo

An object relative to which the Object bounds coordinates should be. If not set, coordinates are in absolute coordinate space.

out

An output Bounds instance.

dx

The top-left X offset of the added bounds rectangle.

dy

The top-left Y offset of the added bounds rectangle.

width

The width of the added bounds rectangle.

height

The height of the added bounds rectangle.

addChild(s:Object):Void

Add a child object at the end of the children list.

addChildAt(s:Object, pos:Int):Void

Insert a child object at the specified position of the children list.

private@:dox(show)calcAbsPos():Void

Internal usage Calculates the absolute object position transform. See `Object.syncPos` for a safe position sync method. This method does not ensure that object parents also have up-to-date transform nor does it clear the `Object.posChanged` flag.

private@:value({ scaleY : 1., scaleX : 1. })@:dox(show)clipBounds(ctx:RenderContext, bounds:Bounds, scaleX:Float = 1., scaleY:Float = 1.):Void

Internal usage Clip the local bounds with our global viewport. Used during filter rendering in order to clip out areas that are off-screen and should not be rendered.

h2d.Scene note: clipBounds will always output bounds equivalent to entire window. This is done in order for scene to never clip out cameras as they may render virtually any area of the Scene.

private@:dox(show)constraintSize(maxWidth:Float, maxHeight:Float):Void

Advanced usage This can be called by a parent container to constraint the size of its children. Negative value mean that constraint is to be disabled.

For example, Text constraints it's maximum width, causing word-wrap to occur within constrained area.

See also:

contains(o:Object):Bool

Tells if the object is contained into this object children, recursively.

private@:dox(show)contentChanged(s:Object):Void

Advanced usage Called by the children of a container object if they have `parentContainer` defined in them. Primary use-case is when the child size got changed, requiring content to reevaluate positioning such as `Flow` layouts, but also can be used for other purposes.

private@:dox(show)draw(ctx:RenderContext):Void

Override this method in order to add custom graphics rendering to your Object. draw is invoked before rendering of the object children.

drawTo(t:Texture):Void

Draw the object and all its children into the given Texture.

drawToTextures(texs:Array<Texture>, outputs:Array<Output>):Void

Draw the object and all its children into the given Textures.

private@:dox(show)emitTile(ctx:RenderContext, tile:Tile):Void

Draws single Tile instance with this Object transform.

find<T>(f:Object ‑> Null<T>):Null<T>

Find a single object in the tree by calling f on each and returning the first not-null value returned, or null if not found.

findAll<T>(f:Object ‑> Null<T>, ?arr:Array<T>):Array<T>

Find several objects in the tree by calling f on each and returning all the not-null values returned.

Parameters:

arr

An optional array instance to fill results with. Allocates a new array if not set.

inlinegetAbsPos():Matrix

Returns the updated absolute position matrix. See Object.getMatrix for current matrix values.

getBounds(?relativeTo:Object, ?out:Bounds):Bounds

Return the bounds of the object for its whole content, recursively.

Parameters:

relativeTo

An optional object relative to coordinates of which bounds are returned. Returns bounds in the absolute coordinates if not set.

out

An optional bounds instance to fill. Allocates new Bounds instance and returns it if not set.

private@:dox(show)getBoundsRec(relativeTo:Object, out:Bounds, forSize:Bool):Void

Override this method in order to expand the reported bounds of an object. Object.addBounds can be used to add bounds with respect to relativeTo. Do not remove the super call.

Parameters:

relativeTo

An object relative to which the Object bounds coordinates should be.

out

An output Bounds instance.

forSize

Whether it's being called for Object.getSize or Object.getBounds.

getChildAt(n:Int):Object

Return the nth element among the immediate children list of this object, or null if there is no Object at this position.

getChildIndex(o:Object):Int

Return the index of the object o within the immediate children list of this object, or -1 if it is not part of the children list.

private@:dox(show)getMatrix(m:Matrix):Void

Populates m with current absolute object transform values. See Object.getAbsPos for up-to-date values.

getObjectByName(name:String):Object

Search for an object recursively by name, return null if not found.

getObjectsCount():Int

Return the total number of children in the whole tree, recursively.

getScene():Scene

Returns an h2d.Scene down the hierarchy tree or null if object is not added to Scene.

finalgetSize(?out:Bounds):Bounds

Similar to getBounds(parent), but instead of the full content, it will return the size based on the alignment of the object. For instance for a text, Object.getBounds will return the full glyphs size whereas getSize will ignore the pixels under the baseline.

Parameters:

out

An optional bounds instance to fill. Allocates new Bounds instance and returns it if not set.

globalToLocal(pt:Point):Point

Convert an absolute screen position into a local position relative to the object origin, applying all the inherited transforms.

Parameters:

pt

A position to convert and return. Modifies the Point instance as is.

inlineiterator():ArrayIterator_h2d_Object

Return an iterator over this object immediate children

localToGlobal(?pt:Point):Point

Convert a local position (or [0,0] if pt is null) relative to the object origin into an absolute screen position, applying all the inherited transforms.

Parameters:

pt

An optional position to convert and return. Allocates new Point at 0,0 position if not set. Modifies the Point instance as is.

move(dx:Float, dy:Float):Void

Move the object by the specified amount along its current direction (Object.rotation angle).

private@:dox(show)onAdd():Void

Sent when object is being added to an allocated scene.

Do not remove the super call when overriding.

private@:dox(show)inlineonContentChanged():Void

Should be called when Object content was changed in order to notify parent container. See Object.contentChanged.

private@:dox(show)onHierarchyMoved(parentChanged:Bool):Void

Sent when object was already allocated and moved within scene object tree hierarchy.

Do not remove the super call when overriding.

Parameters:

parentChanged

Whether Object was moved withing same parent (through Layers.ysort for example) or relocated to a new one.

private@:dox(show)onRemove():Void

Sent when object is removed from the allocated scene.

Do not remove the super call when overriding.

inlineremove():Void

Same as parent.removeChild(this), but does nothing if parent is null.

removeChild(s:Object):Void

Remove the given object from the immediate children list of the object if it's part of it.

removeChildren():Void

Remove all children from the immediate children list.

inlinerotate(v:Float):Void

Rotate the object by the given angle (in radians)

inlinescale(v:Float):Void

Scale uniformly the object by the given factor.

private@:dox(show)setParentContainer(c:Object):Void

Sets the parent container for this Object and it's children. See Object.contentChanged for more details.

inlinesetPosition(x:Float, y:Float):Void

Set the position of the object relative to its parent.

inlinesetScale(v:Float):Void

Set the uniform scale for the object.

private@:dox(show)sync(ctx:RenderContext):Void

Performs a sync of data for rendering (such as absolute position recalculation). While this method can be used as a substitute to an update loop, it's primary purpose it to prepare the Object to be rendered.

Do not remove the super call when overriding.

private@:dox(show)syncPos():Void

Ensures that object has an up-to-date position transform.