import { Vec2D, Segment, AABB } from '../Math'; import { Color } from './Color'; import { ColorGradient } from './ColorGradient'; import { Sprite } from './Sprite'; declare class Surface { /** * HTML canvas target */ canvas: HTMLCanvasElement; /** * Rendering context */ surface: CanvasRenderingContext2D; /** * A base surface for targeted rendering. * * @param w Width of the surface * @param h Height of the surface * @param canvas Target canvas element * @return New Surface object */ constructor(w: number, h: number); /** * Set the width and height of the surface's underlying canvas * * @param width Width of the surface * @param height Height of the surface */ setSize(width: number, height: number): void; /** * Get the bounds of the surface. * * @param center Should bounding box be centered? * @return Bouding box of the surface */ rect(center?: boolean): AABB; /** * Generate a subsurface. * * @param aabb Size and location of subsurface * @param center Should coordinates be centered? * @return New Surface object */ subsurface(aabb: AABB, center?: boolean): Surface; /** * Fill the entire surface with a color or gradient. * * @param color Target color or gradient */ fill(color: Color | ColorGradient): void; /** * Draw another surface on top of the current one. * * @param src Source surface to be drawn * @param aabb Target bounding box for stretching * @param blend Drawing blend mode * @param opacity Transparency value * @param angle Angular rotation in radians * @param flip Flip factor of the image * @param center Should drawing be centered? */ drawSurface(src: Surface, aabb: AABB, blend?: GlobalCompositeOperation, opacity?: number, angle?: number, flip?: Vec2D, center?: boolean): void; /** * Draw a sprite on the surface. * * @param sprite Source sprite to be drawn * @param aabb Target bounding box for stretching * @param blend Drawing blend mode * @param opacity Transparency value * @param angle Angular rotation in radians * @param flip Flip factor of the image * @param center Should drawing be centered? */ drawSprite(sprite: Sprite, aabb: AABB, blend?: GlobalCompositeOperation, opacity?: number, angle?: number, flip?: Vec2D, center?: boolean): void; /** * Draw a line segment on the surface. * * @param segment Start and end points of the line * @param color Target color or gradient * @param linewidth Width of the line * @param blend Drawing blend mode */ drawLine(segment: Segment, color: Color | ColorGradient, linewidth?: number, blend?: GlobalCompositeOperation): void; /** * Draw a rectangular shape on the surface. * * @param aabb Target bounding box * @param color Target color or gradient * @param fill Should the shape be filled? * @param linewidth Width of the outline * @param blend Drawing blend mode * @param center Should drawing be centered? */ drawRect(aabb: AABB, color: Color | ColorGradient, fill?: boolean, linewidth?: number, blend?: GlobalCompositeOperation, center?: boolean): void; /** * Draw a circular shape on the surface. * * @param center Centered position of target * @param radius Radius of the circle * @param color Target color or gradient * @param fill Should the shape be filled? * @param linewidth Width of the outline * @param blend Drawing blend mode */ drawCircle(center: Vec2D, radius: number, color: Color | ColorGradient, fill?: boolean, linewidth?: number, blend?: GlobalCompositeOperation): void; /** * Draw a polygon from a sorted list of points * * @param points Sorted array of Vec2D points * @param color Target color or gradient * @param fill Should the shape be filled? * @param linewidth Width of the outline * @param blend Drawing blend mode */ drawPolygon(points: Vec2D[], color: Color | ColorGradient, fill?: boolean, linewidth?: number, blend?: GlobalCompositeOperation): void; /** * Render text on the surface. * * @param string Text to be rendered * @param font Valid font family * @param size Size of the font in pixels * @param color Target color or gradient * @param pos Centered position of target * @param blend Drawing blend mode */ drawText(string: string, font: string, size: number, color: Color | ColorGradient, pos: Vec2D, fill?: boolean, linewidth?: number, bold?: boolean, italic?: boolean, align?: CanvasTextAlign, blend?: GlobalCompositeOperation): void; /** * Clear the entire surface. */ clear(): void; } export { Surface };