https://github.com/google/forma Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} google / forma Public * Notifications * Fork 10 * Star 518 An efficient vector-graphics renderer License Apache-2.0 license 518 stars 10 forks Star Notifications * Code * Issues 10 * Pull requests 0 * Discussions * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Discussions * Actions * Projects * Security * Insights google/forma This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/g] Use Git or checkout with SVN using the web URL. [gh repo clone google] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @dragostis dragostis Merge pull request #13 from Timmmm/patch-1 ... 4f3ed13 Dec 16, 2022 Merge pull request #13 from Timmmm/patch-1 Fix typo in readme 4f3ed13 Git stats * 11 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .cargo .github/workflows assets demo docs e2e-tests forma .gitignore Cargo.toml LICENSE README.md View code Getting started 4-stage Pipeline Implementation Highlights Similar Projects Example (Currently) Missing Pieces Note README.md forma logo crates.io badge [6874747073] A (thoroughly) parallelized experimental Rust vector-graphics renderer with both a software (CPU) and hardware (GPU) back-end having the following goals, in this order: 1. Portability; supporting Fuchsia, Linux, macOS, Windows, Android & iOS. 2. Performance; making use of compute-focused pipeline that is highly parallelized both at the instruction-level and the thread-level. 3. Simplicity; implementing an easy-to-understand 4-stage pipeline. 4. Size; minimizing the number of dependencies and focusing on vector-graphics only. It relies on Rust's SIMD auto-vectorization/intrinsics and Rayon to have good performance on the CPU, while using WebGPU (wgpu) to take advantage of the GPU. Getting started Add the following to your Cargo.toml dependencies: forma = { version = "0.1.0", package = "forma-render" } 4-stage Pipeline 1. Curve 2. Line segment 3. Sorting 4. Painting flattening rasterization Bezier line segments pixel segments sorted pixel curves segments, old tiles [?][?][?] [?][?][?] [?][?][?] [?][?][?] line pixel segments sorted pixel freshly painted tiles segments segments Implementation Highlights Here are a few implementation highlights that make forma stand out from commonly used vector renderers. Curvature-aware flattening All higher cubic Beziers are approximated by quadratic ones, then, in parallel, flattened to line segments according to their curvature. This technique was developed by Raph Levien. Cheap translations and rotations Translations and rotations can be rendered without having to re-flatten the curves, all the while maintaining full quality. Parallel pixel grid intersection Line segments are transformed into pixel segments by intersecting them with the pixel grid. We developed a simple method that performs this computation in O(1) and which is run in parallel. Efficient sorting We ported crumsort to Rust and parallelized it with Rayon, delivering improved performance over its pdqsort implementation for 64-bit random data. Scattering pixel segments with a sort was inspired from Allan MacKinnon's work on Spinel. Update only the tiles that change (currently CPU-only) We implemented a fail-fast per-tile optimizer that tries to skip the painting step entirely. A similar approach could also be tested on the GPU. Animation as it appears on the screen Updated tiles only [spaceship] juice animation updated tiles You can run the demo above with: cargo run --release -p demo -- spaceship Similar Projects forma draws heavy inspiration from the following projects: * Spinel, with a Vulkan 1.2 back-end * vello, with a wgpu back-end Example You can use the included demo example to render a few examples, one of which is a non-compliant & incomplete SVG renderer: cargo run --release -p demo -- svg assets/svgs/paris-30k.svg It renders enormous SVGs at interactive framerates, even on CPU: ( compare to your web browser) window rendering map of Germany (Currently) Missing Pieces Since this project is work-in-progress, breakage in the API, while not drastic, is expected. The performance on the GPU back-end is also expected to improve especially on mobile where performance is known to be poor and where the CPU back-end is currently advised instead. Other than that: * Automated layer ordering * Strokes * More color spaces for blends & gradients * Faster GPU sorter * Use of f16 for great mobile GPU performance Note This is not an officially supported Google product. About An efficient vector-graphics renderer Resources Readme License Apache-2.0 license Code of conduct Code of conduct Security policy Security policy Stars 518 stars Watchers 4 watching Forks 10 forks Releases No releases published Packages 0 No packages published Contributors 3 * * * Languages * Rust 98.1% * HTML 1.9% Footer (c) 2022 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.