swiftui-skia 0.0.2-beta.1

The swiftui-skia is a skia based 2d graphics SwiftUI rendering library. It is based on Rust to implement software rasterization to perform rendering. It takes up less memory than the hardware rasterization, however it is still an experimental project. And it's based entirely on SwiftUI syntax.
docs.rs failed to build swiftui-skia-0.0.2-beta.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

SwiftUI Skia

license crates

The swiftui-skia is a skia based 2d graphics SwiftUI rendering library. It is based on Rust to implement software rasterization to perform rendering. It takes up less memory than the hardware rasterization, however it is still an experimental project. And it's based entirely on SwiftUI syntax.

基于 Skia 的 2D 图形 SwiftUI 渲染库 —— 使用 Rust 语言实现纯软件光栅化渲染,相比原生光栅化占用更少的内存,不过目前仍然是一个实验项目;此外使用层面完全基于 SwiftUI 语法。

Usage

import SwiftUI
import SwiftUISkia

struct ContentView: View {
    var body: some View {
        SwiftUISkia.Surface(width: 360, height: 360) {
            SwiftUISkia.Rect(x: 10, y: 220, width: 30, height: 30, style: "fill", color: "cyan") {}
            SwiftUISkia.Line(p1: [100, 260], p2: [50, 285], strokeWidth: 8, color: "black") {}
            SwiftUISkia.RoundRect(x: 220, y: 50, r: 10, width: 80, height: 80, style: "stroke", color: "fuchsia") {}
            SwiftUISkia.Points(points: [
                [138, 10],
                [178, 90],
                [266, 103],
                [202, 165],
                [217, 254],
                [138, 212],
                [59, 254],
                [74, 165],
                [10, 103],
                [98, 90],
                [138, 10],
              ], strokeWidth: 1, style: "fill", color: "rgba(200, 255, 0, 0.7)") {}
            SwiftUISkia.Circle(cx: 200, cy: 220, r: 70, style: "stroke", color: "violet") {}
            SwiftUISkia.Circle(cx: 200, cy: 220, r: 50, style: "fill", color: "violet") {}
            SwiftUISkia.Text(text: "Hello SwiftUI Skia!",x: 80, y: 0, fontSize: 16, color: "black", maxWidth: 60) {}
        }
    }
}

Installation in Rust workspace

$ cargo add swiftui-skia
$ ln -s ~/.cargo/registry/src/index.crates.io-{YOUR CRATE HASH}/swiftui-skia-0.0.2 swiftui-skia
$ cargo install cargo-lip

$ cargo install swift-bridge-cli
$ cd swiftui-skia

$ rustup target add x86_64-apple-darwin aarch64-apple-darwin aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim

$ ./build-rust.sh

$ ./build-bridge.sh

Add Package Dependency

Frameworks, Libraries, and Embedded Content

△ SwiftUISkia

△ SwiftUISkiaBridge

License

MIT