Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/excaliburjs/Excalibur. 🎮 Your friendly TypeScript 2D game engine for the web 🗡️ excaliburjs.com
excalibur excaliburjs game-development game-engine game-framework gamedev games html5-canvas typescript
Something went wrong. Try again.
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738import type { RasterOptions } from './raster';import { Raster } from './raster';
export interface RectangleOptions { width: number; height: number;}
/** * A Rectangle {@apilink Graphic} for drawing rectangles to the {@apilink ExcaliburGraphicsContext} */export class Rectangle extends Raster { constructor(options: RasterOptions & RectangleOptions) { super(options); this.width = options.width; this.height = options.height; this.rasterize(); }
public clone(): Rectangle { return new Rectangle({ width: this.width, height: this.height, ...this.cloneGraphicOptions(), ...this.cloneRasterOptions() }); }
execute(ctx: CanvasRenderingContext2D): void { if (this.color) { ctx.fillRect(0, 0, this.width, this.height); } if (this.strokeColor) { ctx.strokeRect(0, 0, this.width, this.height); } }}