Skip to content

A toy R wrapper for 'rust-skia'

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

paithiov909/skiagd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ecf197d Â· Mar 22, 2025

History

28 Commits
Mar 19, 2025
Mar 22, 2025
Mar 22, 2025
Mar 22, 2025
Mar 21, 2025
Mar 19, 2025
Mar 19, 2025
Mar 19, 2025
Mar 9, 2025
Mar 9, 2025
Mar 21, 2025
Mar 21, 2025
Mar 21, 2025
Mar 9, 2025
Mar 9, 2025
Mar 17, 2025
Mar 9, 2025
Mar 9, 2025

Repository files navigation

skiagd

Lifecycle: experimental R-CMD-check

skiagd is a toy R wrapper for rust-skia (the rust crate skia_safe, a binding for Skia).

Despite its name, this package is intended as a graphics library, not a graphics device for R 😓

Design notes

  • This is not a graphics device. skiagd does not allow R’s session to hold a reference to a Canvas object on Rust side.
  • Drawing functions return a picture as a raw object every time it’s called. add_* puts those data onto canvas, actually adds some paintings to there, and then returns a raw object again.

Future plan

I’m planning to re-implement features like React Native Skia.

Maybe in the near future??

  • Shapes
    • Path
      • SVG notation (path)
    • Polygons
      • Rect
      • RoundedRect (round_rect)
      • DiffRect (drrect)
      • Line
      • Points (points; not point)
    • Ellipses
      • Circle
      • Oval (oval)
      • Arc (arc)
    • Atlas
    • Vertices
    • Patch
  • Images
    • PNG
  • Text
    • Paragraph
    • Text
    • Glyphs
    • Text Path
    • Text Blob
  • Painting Attributes (Paint)
    • PathEffects
    • MaskFilter?? (blur)
    • ImageFilters
    • Shaders
    • RuntimeShaders

Possibly in the future??

Showcase

It’s still in early alpha stage. The API is subject to (maybe drastic) change.

pkgload::load_all(export_all = FALSE)
#> ℹ Loading skiagd

img_data <-
  unigd::ugd_render_inline({
    set.seed(1234)
    size <- dev_size("px")
    n_circles <- 250
    canvas("snow") |>
      add_line(
        matrix(c(runif(300, 0, size[1]), runif(300, 0, size[2])), ncol = 2),
        matrix(c(runif(300, 0, size[1]), runif(300, 0, size[2])), ncol = 2),
        props = paint(color = "#fff28166", width = 6)
      ) |>
      add_circle(
        matrix(c(runif(n_circles,  0, size[1]), runif(n_circles, 0, size[2])), ncol = 2),
        runif(n_circles, 6, 50),
        props = paint(color = "#87ceeb66", blend_mode = BlendMode$ColorBurn)
      ) |>
      add_circle(
        matrix(c(runif(n_circles, 0, size[1]), runif(n_circles, 0, size[2])), ncol = 2),
        runif(n_circles, 20, 60),
        props = paint(color = "#ff1493aa", blend_mode = BlendMode$Overlay)
      ) |>
      add_path(
        "M 128 0 L 168 80 L 256 93 L 192 155 L 207 244 L 128 202 L 49 244 L 64 155 L 0 93 L 88 80 L 128 0 Z",
        transform = c(1, 0, (size[1] / 2 - 128), 0, 1, (size[2] / 2 - 128), 0, 0, 1),
        props = paint(color = "#fff281ee")
      ) |>
      draw_img()
  }, as = "png", width = 1280, height = 720)

img_data |>
  magick::image_read() |>
  as.raster() |>
  plot()

About

A toy R wrapper for 'rust-skia'

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published