Home Reference Source
import {Container} from 'penvas/src/container.js'
public class | source

Container

Extends:

Drawer → Container

Create a new container with a canvas element

Example:

let container = new Container({ width: 200, height: 200, background: 'gray' });

Constructor Summary

Public Constructor
public

constructor(options: Object)

Create a new canvas

Member Summary

Public Members
public

background: hex

public

canvas: HTMLCanvasElement

public
public
public
public
public
public

Inherited Summary

From class Drawer
public
public

Reset canvas zone

public

debug(models: Array<Model> | Model)

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

drawLine(x: number, y: number, destX: number, destY: number, size: number, color: string)

Draw a line

public

Draw model

public

drawRect(x: number, y: number, width: number, height: number, size: number, color: string)

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(options: Object) source

Create a new canvas

Override:

Drawer#constructor

Params:

NameTypeAttributeDescription
options Object
  • optional
options.x number
  • optional
  • default: 0
options.y number
  • optional
  • default: 0
options.width number
  • optional

default window width

options.height number
  • optional

default window height

options.background string
  • optional
  • default: #ffffff

Public Members

public background: hex source

public canvas: HTMLCanvasElement source

public height: number source

public width: number source

public x: number source

public y: number source