PCanvas class abstract

Portable Canvas.

Mixed-in types
Implementers

Constructors

PCanvas(int width, int height, PCanvasPainter painter, {PCanvasPixels? initialPixels})
factory
PCanvas.impl()

Properties

area num
The area of this dimension.
no setterinherited
asPCanvas PCanvas?
Returns this instance casted to PCanvas if it's possible.
no setterinherited
asPCanvasElement PCanvasElement?
Returns this instance casted to PCanvasElement if it's possible.
no setterinherited
aspectRation double
The aspect ration of this dimension (width / height).
no setterinherited
boundingBox PRectangle
The bounding box of this element container.
no setterinherited
canvasNative → dynamic
The native canvas of this instance implementation.
no setter
center Point
The center point of this dimension.
no setterinherited
clip PRectangle?
Returns the current drawing clip.
getter/setter pair
cursor PCanvasCursor
The PCanvas cursor.
getter/setter pair
devicePixelRatio num
The pixels ratio of the device of the canvasNative.
no setter
dimension PDimension
The dimension of this canvas.
no setteroverride
elementDimension PDimension
The dimension of the visual element of this canvas.
no setter
elementHeight num
The height of the visual element. See elementDimension.
no setter
elements UnmodifiableListView<PCanvasElement>
All the PCanvasElements of this instance.
no setteroverride
elementsLength int
Returns elements length.
no setteroverride
elementWidth num
The width of the visual element. See elementDimension.
no setter
hasElements bool
Returns true if this instances has elements.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
height num
The pixels height of this canvas.
no setteroverride
info Map<String, Object?>
PCanvas information.
no setter
isPaintRequested bool
Returns true if requestRepaint was called and not processed yet.
no setter
isZeroDimension bool
Returns true if the area of this dimension is zero.
no setterinherited
onPaint Stream<PCanvas>
no setter
painter PCanvasPainter
The painter of this canvas.
no setter
pCanvas PCanvas?
Returns the root PCanvas.
no setterinherited
pixelRatio num
The current pixel ration of this canvas. See devicePixelRatio.
getter/setter pair
pixels FutureOr<PCanvasPixels>
Returns the pixels of this canvas. See PCanvasPixels.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state PCanvasState
The current drawing state.
no setter
stateExtra PCanvasStateExtra?
The platform specific extra states.
no setter
subClip PRectangle?
Sets clip merging the coordinates of clip2 with the previous clip.
no getter
subTransform PcanvasTransform
Sets transform to a sub-transformation, merging the current transform with transform2.
no getter
transform PcanvasTransform
The current transformation of the canvas operation.
getter/setter pair
width num
The pixels width of this canvas.
no setteroverride

Methods

