animator.skia.Canvas¶
- class animator.skia.Canvas¶
Bases:
pybind11_builtins.pybind11_object- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: animator.skia.Canvas, array: numpy.ndarray, ct: animator.skia.ColorType = <ColorType.kRGBA_8888_ColorType: 4>, at: animator.skia.AlphaType = <AlphaType.kUnpremul_AlphaType: 3>, cs: animator.skia.ColorSpace = None, surfaceProps: animator.skia.SurfaceProps = None) -> None
Creates raster
Canvasbacked by numpy array.- param array
numpy array of shape=(height, width, channels) and appropriate dtype. Must have the valid number of channels for the specified color type.
- param ct
color type
- param at
alpha type
- param cs
color space
- param surfaceProps
optional surface properties
__init__(self: animator.skia.Canvas) -> None
__init__(self: animator.skia.Canvas, width: int, height: int, props: animator.skia.SurfaceProps = None) -> None
__init__(self: animator.skia.Canvas, bitmap: animator.skia.Bitmap) -> None
__init__(self: animator.skia.Canvas, bitmap: animator.skia.Bitmap, props: animator.skia.SurfaceProps) -> None
Methods
MakeRasterDirect(info, pixels[, rowBytes, props])Allocates raster
Canvasthat will draw directly into pixel buffer.MakeRasterDirectN32(width, height, pixels, ...)Allocates raster
Canvasthat will draw directly into pixel buffer.__init__(*args, **kwargs)Overloaded function.
accessTopLayerPixels(self)Returns a tuple of
(memoryview of pixels, image info, rowBytes, origin)if the pixels can be read directly.clear(*args, **kwargs)Overloaded function.
clipIRect(self, irect, op)clipPath(self, path, op, doAntiAlias)clipRRect(self, rrect, op, doAntiAlias)clipRect(self, rect, op, doAntiAlias)clipRegion(self, deviceRgn, op)clipShader(self, sh, op)concat(self, matrix)discard(self)drawArc(self, oval, startAngle, sweepAngle, ...)drawAtlas(self, atlas, xform, tex, colors, ...)Draws a set of sprites from atlas, defined by xform, tex, and colors using mode and sampling.
drawCircle(*args, **kwargs)Overloaded function.
drawColor(*args, **kwargs)Overloaded function.
drawDRRect(self, outer, inner, paint)drawGlyphs(*args, **kwargs)Overloaded function.
drawIRect(self, rect, paint)drawImage(*args, **kwargs)Overloaded function.
drawImageLattice(self, image, lattice, dst, ...)drawImageNine(self, image, center, dst, filter)drawImageRect(*args, **kwargs)Overloaded function.
drawLine(*args, **kwargs)Overloaded function.
drawOval(self, oval, paint)drawPaint(self, paint)drawParagraph(self, paragraph, x, y)Draws the paragraph at the given x and y position.
drawPatch(self, cubics, colors, texCoords, ...)drawPath(self, path, paint)drawPicture(self, picture[, matrix, paint])drawPoint(*args, **kwargs)Overloaded function.
drawPoints(self, mode, pts, paint)Draw a list of points, pts, with the specified mode and paint.
drawRRect(self, rrect, paint)drawRect(self, rect, paint)drawRegion(self, region, paint)drawRoundRect(self, rect, rx, ry, paint)drawShadow(self, path, zPlaneParams, ...)Draw an offset spot shadow and outlining ambient shadow for the given path using a disc light.
drawSimpleText(self, text, encoding, x, y, ...)Draws text at (x, y) using font and paint.
drawString(self, text, x, y, font, paint)drawText(self, text, x, y, font, paint, ...)Draws the text at (x, y) using the given font and paint useing SkTextUtils.
drawTextBlob(self, blob, x, y, paint)drawVertices(self, vertices, mode, paint)getBaseLayerSize(self)getBaseProps(self)getDeviceClipBounds(self)getLocalClipBounds(self)getLocalToDeviceAs3x3(self)getProps(self)Returns
SurfaceProps, ifCanvasis associated with raster surface.getSaveCount(self)getSurface(self)getTopProps(self)getTotalMatrix(self)imageInfo(self)isClipEmpty(self)isClipRect(self)makeSurface(self, info[, props])peekPixels(self)Returns a
Pixmapdescribing the pixel data.quickReject(*args, **kwargs)Overloaded function.
readPixels(*args, **kwargs)Overloaded function.
resetMatrix(self)restore(self)restoreToCount(self, saveCount)rotate(*args, **kwargs)Overloaded function.
save(self)saveLayer(*args, **kwargs)Overloaded function.
saveLayerAlpha(self, bounds, alpha)saveLayerAlphaf(self, bounds, alpha)scale(self, sx, sy)setMatrix(self, matrix)skew(self, sx, sy)toarray(self, srcX, srcY, ct, at, cs)Returns a
ndarrayof the current canvas' pixels.translate(self, dx, dy)writePixels(*args, **kwargs)Overloaded function.
- static MakeRasterDirect(info: animator.skia.ImageInfo, pixels: buffer, rowBytes: int = 0, props: animator.skia.SurfaceProps = None) animator.skia.Canvas¶
Allocates raster
Canvasthat will draw directly into pixel buffer.- Parameters
info –
ImageInfodescribing pixel bufferpixels – pixel buffer
rowBytes – number of bytes per row
props – optional
SurfaceProps
- static MakeRasterDirectN32(width: int, height: int, pixels: buffer, rowBytes: int) animator.skia.Canvas¶
Allocates raster
Canvasthat will draw directly into pixel buffer.
- class PointMode¶
Bases:
pybind11_builtins.pybind11_objectMembers:
kPoints_PointMode
kLines_PointMode
kPolygon_PointMode
- property name¶
- class SaveLayerFlags¶
Bases:
pybind11_builtins.pybind11_objectMembers:
kPreserveLCDText_SaveLayerFlag
kInitWithPrevious_SaveLayerFlag
kF16ColorType
- property name¶
- class SrcRectConstraint¶
Bases:
pybind11_builtins.pybind11_objectMembers:
kStrict_SrcRectConstraint
kFast_SrcRectConstraint
- property name¶
- accessTopLayerPixels(self: animator.skia.Canvas) Optional[tuple]¶
Returns a tuple of
(memoryview of pixels, image info, rowBytes, origin)if the pixels can be read directly. Otherwise, returnsNone.
- clear(*args, **kwargs)¶
Overloaded function.
clear(self: animator.skia.Canvas, color: int) -> None
clear(self: animator.skia.Canvas, color: animator.skia.Color4f) -> None
- clipIRect(self: animator.skia.Canvas, irect: animator.skia.IRect, op: animator.skia.ClipOp = <ClipOp.kIntersect: 1>) None¶
- clipPath(self: animator.skia.Canvas, path: animator.skia.Path, op: animator.skia.ClipOp = <ClipOp.kIntersect: 1>, doAntiAlias: bool = False) None¶
- clipRRect(self: animator.skia.Canvas, rrect: animator.skia.RRect, op: animator.skia.ClipOp = <ClipOp.kIntersect: 1>, doAntiAlias: bool = False) None¶
- clipRect(self: animator.skia.Canvas, rect: animator.skia.Rect, op: animator.skia.ClipOp = <ClipOp.kIntersect: 1>, doAntiAlias: bool = False) None¶
- clipRegion(self: animator.skia.Canvas, deviceRgn: animator.skia.Region, op: animator.skia.ClipOp = <ClipOp.kIntersect: 1>) None¶
- clipShader(self: animator.skia.Canvas, sh: animator.skia.Shader, op: animator.skia.ClipOp = <ClipOp.kIntersect: 1>) None¶
- concat(self: animator.skia.Canvas, matrix: animator.skia.Matrix) None¶
- discard(self: animator.skia.Canvas) None¶
- drawArc(self: animator.skia.Canvas, oval: animator.skia.Rect, startAngle: float, sweepAngle: float, useCenter: bool, paint: animator.skia.Paint) None¶
- drawAtlas(self: animator.skia.Canvas, atlas: animator.skia.Image, xform: Optional[List[animator.skia.RSXform]], tex: List[animator.skia.Rect], colors: Optional[List[int]], mode: animator.skia.BlendMode, sampling: animator.skia.SamplingOptions, cullRect: animator.skia.Rect = None, paint: animator.skia.Paint = None) None¶
Draws a set of sprites from atlas, defined by xform, tex, and colors using mode and sampling.
- drawCircle(*args, **kwargs)¶
Overloaded function.
drawCircle(self: animator.skia.Canvas, cx: float, cy: float, radius: float, paint: animator.skia.Paint) -> None
drawCircle(self: animator.skia.Canvas, center: animator.skia.Point, radius: float, paint: animator.skia.Paint) -> None
- drawColor(*args, **kwargs)¶
Overloaded function.
drawColor(self: animator.skia.Canvas, color: int, mode: animator.skia.BlendMode = <BlendMode.kSrcOver: 3>) -> None
drawColor(self: animator.skia.Canvas, color: animator.skia.Color4f, mode: animator.skia.BlendMode = <BlendMode.kSrcOver: 3>) -> None
- drawDRRect(self: animator.skia.Canvas, outer: animator.skia.RRect, inner: animator.skia.RRect, paint: animator.skia.Paint) None¶
- drawGlyphs(*args, **kwargs)¶
Overloaded function.
drawGlyphs(self: animator.skia.Canvas, glyphs: List[int], positions: List[animator.skia.Point], clusters: List[int], utf8text: str, origin: animator.skia.Point, font: animator.skia.Font, paint: animator.skia.Paint) -> None
Draws glyphs, at positions relative to origin styled with font and paint with supporting utf8text and clusters information.
drawGlyphs(self: animator.skia.Canvas, glyphs: List[int], positions: List[animator.skia.Point], origin: animator.skia.Point, font: animator.skia.Font, paint: animator.skia.Paint) -> None
Draws glyphs, at positions relative to origin styled with font and paint.
drawGlyphs(self: animator.skia.Canvas, glyphs: List[int], xforms: List[animator.skia.RSXform], origin: animator.skia.Point, font: animator.skia.Font, paint: animator.skia.Paint) -> None
Draws glyphs, with xforms relative to origin styled with font and paint.
- drawIRect(self: animator.skia.Canvas, rect: animator.skia.IRect, paint: animator.skia.Paint) None¶
- drawImage(*args, **kwargs)¶
Overloaded function.
drawImage(self: animator.skia.Canvas, image: animator.skia.Image, left: float, top: float) -> None
drawImage(self: animator.skia.Canvas, image: animator.skia.Image, left: float, top: float, sampling: animator.skia.SamplingOptions = <animator.skia.SamplingOptions object at 0x7f2050122530>, paint: animator.skia.Paint = None) -> None
- drawImageLattice(self: animator.skia.Canvas, image: animator.skia.Image, lattice: SkCanvas::Lattice, dst: animator.skia.Rect, filter: animator.skia.FilterMode = <FilterMode.kNearest: 0>, paint: animator.skia.Paint = None) None¶
- drawImageNine(self: animator.skia.Canvas, image: animator.skia.Image, center: animator.skia.IRect, dst: animator.skia.Rect, filter: animator.skia.FilterMode, paint: animator.skia.Paint = None) None¶
- drawImageRect(*args, **kwargs)¶
Overloaded function.
drawImageRect(self: animator.skia.Canvas, image: animator.skia.Image, src: animator.skia.Rect, dst: animator.skia.Rect, sampling: animator.skia.SamplingOptions = <animator.skia.SamplingOptions object at 0x7f20501141f0>, paint: animator.skia.Paint = None, constraint: animator.skia.Canvas.SrcRectConstraint = <SrcRectConstraint.kFast_SrcRectConstraint: 1>) -> None
drawImageRect(self: animator.skia.Canvas, image: animator.skia.Image, dst: animator.skia.Rect, sampling: animator.skia.SamplingOptions = <animator.skia.SamplingOptions object at 0x7f2052985bb0>, paint: animator.skia.Paint = None) -> None
- drawLine(*args, **kwargs)¶
Overloaded function.
drawLine(self: animator.skia.Canvas, x0: float, y0: float, x1: float, y1: float, paint: animator.skia.Paint) -> None
drawLine(self: animator.skia.Canvas, p0: animator.skia.Point, p1: animator.skia.Point, paint: animator.skia.Paint) -> None
- drawOval(self: animator.skia.Canvas, oval: animator.skia.Rect, paint: animator.skia.Paint) None¶
- drawPaint(self: animator.skia.Canvas, paint: animator.skia.Paint) None¶
- drawParagraph(self: animator.skia.Canvas, paragraph: animator.skia.textlayout.Paragraph, x: float, y: float) None¶
Draws the paragraph at the given x and y position.
- drawPatch(self: animator.skia.Canvas, cubics: List[animator.skia.Point], colors: Optional[List[int]], texCoords: Optional[List[animator.skia.Point]], mode: animator.skia.BlendMode, paint: animator.skia.Paint) None¶
- drawPath(self: animator.skia.Canvas, path: animator.skia.Path, paint: animator.skia.Paint) None¶
- drawPicture(self: animator.skia.Canvas, picture: animator.skia.Picture, matrix: animator.skia.Matrix = None, paint: animator.skia.Paint = None) None¶
- drawPoint(*args, **kwargs)¶
Overloaded function.
drawPoint(self: animator.skia.Canvas, x: float, y: float, paint: animator.skia.Paint) -> None
drawPoint(self: animator.skia.Canvas, p: animator.skia.Point, paint: animator.skia.Paint) -> None
- drawPoints(self: animator.skia.Canvas, mode: animator.skia.Canvas.PointMode, pts: List[animator.skia.Point], paint: animator.skia.Paint) None¶
Draw a list of points, pts, with the specified mode and paint.
- drawRRect(self: animator.skia.Canvas, rrect: animator.skia.RRect, paint: animator.skia.Paint) None¶
- drawRect(self: animator.skia.Canvas, rect: animator.skia.Rect, paint: animator.skia.Paint) None¶
- drawRegion(self: animator.skia.Canvas, region: animator.skia.Region, paint: animator.skia.Paint) None¶
- drawRoundRect(self: animator.skia.Canvas, rect: animator.skia.Rect, rx: float, ry: float, paint: animator.skia.Paint) None¶
- drawShadow(self: animator.skia.Canvas, path: animator.skia.Path, zPlaneParams: animator.skia.Point3, lightPos: animator.skia.Point3, lightRadius: float, ambientColor: int, spotColor: int, flags: int = <ShadowFlags.kNone_ShadowFlag: 0>) None¶
Draw an offset spot shadow and outlining ambient shadow for the given path using a disc light.
- drawSimpleText(self: animator.skia.Canvas, text: str, encoding: animator.skia.TextEncoding, x: float, y: float, font: animator.skia.Font, paint: animator.skia.Paint) None¶
Draws text at (x, y) using font and paint.
- drawString(self: animator.skia.Canvas, text: str, x: float, y: float, font: animator.skia.Font, paint: animator.skia.Paint) None¶
- drawText(self: animator.skia.Canvas, text: str, x: float, y: float, font: animator.skia.Font, paint: animator.skia.Paint, encoding: animator.skia.TextEncoding = <TextEncoding.kUTF8: 0>, align: animator.skia.TextUtils_Align = <TextUtils_Align.kLeft_Align: 0>) None¶
Draws the text at (x, y) using the given font and paint useing SkTextUtils.
- drawTextBlob(self: animator.skia.Canvas, blob: animator.skia.TextBlob, x: float, y: float, paint: animator.skia.Paint) None¶
- drawVertices(self: animator.skia.Canvas, vertices: animator.skia.Vertices, mode: animator.skia.BlendMode, paint: animator.skia.Paint) None¶
- getBaseLayerSize(self: animator.skia.Canvas) animator.skia.ISize¶
- getBaseProps(self: animator.skia.Canvas) animator.skia.SurfaceProps¶
- getDeviceClipBounds(self: animator.skia.Canvas) animator.skia.IRect¶
- getLocalClipBounds(self: animator.skia.Canvas) animator.skia.Rect¶
- getLocalToDeviceAs3x3(self: animator.skia.Canvas) animator.skia.Matrix¶
- getProps(self: animator.skia.Canvas) Optional[animator.skia.SurfaceProps]¶
Returns
SurfaceProps, ifCanvasis associated with raster surface. Otherwise, returnsNone.
- getSaveCount(self: animator.skia.Canvas) int¶
- getSurface(self: animator.skia.Canvas) animator.skia.Surface¶
- getTopProps(self: animator.skia.Canvas) animator.skia.SurfaceProps¶
- getTotalMatrix(self: animator.skia.Canvas) animator.skia.Matrix¶
- imageInfo(self: animator.skia.Canvas) animator.skia.ImageInfo¶
- isClipEmpty(self: animator.skia.Canvas) bool¶
- isClipRect(self: animator.skia.Canvas) bool¶
- makeSurface(self: animator.skia.Canvas, info: animator.skia.ImageInfo, props: animator.skia.SurfaceProps = None) animator.skia.Surface¶
- peekPixels(self: animator.skia.Canvas) animator.skia.Pixmap¶
Returns a
Pixmapdescribing the pixel data.
- quickReject(*args, **kwargs)¶
Overloaded function.
quickReject(self: animator.skia.Canvas, rect: animator.skia.Rect) -> bool
quickReject(self: animator.skia.Canvas, path: animator.skia.Path) -> bool
- readPixels(*args, **kwargs)¶
Overloaded function.
readPixels(self: animator.skia.Canvas, dstInfo: animator.skia.ImageInfo, dstPixels: buffer, dstRowBytes: int = 0, srcX: int = 0, srcY: int = 0) -> bool
Copies dstInfo pixels starting from (srcX, srcY) to dstPixels buffer.
readPixels(self: animator.skia.Canvas, pixmap: animator.skia.Pixmap, srcX: int = 0, srcY: int = 0) -> bool
readPixels(self: animator.skia.Canvas, bitmap: animator.skia.Bitmap, srcX: int = 0, srcY: int = 0) -> bool
- resetMatrix(self: animator.skia.Canvas) None¶
- restore(self: animator.skia.Canvas) None¶
- restoreToCount(self: animator.skia.Canvas, saveCount: int) None¶
- rotate(*args, **kwargs)¶
Overloaded function.
rotate(self: animator.skia.Canvas, degrees: float) -> None
rotate(self: animator.skia.Canvas, degrees: float, px: float, py: float) -> None
- save(self: animator.skia.Canvas) int¶
- saveLayer(*args, **kwargs)¶
Overloaded function.
saveLayer(self: animator.skia.Canvas, bounds: animator.skia.Rect = None, paint: animator.skia.Paint = None) -> int
saveLayer(self: animator.skia.Canvas, layerRec: animator.skia.Canvas.SaveLayerRec) -> int
- saveLayerAlpha(self: animator.skia.Canvas, bounds: animator.skia.Rect, alpha: int) int¶
- saveLayerAlphaf(self: animator.skia.Canvas, bounds: animator.skia.Rect, alpha: float) int¶
- scale(self: animator.skia.Canvas, sx: float, sy: float) None¶
- setMatrix(self: animator.skia.Canvas, matrix: animator.skia.Matrix) None¶
- skew(self: animator.skia.Canvas, sx: float, sy: float) None¶
- toarray(self: animator.skia.Canvas, srcX: int = 0, srcY: int = 0, ct: animator.skia.ColorType = <ColorType.kRGBA_8888_ColorType: 4>, at: animator.skia.AlphaType = <AlphaType.kUnpremul_AlphaType: 3>, cs: animator.skia.ColorSpace = None) numpy.ndarray¶
Returns a
ndarrayof the current canvas’ pixels.
- translate(self: animator.skia.Canvas, dx: float, dy: float) None¶
- writePixels(*args, **kwargs)¶
Overloaded function.
writePixels(self: animator.skia.Canvas, info: animator.skia.ImageInfo, pixels: buffer, rowBytes: int = 0, x: int = 0, y: int = 0) -> bool
Writes pixels from a buffer to the canvas.
writePixels(self: animator.skia.Canvas, bitmap: animator.skia.Bitmap, x: int = 0, y: int = 0) -> bool