Drawer
Direct Subclass:
Draw class
Example:
let drawer = new Drawer();
drawer.drawRect(10, 10, 100, 100);
let metrics = drawer.drawText('Hello world', 50, 50);
metrics.width // text width
Constructor Summary
| Public Constructor | ||
| public |
|
|
Member Summary
| Public Members | ||
| public |
|
|
Method Summary
| Public Methods | ||
| public |
Reset canvas zone |
|
| public |
Add models to debug |
|
| public |
drawCircle(x: number, y: number, radius: number, size: number, color: string, start: number, end: number) Draw a circle |
|
| public |
drawFillCircle(x: number, y: number, radius: number, color: string, lineSize: number, lineColor: string, start: number, end: number) Draw a fill circle |
|
| public |
drawFillRect(x: number, y: number, width: number, height: number, color: string, lineSize: number, lineColor: string) Draw a fill rectangle |
|
| public |
drawImage(source: *, x: number, y: number, width: number, height: number, destinationX: number, destinationY: number, destinationWidth: number, destinationHeight: number) Draw images |
|
| public |
Draw a line |
|
| public |
Draw model |
|
| public |
Draw a rectangle |
|
| public |
drawText(text: string, x: number, y: number, size: string, font: string, color: string, style: string, align: string, baseline: string): Object Draw a text |
|
| public |
Restore last saved context |
|
| public |
rotateModel(model: Model, deg: float, pivotX: number, pivotY: number): Drawer Rotate model |
|
| public |
Save context |
|
Public Constructors
public constructor(ctx: CanvasRenderingContext2D) source
Params:
| Name | Type | Attribute | Description |
| ctx | CanvasRenderingContext2D |
|
Public Members
public ctx: CanvasRenderingContext2D source
Public Methods
public drawCircle(x: number, y: number, radius: number, size: number, color: string, start: number, end: number) source
Draw a circle
Params:
| Name | Type | Attribute | Description |
| x | number | x coordinate for circle position |
|
| y | number | y coordinate for circle position |
|
| radius | number | circle radius |
|
| size | number |
|
line size |
| color | string |
|
line color |
| start | number |
|
angle start |
| end | number |
|
angle end |
public drawFillCircle(x: number, y: number, radius: number, color: string, lineSize: number, lineColor: string, start: number, end: number) source
Draw a fill circle
Params:
| Name | Type | Attribute | Description |
| x | number | x coordinate for circle position |
|
| y | number | y coordinate for circle position |
|
| radius | number | circle radius |
|
| color | string |
|
circle background color |
| lineSize | number |
|
line size |
| lineColor | string |
|
line color |
| start | number |
|
angle start |
| end | number |
|
angle end |
public drawFillRect(x: number, y: number, width: number, height: number, color: string, lineSize: number, lineColor: string) source
Draw a fill rectangle
Params:
| Name | Type | Attribute | Description |
| x | number | x coordinate for rectangle position |
|
| y | number | y coordinate for rectangle position |
|
| width | number | rectangle width |
|
| height | number | rectangle height |
|
| color | string |
|
rectangle background color |
| lineSize | number |
|
line size |
| lineColor | string |
|
line color |
public drawImage(source: *, x: number, y: number, width: number, height: number, destinationX: number, destinationY: number, destinationWidth: number, destinationHeight: number) source
Draw images
Params:
| Name | Type | Attribute | Description |
| source | * | image or canvas |
|
| x | number | source pos x |
|
| y | number | source pos y |
|
| width | number |
|
source width |
| height | number |
|
source height |
| destinationX | number |
|
destination x |
| destinationY | number |
|
destination y |
| destinationWidth | number |
|
destination width |
| destinationHeight | number |
|
destination height |
public drawLine(x: number, y: number, destX: number, destY: number, size: number, color: string) source
Draw a line
Params:
| Name | Type | Attribute | Description |
| x | number | x coordinate for first point of line |
|
| y | number | y coordinate for first point of line |
|
| destX | number | x coordinate for second point of line |
|
| destY | number | y coordinate for second point of line |
|
| size | number |
|
line size |
| color | string |
|
line color |
public drawModel(model: Model): Drawer source
Draw model
Params:
| Name | Type | Attribute | Description |
| model | Model |
public drawRect(x: number, y: number, width: number, height: number, size: number, color: string) source
Draw a rectangle
public drawText(text: string, x: number, y: number, size: string, font: string, color: string, style: string, align: string, baseline: string): Object source
Draw a text
Params:
| Name | Type | Attribute | Description |
| text | string | The text |
|
| x | number | x coordinate for text position |
|
| y | number | y coordinate for text position |
|
| size | string |
|
text size (default: 10pt) |
| font | string |
|
text font familly (default: Arial) |
| color | string |
|
text color |
| style | string |
|
text style, italic, blod etc ... |
| align | string |
|
text align, left, right, center |
| baseline | string |
|
text baseline, top, hanging, middle, alphabetic, ideographic, bottom |