{"id":13478157,"url":"https://github.com/rust-skia/rust-skia","last_synced_at":"2025-05-12T13:23:51.371Z","repository":{"id":37502618,"uuid":"160787491","full_name":"rust-skia/rust-skia","owner":"rust-skia","description":"Rust Bindings for the Skia Graphics Library","archived":false,"fork":false,"pushed_at":"2025-05-09T11:22:56.000Z","size":6646,"stargazers_count":1570,"open_issues_count":48,"forks_count":149,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-09T12:31:06.946Z","etag":null,"topics":["android","d3d","graphics-library","ios","metal","opengl","pdf","rust-bindings","skia","svg","vulkan"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-skia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-07T07:25:31.000Z","updated_at":"2025-05-09T11:23:00.000Z","dependencies_parsed_at":"2024-01-07T21:05:00.527Z","dependency_job_id":"22d6e089-f0f1-49f0-bad6-245a8aebc81a","html_url":"https://github.com/rust-skia/rust-skia","commit_stats":{"total_commits":2752,"total_committers":41,"mean_commits":67.1219512195122,"dds":0.08030523255813948,"last_synced_commit":"a67ea9599ef96d112b0f585aab3439a2b5cfb5b5"},"previous_names":[],"tags_count":101,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-skia%2Frust-skia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-skia%2Frust-skia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-skia%2Frust-skia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-skia%2Frust-skia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-skia","download_url":"https://codeload.github.com/rust-skia/rust-skia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745552,"owners_count":21957398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","d3d","graphics-library","ios","metal","opengl","pdf","rust-bindings","skia","svg","vulkan"],"created_at":"2024-07-31T16:01:53.237Z","updated_at":"2025-05-12T13:23:51.360Z","avatar_url":"https://github.com/rust-skia.png","language":"Rust","funding_links":[],"categories":["Rust","Graphics Library"],"sub_categories":[],"readme":"# \u003cimg alt=\"\" width=\"48\" align=\"top\" src=\"artwork/rust-skia-icon_512x512.png\"/\u003e Safe Rust bindings for the [Skia Graphics Library](https://skia.org/).\n\n[![crates.io](https://img.shields.io/crates/v/skia-safe)](https://crates.io/crates/skia-safe) [![license](https://img.shields.io/crates/l/skia-safe)](LICENSE) [![Windows QA](https://github.com/rust-skia/rust-skia/actions/workflows/windows-qa.yaml/badge.svg?branch=master)](https://github.com/rust-skia/rust-skia/actions/workflows/windows-qa.yaml) [![Linux QA](https://github.com/rust-skia/rust-skia/actions/workflows/linux-qa.yaml/badge.svg?branch=master)](https://github.com/rust-skia/rust-skia/actions/workflows/linux-qa.yaml) [![macOS QA](https://github.com/rust-skia/rust-skia/actions/workflows/macos-qa.yaml/badge.svg?branch=master)](https://github.com/rust-skia/rust-skia/actions/workflows/macos-qa.yaml)\n\nSkia Submodule Status: chrome/m136 ([upstream changes][skia-upstream], [our changes][skia-ours]).\n\n[skia-upstream]: https://github.com/rust-skia/skia/compare/m136-0.84.2...google:chrome/m136\n[skia-ours]: https://github.com/google/skia/compare/chrome/m136...rust-skia:m136-0.84.2\n\n## About\n\nThis project provides _up to date_ safe bindings that bridge idiomatic Rust with Skia's C++ API on desktop and mobile platforms, including GPU rendering backends for [Vulkan](\u003chttps://en.wikipedia.org/wiki/Vulkan_(API)\u003e), [Metal](\u003chttps://en.wikipedia.org/wiki/Metal_(API)\u003e), [OpenGL](https://en.wikipedia.org/wiki/OpenGL), and [Direct3D](https://en.wikipedia.org/wiki/Direct3D).\n\n## Status\n\n### Documentation\n\nBecause we [can't build on docs.rs](https://docs.rs/crate/skia-safe/0.34.0/builds), the `cargo doc` output for skia-safe is manually created and uploaded to [rust-skia.github.io](https://rust-skia.github.io/doc/skia_safe).\n\nWe (slowly) [add more documentation](https://github.com/rust-skia/rust-skia/issues/446) by converting Skia's Doxygen comments to Rust.\n\n### Crate\n\nA prerelease crate is available from [crates.io](https://crates.io/crates/skia-safe) and invoking\n\n```bash\ncargo add skia-safe\n```\n\nin your project's folder should get you started. And you might want to take a look at the [gl-window](https://github.com/rust-skia/rust-skia/tree/master/skia-safe/examples/gl-window) example if you plan to render to a window.\n\n**On Linux** you may run into trouble when **OpenSSL libraries** are missing. On **Debian** and **Ubuntu** they can be installed with:\n\n```bash\nsudo apt-get install pkg-config libssl-dev\n```\n\nFor other platforms, more information is available at the [OpenSSL crate documentation](https://docs.rs/openssl/0.10.24/openssl/#automatic).\n\n### Platform Support, Build Targets, and Prebuilt Binaries\n\nBecause building Skia takes a lot of time and needs tools that may be missing, the skia-bindings crate's `build.rs` attempts to download prebuilt binaries from [the skia-binaries repository](https://github.com/rust-skia/skia-binaries/releases) using the `curl` command line tool.\n\n| Platform                          | Binaries                                                   |\n| --------------------------------- | ---------------------------------------------------------- |\n| Windows                           | `x86_64-pc-windows-msvc`                                   |\n| Linux Ubuntu 16+\u003cbr /\u003eCentOS 7, 8 | `x86_64-unknown-linux-gnu`\u003cbr/\u003e`aarch64-unknown-linux-gnu` |\n| macOS                             | `x86_64-apple-darwin`\u003cbr/\u003e`aarch64-apple-darwin`           |\n| Android                           | `aarch64-linux-android`\u003cbr/\u003e`x86_64-linux-android`         |\n| iOS                               | `aarch64-apple-ios`\u003cbr/\u003e`x86_64-apple-ios`                 |\n| WebAssembly                       | `wasm32-unknown-emscripten`                                |\n\n### Wrappers \u0026 Codecs \u0026 Supported Features\n\nThe supported wrappers, Skia codecs, and additional Skia features are documented in the [skia-safe package's readme](skia-safe/README.md). Prebuilt binaries are available for most feature combinations.\n\n## Building\n\nIf the target platform or feature configuration is not available as a prebuilt binary, skia-bindings' `build.rs` will try to build Skia and generate the Rust bindings.\n\nFor building Skia from source, **LLVM**, **Python 3**, and **Ninja** are required:\n\n**LLVM**\n\nWe recommend the version that comes preinstalled with your platform, or, if not available, the [latest official LLVM release](http://releases.llvm.org/download.html). To see which version of LLVM/Clang is installed on your system, use `clang --version`.\n\n**Python 3**\n\nThe build script probes for `python --version` and `python3 --version` and uses the first one that looks like a version 3 executable for building Skia.\n\n**Ninja**\n\nThe build system for Skia. `ninja` is available as a binary package on all major platforms. Install `ninja` or `ninja-build` and make sure it is available `PATH` with `ninja --version`.\n\n### On macOS\n\n- Install the Command Line Tools for Xcode with\n\n  ```bash\n  xcode-select --install\n  ```\n\n  or download and install the [Command Line Tools for Xcode](https://developer.apple.com/download/more/).\n\n- As an alternative to Apple's XCode LLVM, install LLVM via `brew install llvm` or `brew install llvm` and then set `PATH`, `CPPFLAGS`, and `LDFLAGS` like instructed.\n\n  If the environment variables are not set, [bindgen](https://github.com/rust-lang/rust-bindgen) will most likely use the wrong `libclang.dylib` and cause confusing compilation errors (see #228).\n\n### On Windows\n\n- Have the latest versions of `git` and Rust ready.\n\n- [Install Visual Studio 2022 Build Tools](https://visualstudio.microsoft.com/downloads/) or one of the other IDE editions. If you installed the IDE, make sure that the [Desktop Development with C++ workload](https://docs.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=msvc-170) is installed.\n\n- Install the [latest LLVM](http://releases.llvm.org/download.html) distribution.\n\n  If the environment variable `LLVM_HOME` is not defined, the build script will look for LLVM installations located at `C:\\Program Files\\LLVM\\`, `C:\\LLVM\\`, and `%USERPROFILE%\\scoop\\apps\\llvm\\current\\`.\n\n- [MSYS2](https://www.msys2.org/):\n\n  - Install Python 3 with `pacman -S python`.\n\n- Windows Shell (`Cmd.exe`):\n\n  - Download and install Python 3 from [python.org](https://www.python.org/downloads).\n\n- Install and select the MSVC toolchain:\n  ```bash\n  rustup default stable-msvc\n  ```\n\n### On Linux\n\n#### Ubuntu 20+\n\n- LLVM/Clang should be available already, if not, [install the latest version](http://releases.llvm.org/download.html).\n- If OpenGL libraries are missing, install the drivers for you graphics card, or a mesa package like `libgl1-mesa-dev`.\n- For **X11**, build with feature `x11`.\n- For **Wayland**, install `libwayland-dev` and build with the `wayland` feature.\n\n### For Android\n\nCross compilation to Android is supported for targeting 64 bit ARM and Intel x86 architectures (`aarch64` and `x86_64`) for API Level 26 (Oreo, Android 8):\n\nWe recommend to use [cargo apk](https://crates.io/crates/cargo-apk), but if that does not work for you, following are some instructions on how we build Android targets with GitHub Actions:\n\nFor example, to compile for `aarch64`:\n\n1. Install the Rust target:\n   ```bash\n   rustup target install aarch64-linux-android\n   ```\n2. Download the [r26d NDK](https://developer.android.com/ndk/downloads) (or newer) for your host architecture and unzip it.\n3. Compile your project for the `aarch64-linux-android` target:\n\nOn **macOS**:\n\n```bash\nexport ANDROID_NDK=:path-to-android-ndk-r26d\nexport PATH=$PATH:$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin\nexport CC_aarch64_linux_android=aarch64-linux-android26-clang\nexport CXX_aarch64_linux_android=aarch64-linux-android26-clang++\nexport AR_aarch64_linux_android=llvm-ar\nexport CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android26-clang\n\ncargo build -vv --target aarch64-linux-android\n```\n\nWe don't support Apple's Clang to build for Android on macOS, so you need to install LLVM and set the `PATH` like instructed.\n\nOn **Linux**:\n\n```bash\nexport ANDROID_NDK=:path-to-android-ndk-r26d\nexport PATH=$PATH:$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin\nexport CC_aarch64_linux_android=aarch64-linux-android26-clang\nexport CXX_aarch64_linux_android=aarch64-linux-android26-clang++\nexport AR_aarch64_linux_android=llvm-ar\nexport CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android26-clang\n\ncargo build -vv --target aarch64-linux-android\n```\n\nOn **Windows** the Android NDK Clang executable must be invoked through `.cmd` scripts:\n\n```bash\nexport ANDROID_NDK=:path-to-android-ndk-r26d\nexport PATH=$PATH:$ANDROID_NDK/toolchains/llvm/prebuilt/windows-x86_64/bin\nexport CC_aarch64_linux_android=aarch64-linux-android26-clang.cmd\nexport CXX_aarch64_linux_android=aarch64-linux-android26-clang++.cmd\nexport AR_aarch64_linux_android=llvm-ar\nexport CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android26-clang.cmd\n\ncargo build -vv --target aarch64-linux-android\n```\n\n_Notes:_\n\n- At the time of this writing, the Rust compiler will [automatically add a `-lgcc` argument](https://github.com/rust-windowing/android-ndk-rs/issues/149) to the linker, which results in a linker error, because newer NDKs do not contain `libgcc.a` anymore. To fix this, we created a workaround and [copy `libunwind.a` over to `libgcc.a`](https://github.com/pragmatrix/rust-skia-containers/blob/master/linux/Dockerfile#L48-L52). Cargo apk does something [similar](https://github.com/rust-windowing/android-ndk-rs/issues/149#issuecomment-963988601).\n- The `CARGO_TARGET_${TARGET}_LINKER` environment variable name [needs to be all uppercase](https://github.com/rust-lang/cargo/issues/1109#issuecomment-386850387).\n- In some older shells (for example macOS High Sierra), environment variable replacement can not be used when the variable was defined on the same line. Therefore the `ANDROID_NDK` variable must be defined before it's used in the `PATH` variable.\n- Rebuilding skia-bindings with a different target may cause linker errors, in that case `touch skia-bindings/build.rs` will force a rebuild ([#10](https://github.com/rust-skia/rust-skia/issues/10)).\n\n### For iOS\n\nCompilation to iOS is supported on macOS targeting the iOS simulator (`--target x86_64-apple-ios`) and 64 bit ARM devices (`--target aarch64-apple-ios`). The ARM64**e** architecture is [not supported yet](https://github.com/rust-lang/rust/issues/73628).\n\n### For WebAssembly\n\nInstall `emscripten` version 3.1.57 or superior and make sure that llvm / clang 16+ is installed. In the examples below, we assume\n`emsdk` version `3.1.57` was installed with [asdf](http://asdf-vm.com/).\n\nBuild with the `wasm32-unknown-emscripten` target (`wasm32-unknown-unknown` is\nunsupported because it is [fundamentally incompatible with linking C code](https://github.com/rustwasm/team/issues/291#issuecomment-645482430):\n\n```bash\nexport EMSDK=~/.asdf/installs/emsdk/3.1.57\nexport EMCC_CFLAGS=\"-s ERROR_ON_UNDEFINED_SYMBOLS=0\"\n\ncargo build --target wasm32-unknown-emscripten\n```\n\nThe `EMSDK` environment variable must be set to the root of your `emscripten` SDK.\n\nIn `EMCC_CFLAGS`, `-s ERROR_ON_UNDEFINED_SYMBOLS` is a\n[workaround](https://github.com/rust-lang/rust/issues/85821#issuecomment-969369677) to build with\n`emscripten \u003e 2.0.9`.\n\nIf you want to enable WebGL, you will also have to set `MAX_WEBGL_VERSION=2`:\n\n```bash\nexport EMSDK=~/.asdf/installs/emsdk/3.1.57\nexport EMCC_CFLAGS=\"-s ERROR_ON_UNDEFINED_SYMBOLS=0 -s MAX_WEBGL_VERSION=2\"\n\ncargo build --target wasm32-unknown-emscripten --features gl\n```\n\nOn MacOS there is a problem with the OS version of `ar` so you will have to install the GNU version from homebrew:\n\n```bash\nbrew install binutils\n```\n\nThen prepend `binutils` path for the build. The path depends on your CPU\narchitecture, and can be retrieved with `brew info binutils`. Here is an\nexample for Apple silicon:\n\n```bash\nexport EMSDK=~/.asdf/installs/emsdk/3.1.57\nexport EMCC_CFLAGS=\"-s ERROR_ON_UNDEFINED_SYMBOLS=0\"\nexport PATH=\"/opt/homebrew/opt/binutils/bin:$PATH\"\n\ncargo build --target wasm32-unknown-emscripten\n```\n\n### Skia\n\nFor situations in which Skia does not build or needs to be configured differently, we support some customization support in `skia-bindings/build.rs`. For more details take a look at the [README of the skia-bindings package](skia-bindings/README.md).\n\nPlease share your build experience so that we can try to automate the build and get to the point where `cargo build` _is_ sufficient to build the bindings _including_ Skia, and if that is not possible, clearly prompts to what's missing.\n\n## Example Applications\n\n### gl-window\n\nAn example that opens an OpenGL Window and draws the rust-skia icon with skia-safe (contributed by [@nornagon](https://github.com/nornagon)).\n\n```bash\ncargo run --example gl-window --features gl\n```\n\nOn Linux the feature `x11` needs to be enabled:\n\n```bash\ncargo run --example gl-window --features gl,x11\n```\n\n### vulkan-window\n\nAn example application that opens a Window and renders a blue rectangle using [Vulkano](https://github.com/vulkano-rs/vulkano) (contributed by [@samizdatco](https://github.com/samizdatco) in [#1066](https://github.com/rust-skia/rust-skia/pull/1066))\n\n```bash\ncargo run --example vulkan-window --features \"vulkan,vulkan-window\"\n```\n\nTo add Vulkan support to your system, the easiest way is to install the [LunarG SDK](https://vulkan.lunarg.com/sdk/home), and enable \"System Global Installation\" in the installer.\n\n### icon\n\nThe `icon` example generates the rust-skia icon in the current directory.\nIt computes the position of all the gear teeth etc. based on parameters such as the number of teeth and wheel radius.\n\nIf you were able to build the project, run\n\n```bash\ncargo run --example icon 512\n```\n\nIt has a single optional parameter which is the size in pixels for the PNG file.\nWithout parameters, it’ll produce PNG frames for the animated version.\n\n### skia-org\n\nThe other examples are taken from [Skia's website](https://skia.org/) and [ported to the Rust API](skia-org/).\n\n```bash\ncargo run -- [OUTPUT_DIR]\n```\n\nto generate some Skia drawn PNG images in the directory `OUTPUT_DIR`. To render with OpenGL, use\n\n```bash\ncargo run --features gl -- [OUTPUT_DIR] --driver gl\n```\n\nAnd to show the drivers that are supported\n\n```bash\ncargo run -- --help\n```\n\n## Example Images\n\nFill, Radial Gradients, Stroke, Stroke with Gradient, Transparency:\n[![Rust-skia icon](artwork/rust-skia-icon_512x512.png)](https://matracas.org/tmp/rust-skia-icon.html)\n\nFill, Stroke, Text:\n\n![Fill, Stroke, Text](https://rust-skia.github.io/skia-org/cpu/SkPaint-Overview/02-fill-and-stroke.png)\n\nSweep Gradient:\n\n![Sweep Gradient](https://rust-skia.github.io/skia-org/cpu/SkPaint-Overview/08-sweep-gradient-shader.png)\n\nDash Path Effect:\n\n![Dash Path Effect](https://rust-skia.github.io/skia-org/cpu/SkPaint-Overview/19-dash-path-effect.png)\n\nFor more, you may take a look at the [rust-skia.github.io](https://github.com/rust-skia/rust-skia.github.io/tree/master/skia-org/cpu) repository.\n\n## This project needs contributions!\n\nIf you'd like to help with the bindings, take a look at the [Wiki](https://github.com/rust-skia/rust-skia/wiki) to get started and create an issue to prevent duplicate work. For smaller tasks, grep for \"TODO\"s in the source code. And for heroic work, check out the label [help wanted](https://github.com/rust-skia/rust-skia/labels/help%20wanted). And if you like to help making the Rust API nicer to use, look out for open issues with the label [api ergonomics](https://github.com/rust-skia/rust-skia/issues?q=is%3Aissue+is%3Aopen+label%3A%22api+ergonomics%22).\n\nMore details can be found at [CONTRIBUTING.md](https://github.com/rust-skia/rust-skia/tree/master/CONTRIBUTING.md).\n\n## Notable Contributions\n\n- Denis Kolodin ([@DenisKolodin](https://github.com/DenisKolodin)) contributed build support for Android.\n- Alberto González Palomo ([@AlbertoGP](https://github.com/AlbertoGP)) designed the Rust-Skia Logo and the example program that renders it.\n- Luper Rouch ([@flupke](https://github.com/flupke), sponsored by [Jitter](https://jitter.video/))\n  added build support for the `wasm32-unknown-emscripten` target.\n- Osei Fortune ([@triniwiz](https://github.com/triniwiz)) and Savchenko Ivan ([@Aiving](https://github.com/Aiving))\n  contributed rendering SVG files.\n\n## Maintainers\n\n- LongYinan ([@Brooooooklyn](https://github.com/Brooooooklyn))\n- Armin ([@pragmatrix](https://github.com/pragmatrix))\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-skia%2Frust-skia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-skia%2Frust-skia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-skia%2Frust-skia/lists"}