A simple interface to draw arbitrary 2D geometry.

Usage notes:
* While Graphics allows for multiple unique textures, each texture swap causes a new drawcall,
and due to that it's recommended to minimize the amount of used textures per Graphics instance,
ideally limiting to only one texture.
* Due to how Graphics operate, removing them from the active `h2d.Scene`

will cause a loss of all data.

### Constructor

`new(?parent:Object)`

Create a new Graphics instance.

Parameters:

`parent` | An optional parent |
---|

### Variables

`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.

### Methods

`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. |

`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 tiling texture, `Drawable.tileWrap`

have 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 |

`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 )

`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 |

`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 |

`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 |

`nsegments` | Amount of segments used to draw the pie. When |

`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 |

`nsegments` | Amount of segments used to draw the pie. When |

`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. |

`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 |

`nsegments` | Amount of segments used to draw the pie. When |

`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 |

`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. |

`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.

`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. |