Last updated

API / geotoolkit / renderer / Surface / Surface

Class: Surface

renderer.Surface.Surface

Define interface for a raster surface. This surface can be rendered to context

Table of contents

Constructors
Methods

Contents

Constructors

new Surface()

new Surface()

Methods

beginPaint

Abstract beginPaint(tr?, offset?, rect?, clearArea?): RenderingContext

Begin paint

Parameters

Name Type Description
Optional trTransformationtransformation
Optional offsetPointThe offset of the surface relative to device.
Optional rectRectThe rectangle area to be cleared
Optional clearAreabooleanclear rendering area

Returns

RenderingContext

a node rendering context


clear

Abstract clear(): void

Clear surface

Returns

void


createPixmap

Abstract createPixmap(width, height): Pixmap

Create pixmap object with the specified dimensions

Parameters

Name Type Description
widthnumberwidth of the image data
heightnumberheight of the image data

Returns

Pixmap


drawImage

Abstract drawImage(image, dx, dy): void

Draw image to surface

Parameters

Name Type Description
imageSurface | IBaseImageimage to draw
dxnumberthe x coordinate of the upper-left corner of the destination rectangle
dynumberthe y coordinate of the upper-left corner of the destination rectangle

Returns

void


endPaint

Abstract endPaint(): void

End paint

Returns

void


flipHorizontal

Abstract flipHorizontal(): Surface

Flip surface content horizontally

Returns

Surface

this


flipVertical

Abstract flipVertical(): Surface

Flip surface content vertically

Returns

Surface

this


getBase64

getBase64(): string

Returns base64 representation

Returns

string


getHeight

Abstract getHeight(): number

Return height of the surface

Returns

number


getPixelsCount

getPixelsCount(): number

Returns canvas surface pixels amount

Returns

number


getPixmap

Abstract getPixmap(x, y, width, height): Pixmap

Get pixmap object representing the underlying pixel data for the area of the surface denoted by the rectangle which starts at (x, y) and has width and height.

Parameters

Name Type Description
xnumberThe x coordinate of the upper left corner of the rectangle from which the Pixmap will be extracted.
ynumberThe y coordinate of the upper left corner of the rectangle from which the Pixmap will be extracted.
widthnumberwidth of the image data
heightnumberheight of the image data

Returns

Pixmap


getWidth

Abstract getWidth(): number

Return width of the surface

Returns

number


isValid

Abstract isValid(contextAttributes?): boolean

Check if surface is valid. If it was created for different pixel scale it is marked as invalid

Parameters

Name Type
Optional contextAttributesCanvasRenderingContext2DSettings

Returns

boolean


putPixmap

Abstract putPixmap(pixmap, srcX, srcY, dstX?, dstY?, dstWidth?, dstHeight?): void

Renders data from the given Pixmap object onto the surface. If a dirty rectangle is provided, only the pixels from that rectangle are rendered.

Parameters

Name Type Description
pixmapPixmappixmap, which contains pixels to be rendered
srcXnumberhorizontal position (x-coordinate) of the upper-left corner of the pixmap data rectangle in the target surface.
srcYnumbervertical position (y-coordinate) of the upper-left corner of the pixmap data rectangle in the target surface
Optional dstXnumberhorizontal position (x-coordinate) where to place the image on the surface. Defaults to the top left of the whole pixmap.
Optional dstYnumbervertical position (y-coordinate) where to place the image on the surface. Defaults to the top left of the whole image data.
Optional dstWidthnumberwidth of the rectangle to be rendered, in the origin image data. Defaults to the width of the image data.
Optional dstHeightnumberwidth of the rectangle to be rendered, in the origin image data. Defaults to the width of the image data.

Returns

void


release

Abstract release(): void

Release surface

Returns

void


render

Abstract render(context, x, y, dstW?, dstH?, xImg?, yImg?, imgW?, imgH?): void

Render a surface at specified position of the target device. This method ignores transformation, which is set on context.

Parameters

Name Type Description
contextRenderingContextcontext to render surface
xnumberthe x coordinate of the upper-left corner of the destination rectangle
ynumberthe y coordinate of the upper-left corner of the destination rectangle
Optional dstWnumberdevice width
Optional dstHnumberdevice height
Optional xImgnumberxPosition of the image to start rendering
Optional yImgnumberyPosition of the image to start rendering
Optional imgWnumberwidth of the image to draw
Optional imgHnumberheight of the image to draw

Returns

void


setDevicePixel

Abstract setDevicePixel(devicePixel): Surface

Sets device pixel

Parameters

Name Type Description
devicePixelbooleanIf set to true, width and height will be used as 'device' pixels.

Returns

Surface

this


setSize

Abstract setSize(width, height): Surface

Sets surface size

Parameters

Name Type Description
widthnumberwidth of canvas
heightnumberheight of canvas

Returns

Surface

this