Title: | R wrapper for 'rust-skia' |
---|---|
Description: | A toy R wrapper for 'rust-skia' <https://github.com/rust-skia/rust-skia> (the Rust crate 'skia_safe' <https://rust-skia.github.io/doc/skia_safe/>, a binding for 'Skia' <https://skia.org/>). |
Authors: | Akiru Kato [aut, cre], Jeroen Ooms [cph] |
Maintainer: | Akiru Kato <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2025-03-24 08:23:01 UTC |
Source: | https://github.com/paithiov909/skiagd |
Add circles
add_circle(img, center, radius, props = paint())
add_circle(img, center, radius, props = paint())
img |
A raw vector of picture. |
center |
A double matrix where each row is circle center. |
radius |
Numerics of circle radius. |
props |
A paint properties out of |
A raw vector of picture.
Add difference rectangles
add_diff_rect(img, outer, outer_radii, inner, inner_radii, props = paint())
add_diff_rect(img, outer, outer_radii, inner, inner_radii, props = paint())
img |
A raw vector of picture. |
outer |
A double matrix where each row is an outer rectangle XYWH (left, top, right, bottom). |
outer_radii |
A double matrix where each row is a pair of axis lengths on X-axis and Y-axis of outer oval describing rounded corners. |
inner |
A double matrix where each row is an inner rectangle XYWH (left, top, right, bottom). |
inner_radii |
A double matrix where each row is a pair of axis lengths on X-axis and Y-axis of inner oval describing rounded corners. |
props |
A paint properties out of |
A raw vector of picture.
Add lines
add_line(img, from, to, props = paint())
add_line(img, from, to, props = paint())
img |
A raw vector of picture. |
from |
A double matrix where each row is a start point. |
to |
A double matrix where each row is an end point. |
props |
A paint properties out of |
A raw vector of picture.
Add paths
add_path(img, path, transform = c(1, 0, 0, 0, 1, 0, 0, 0, 1), props = paint())
add_path(img, path, transform = c(1, 0, 0, 0, 1, 0, 0, 0, 1), props = paint())
img |
A raw vector of picture. |
path |
Characters of SVG notations
like |
transform |
Numerics of length 9 to apply affine transformations to the path themselves. See transform-matrix for affine transformations. |
props |
A paint properties out of |
A raw vector of picture.
Add PNG image to canvas
add_png(img, png, left = 0, top = 0, props = paint())
add_png(img, png, left = 0, top = 0, props = paint())
img |
A raw vector of picture. |
png |
A raw vector of PNG data. |
left |
Left offset for drawing PNG image. |
top |
Top offset for drawing PNG image. |
props |
A paint properties out of |
A raw vector of picture.
Add points
add_point(img, point, props = paint())
add_point(img, point, props = paint())
img |
A raw vector of picture. |
point |
A double matrix where each row is a point. |
props |
A paint properties out of |
A raw vector of picture.
Add rectangles
add_rect(img, rect, props = paint())
add_rect(img, rect, props = paint())
img |
A raw vector of picture. |
rect |
A double matrix where each row is a rectangle XYWH (left, top, right, bottom). |
props |
A paint properties out of |
A raw vector of picture.
Add rounded rectangles
add_rounded_rect(img, rect, radii, props = paint())
add_rounded_rect(img, rect, radii, props = paint())
img |
A raw vector of picture. |
rect |
A double matrix where each row is a rectangle XYWH (left, top, right, bottom). |
radii |
A double matrix where each row is a pair of axis lengths on X-axis and Y-axis of oval describing rounded corners. |
props |
A paint properties out of |
A raw vector of picture.
Convert picture into PNG data
as_png(img, props = paint())
as_png(img, props = paint())
img |
A raw vector of picture. |
props |
A paint properties out of |
A raw vector of PNG data.
This is mainly for testing purposes.
as_recordedplot(img, props = paint())
as_recordedplot(img, props = paint())
img |
A raw vector of picture. |
props |
A paint properties out of |
A recordedplot
object. See grDevices::recordPlot()
for details.
BlendMode
determines how source and destination colors are combined.
BlendMode
BlendMode
An object of class BlendMode__bundle
(inherits from savvy_skiagd__sealed
) of length 29.
The following blend modes are available in Skia:
Clear
Src
Dst
SrcOver
DstOver
SrcIn
DstIn
SrcOut
DstOut
SrcATop
DstATop
Xor
Plus
Modulate
Screen
Overlay
Darken
Lighten
ColorDodge
ColorBurn
HardLight
SoftLight
Difference
Exclusion
Multiply
Hue
Saturation
Color
Luminosity
Other paint-attributes:
Cap
,
FillType
,
Join
,
PathEffect
,
PointMode
,
Shader
,
Style
Creates a new canvas filled with specified color.
canvas(fill = "transparent", size = paint()[["canvas_size"]])
canvas(fill = "transparent", size = paint()[["canvas_size"]])
fill |
RGBA representation of a color.
This can be specified using named colors or hexadecimal color codes,
which are converted internally using |
size |
Integers of length 2; canvas size. |
A raw vector of picture.
Cap
determines the stroke cap (the geometry drawn at the beginning and end of strokes).
Cap
Cap
An object of class Cap__bundle
(inherits from savvy_skiagd__sealed
) of length 3.
The following caps are available:
Butt
: Butt cap.
Round
: Round cap.
Square
: Square cap.
Cap in skia_safe::paint - Rust
Other paint-attributes:
BlendMode
,
FillType
,
Join
,
PathEffect
,
PointMode
,
Shader
,
Style
A wrapper of grDevices::col2rgb()
.
col2rgba(color)
col2rgba(color)
color |
|
An integer vector.
Just returns the size of the current device as an integer (not a numeric).
dev_size(units = "px")
dev_size(units = "px")
units |
|
An integer vector.
Plot picture as PNG image
draw_img(img, props = paint())
draw_img(img, props = paint())
img |
A raw vector of picture. |
props |
A paint properties out of |
img
is returned invisibly.
FillType
determines how paths are drawn.
This is for add_path()
only. Not used in other functions.
FillType
FillType
An object of class FillType__bundle
(inherits from savvy_skiagd__sealed
) of length 4.
The following FillType
are available:
Winding
EvenOdd
InverseWinding
InverseEvenOdd
FillType in skia_safe::path - Rust
Other paint-attributes:
BlendMode
,
Cap
,
Join
,
PathEffect
,
PointMode
,
Shader
,
Style
as_png(img)
and then adds it to a new canvas.
freeze(img, fill = "transparent", props = paint())
freeze(img, fill = "transparent", props = paint())
img |
A raw vector of picture. |
fill |
A string scalar; named colors or hexadecimal color codes. |
props |
A paint properties out of |
A raw vector of picture.
Join
determines the stroke join (the geometry drawn at the corners of strokes) for shapes.
Join
Join
An object of class Join__bundle
(inherits from savvy_skiagd__sealed
) of length 3.
The following joins are available:
Miter
: Miter join.
Round
: Round join.
Bevel
: Bevel join.
Join in skia_safe::paint - Rust
Other paint-attributes:
BlendMode
,
Cap
,
FillType
,
PathEffect
,
PointMode
,
Shader
,
Style
The paint()
function allows users to specify
various painting attributes for drawing shapes on the canvas,
such as color, stroke width, and transformations.
paint(...)
paint(...)
... |
< |
The following painting attributes can be specified:
canvas_size
: Integers of length 2 (width, height).
color
: RGBA representation of a color. This can be specified using named colors or hexadecimal color codes, which are converted internally using grDevices::col2rgb()
.
style
: The paint style. See Style.
join
: Stroke join. See Join.
cap
: Stroke cap. See Cap.
width
: A numeric scalar (stroke width).
miter
: A numeric scalar (stroke miter).
blend_mode
: See BlendMode.
path_effect
: See PathEffect.
shader
: See Shader.
point_mode
: PointMode for add_point()
.
fill_type
: FillType for add_path()
.
transform
: Numerics of length 9. See transform-matrix for affine transformations.
A list containing the specified painting attributes, merged with default values.
PathEffect
is a struct that offers a reference to skia_safe::PathEffect
.
You can apply a path effect to shapes via paint()
.
Currently only single PathEffect
can be specified; multiple effects are not supported.
start |
A numeric scalar in the range |
end |
A numeric scalar in the range |
length |
A numeric scalar; length of the subsegments. |
deviation |
A numeric scalar; limit of the movement of the endpoints. |
seed |
An integer scalar; random seed. |
intervals |
A numeric vector; even number of entries with even indices specifying the length of the "on" intervals, and the odd index specifying the length of "off". |
phase |
A numeric scalar; offset into the intervals array (for |
radius |
A numeric scalar; radius of the rounded corners. |
path |
A string scalar of SVG notation to replicate. |
advance |
A numeric scalar; space between instances of path. |
style |
A string scalar; how to transform path at each point.
Can be |
transform |
Numerics of length 9; transformation matrix. |
width |
A numeric scalar; width of the path to be stamped. |
The following effects are available:
no_effect()
: does not apply any path effect. This is the default effect for paint()
.
trim(start, end)
: trims the start
and end
of the path. Note that you can't trim nothing at all, i.e., setting start = 0
and end = 1
arises an error.
discrete(lentgh, deviation, seed)
: applies discrete path effect.
dash(intervals, phase)
: applies dash path effect.
corner(radius)
: applies corner path effect.
path_1d(path, advance, phase, style)
: applies 1D path effect.
path_2d(path, transform)
: applies 2D path effect.
line_2d(width, transform)
: applies 2D line path effect.
A PathEffect
object.
Path Effects | React Native Skia
Other paint-attributes:
BlendMode
,
Cap
,
FillType
,
Join
,
PointMode
,
Shader
,
Style
PointMode
determines how points are drawn.
This is for add_point()
only. Not used in other functions.
PointMode
PointMode
An object of class PointMode__bundle
(inherits from savvy_skiagd__sealed
) of length 3.
The following PointMode
are available:
Points
: Draws each point
as a point. The shape of point drawn depends on props
.
Lines
: Each pair of point
draws a line segment. One line is drawn for every two points; each point is used once. If count is odd, the final point is ignored.
Polygon
: Each adjacent pair of point
draws a line segment. count minus one lines are drawn; the first and last point are used once.
PointMode in skia_safe::canvas - Rust
Other paint-attributes:
BlendMode
,
Cap
,
FillType
,
Join
,
PathEffect
,
Shader
,
Style
Shader
is a struct that offers a reference to skia_safe::Shader
.
You can apply a shader to shapes via paint()
.
Note that concatenating shaders with c()
is equivalent to blend them all
into a single shader using Shader$blend()
with the default BlendMode
.
You can pass mode
explicitly for c()
to change the blend mode.
img |
A raw vector of picture. |
mode |
|
tile_size |
Numerics of length 2; tile size (width, height). |
transform |
Numerics of length 9; transformation matrix. |
png_bytes |
A raw vector of PNG data. |
rgba |
Integers of length 4 in range |
dst |
A |
src |
A |
freq |
Numerics of length 2; frequencies. |
octaves |
A numeric scalar; number of octaves. |
seed |
Integer scalar; random seed. |
start |
Numerics of length 2; starting point (x, y). |
end |
Numerics of length 2; ending point (x, y). |
from |
Integers of lenth 4 in range |
to |
Integers of length 4 in range |
flags |
A logical scalar; typically, you can leave this as |
radii |
Numerics of length 2; radii of start and end circles. |
center |
Numerics of length 2; center of the gradient. |
start_angle |
A numeric scalar in range |
end_angle |
A numeric scalar in range |
The following shaders are available:
no_shader()
: does not apply any shader. This is the default shader for paint()
.
from_picture(img, mode, tile_size, transform)
: takes a picture and returns an image shader.
from_png(png_bytes, mode, transform)
: takes a PNG image and returns an image shader.
color(rgba)
: takess a color and returns a color shader.
blend(mode, dst, src)
: returns a shader that combines the given shaders with a BlendMode.
fractal_noise(freq, octaves, seed, tile_size)
: fractal perlin noise shader.
turbulence(freq, octaves, seed, tile_size)
: turbulence noise shader.
linear_gradient(start, end, from, to, mode, flags, transform)
: linear gradient shader.
radial_gradient(center, radius, from, to, mode, flags, transform)
: radial gradient shader.
conical_gradient(start, end, radii, from, to, mode, flags, transform)
: conical gradient shader.
sweep_gradient(center, start_angle, end_angle, from, to, mode, flags, transform)
: sweep gradient shader.
A Shader
object.
Other paint-attributes:
BlendMode
,
Cap
,
FillType
,
Join
,
PathEffect
,
PointMode
,
Style
Style
determines the stroke style of shapes.
Style
Style
An object of class Style__bundle
(inherits from savvy_skiagd__sealed
) of length 3.
The following styles are available:
StrokeAndFill
: Stroke and fill.
Stroke
: Stroke only.
Fill
: Fill only.
Style in skia_safe::paint - Rust
Other paint-attributes:
BlendMode
,
Cap
,
FillType
,
Join
,
PathEffect
,
PointMode
,
Shader
TileMode
determines how the source is tiled for shaders.
This is not a paint attribute. To specify TileMode
, directly pass these pointers to shader functions.
TileMode
TileMode
An object of class TileMode__bundle
(inherits from savvy_skiagd__sealed
) of length 4.
The following TileMode
are available:
Clamp
Repeat
Mirror
Decal
When loading a picture into a canvas,
you can apply an affine transformation
by providing a numeric vector of length 9 to paint()
as transform
.
This vector defines a transformation matrix that modifies a picture before rendering it onto the canvas.
The transform
vector represents a 3x3 matrix
used for affine transformations, following the format:
The first two columns define standard affine transformations,
including scaling, skewing, and translation.
The third column (pers_0
, pers_1
, and pers_2
) is
typically used for perspective transformations,
though in most affine transformations, it remains as c(0, 0, 1)
.