addAllElements(Iterable<PCanvasElement> elements) → void
Adds all the entries in elements to this instances.
inherited
addElement(PCanvasElement element) → void
Adds an element to this instances.
override
angleToRadians(num angle) double
Converts angle in degrees to arcs.
callPainter() FutureOr<bool>
Calls the painter, forcing a render operation.
callWithGuardedState<R>(R call()) → R
Executes call preserving the internal drawing state.
callWithGuardedStateAsync<R>(FutureOr<R> call()) FutureOr<R>
Executes call preserving the internal drawing state, accepting Future as return value.
canvasPoint(Point p) Point
canvasX(num x) num
canvasXD(num x) double
canvasY(num y) num
canvasYD(num y) double
centered(void paint(PCanvas pCanvas, Point point, PDimension size), {num? x, num? y, Point? point, PDimension? area, num? width, num? height, PDimension? dimension, PDimension sizer()?, double? scale}) → void
A helper funtion to center draw operations.
checkDimension() → void
Checks if the canvas dimension has changed.
checkImageLoaded(PCanvasImage image) → void
Checks if image is already loaded.
clear({PStyle? style}) → void
Clears the canvas.
clearElements() → void
Clears the elements of this instance.
override
clearRect(num x, num y, num width, num height, {PStyle? style}) → void
Clears a part of the canvas.
createCanvasImage(Object source, {int? width, int? height}) PCanvasImage
Creates a PCanvasImage instance compatible to this canvas and its painter.
dispatchOnClick(PCanvasClickEvent event) PCanvasClickEvent
Processes event and calls onClick on clicked elements.
inherited
dispatchOnClickDown(PCanvasClickEvent event) PCanvasClickEvent
Processes event and calls onClickDown on clicked elements.
inherited
dispatchOnClickMove(PCanvasClickEvent event) PCanvasClickEvent
Processes event and calls onClickMove on clicked elements.
inherited
dispatchOnClickUp(PCanvasClickEvent event) PCanvasClickEvent
Processes event and calls onClickUp on clicked elements.
inherited
dispatchOnKey(PCanvasKeyEvent event) PCanvasKeyEvent
Processes event and calls onKey on elements.
inherited
dispatchOnKeyDown(PCanvasKeyEvent event) PCanvasKeyEvent
Processes event and calls onKeyDown on elements.
inherited
dispatchOnKeyUp(PCanvasKeyEvent event) PCanvasKeyEvent
Processes event and calls onKeyUp on elements.
inherited
drawImage(PCanvasImage image, num x, num y) → void
Draw an image at (x,y) using the original dimension of the image.
drawImageArea(PCanvasImage image, int srcX, int srcY, int srcWidth, int srcHeight, num dstX, num dstY, num dstWidth, num dstHeight) → void
Draw an image part (srcX,srcY , srcWidth x srcHeight) to a destiny area (dstX,dstY , dstWidth x dstHeight).
drawImageFitted(PCanvasImage image, num dstX, num dstY, num dstWidth, num dstHeight) → void
Draw an image fitting a destiny area (dstX,dstY , dstWidth x dstHeight).
drawImageScaled(PCanvasImage image, num x, num y, num width, num height) → void
Draw an image at (x,y) scaling it to the dimension width x height.
drawText(String text, num x, num y, PFont font, PStyle style) → void
Draw a text at position (x,y).
fillBottomUpGradient(num x, num y, num width, num height, PColor colorFrom, PColor colorTo) → void
Fill a rectangle (x,y , width x height) with a bottom up linear gradient. See fillTopDownGradient.
fillCircle(num x, num y, num radius, PStyle style, {num startAngle = 0, num endAngle = 360}) → void
Fill a circle at (x,y) with radius.
fillLeftRightGradient(num x, num y, num width, num height, PColor colorFrom, PColor colorTo) → void
Fill a rectangle (x,y , width x height) with a left right linear gradient. See fillRightLeftGradient.
fillPath(List path, PStyle style, {bool closePath = false}) → void
Fill a path of points.
fillRect(num x, num y, num width, num height, PStyle style) → void
Fill a rectangle (x,y , width x height).
fillRightLeftGradient(num x, num y, num width, num height, PColor colorFrom, PColor colorTo) → void
Fill a rectangle (x,y , width x height) with a right left linear gradient. See fillLeftRightGradient.
fillTopDownGradient(num x, num y, num width, num height, PColor colorFrom, PColor colorTo) → void
Fill a rectangle (x,y , width x height) with a top down linear gradient. See fillBottomUpGradient.
getCursor() PCanvasCursor
Returns the PCanvas cursor.
getElement(int index) PCanvasElement
Returns the element at elements index.
override
log(Object? o) → void
Logs a debugging message.
measureText(String text, PFont font) PTextMetric
Measure the text dimension.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onPosPaint() → void
onPrePaint() → void
preventEventDefault(PCanvasEvent event) bool
Prevents PCanvasEvent.nativeEvent default behavior.
refresh() Future<bool>
Refreshes the canvas asynchronously.
removeAllElements(Iterable<PCanvasElement> elements) → void
Removes all entries in elements from this instances.
inherited
removeElement(PCanvasElement element) bool
Removes element from this instance.
override
requestRepaint() Future<bool>
Requests a refresh (repaint).
requestRepaintDelayed(Duration delay) Future<bool>
Same as requestRepaint but ensures a delay before refresh.
restoreState({PCanvasState? expectedState}) PCanvasState?
Restores the drawing state.
saveState() PCanvasState
Saves the drawing state (PCanvasState).
selectElementAtPoint<T extends PCanvasElement>(Point point, {bool recursive = false}) List<T>
inherited
selectElementByID<T extends PCanvasElement>(String? id, {bool recursive = false}) List<T>
Returns a list of PCanvasElement of type T with a matching id.
inherited
selectElementByType<T extends PCanvasElement>({bool recursive = false}) List<T>
Returns a list of PCanvasElement of type T.
inherited
selectElementWhere<T extends PCanvasElement>(bool selector(T elem), {bool recursive = false}) List<T>
Returns a list of PCanvasElement of type T filtered by selector.
inherited
setClip(num x, num y, num width, num height) → void
Sets the drawing clip.
setCursor(PCanvasCursor cursor) → void
Sets the PCanvas cursor.
setPixels(PCanvasPixels pixels, {int x = 0, int y = 0, int? width, int? height}) → void
Sets the canvas pixels.
setSubClip(num x, num y, num width, num height) → void
Sets clip merging the passed coordinates with the previous clip.
strokeCircle(num x, num y, num radius, PStyle style, {num startAngle = 0, num endAngle = 360}) → void
Stroke a circle at (x,y) with radius.
strokePath(List path, PStyle style, {bool closePath = false}) → void
Stroke a path of points.
strokeRect(num x, num y, num width, num height, PStyle style) → void
Stroke a rectangle (x,y , width x height).
toDataUrl() FutureOr<String>
Returns a data URI containing the canvas data in PNG format. See toPNG.
toInnerClickEvent(PCanvasClickEvent event, {PCanvasElement? targetElement, PCanvas? pCanvas}) PCanvasClickEvent
Returns an event translated to the internal coordinates of this element.
inherited
toPNG() FutureOr<Uint8List>
Returns the pixels of this as a PNG data.
toString() String
A string representation of this object.
inherited
waitLoading() FutureOr<bool>
Waits the loading of the canvas and also the painter.loadResources.

Operators

operator ==(Object other) bool
The equality operator.
inherited