{"id":21699535,"url":"https://github.com/basdp/skia-zig","last_synced_at":"2025-04-12T13:13:30.102Z","repository":{"id":264592043,"uuid":"869558713","full_name":"basdp/skia-zig","owner":"basdp","description":"Zig bindings for the Skia 2D Graphics Library","archived":false,"fork":false,"pushed_at":"2024-11-25T07:49:28.000Z","size":8364,"stargazers_count":7,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T13:13:22.916Z","etag":null,"topics":["skia","zig","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/basdp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2024-10-08T13:53:02.000Z","updated_at":"2025-02-01T10:16:04.000Z","dependencies_parsed_at":"2024-11-25T08:41:20.390Z","dependency_job_id":null,"html_url":"https://github.com/basdp/skia-zig","commit_stats":null,"previous_names":["basdp/skia-zig"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basdp%2Fskia-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basdp%2Fskia-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basdp%2Fskia-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basdp%2Fskia-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basdp","download_url":"https://codeload.github.com/basdp/skia-zig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571863,"owners_count":21126522,"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":["skia","zig","zig-package"],"created_at":"2024-11-25T20:09:59.473Z","updated_at":"2025-04-12T13:13:30.083Z","avatar_url":"https://github.com/basdp.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ch1 align=\"center\"\u003eSkia Zig Bindings\u003c/h1\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/basdp/skia-zig/actions/workflows/build.yml\"\u003e\u003cimg src=\"https://github.com/basdp/skia-zig/actions/workflows/build.yml/badge.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eZig bindings for the famous \u003ca href=\"https://skia.org/\"\u003eSkia 2D Graphics Library\u003c/a\u003e.\u003c/p\u003e\n\n## Overview\n\nThis repository provides Zig bindings to the Skia C API. It builds Skia for multiple platforms and exposes the raw C headers to be used directly in Zig projects. **No wrappers** are provided—this is a low-level binding to the C layer only.\n\nThis repository is using the [Skia fork from the Mono project](https://github.com/mono/skia), as they actively maintain a C wrapper for Skia (which is C++ only). We need C wrappers to bridge to Zig. \n\n## Features\n\n- Pre-built Skia binaries\n- Exposes the raw Skia C API headers to Zig\n- Easy to import and use directly from Zig code without any dependencies or extra build steps\n\n## Project status\n*Warning*: This wrapper is in a very early stage and is _not_ stable for production use. Also not all features and plaforms are implemented.\n\n- [x] Skia build for Windows x86_64\n- [ ] Skia build for macOS x86_64\n- [ ] Skia build for macOS Apple Silicon\n- [ ] Skia build for Linux\n\n## Getting Started\n\n### Usage\n\n1. Import the `skia-zig` package into your project:\n```bash\nzig fetch --save https://github.com/basdp/skia-zig/releases/latest/download/skia-zig-package.zip\n```\n\n2. Add the dependency to your `build.zig` file, somewhere below `b.addExecutable(...)` or whatever you are building:\n\n```zig\nconst skia_dep = b.dependency(\"skia-zig\", .{\n    .target = target,\n    .optimize = optimize,\n});\nexe.root_module.addImport(\"skia-zig\", skia_dep.module(\"skia-zig\"));\n```\n\n3. You can now import `skia-zig` in your Zig code:\n```zig\nconst skia = @import(\"skia-zig\");\n\npub fn main() !void {\n    const gr_glinterface = skia.gr_glinterface_create_native_interface();\n    defer skia.gr_glinterface_unref(gr_glinterface);\n    const gr_context = skia.gr_direct_context_make_gl(gr_glinterface) orelse return error.SkiaCreateContextFailed;\n    defer skia.gr_direct_context_free_gpu_resources(gr_context);\n\n    const gl_info = skia.gr_gl_framebufferinfo_t{\n        .fFBOID = 0,\n        .fFormat = gl.RGBA8,\n    };\n\n    const samples: c_int = ... // get from GL or something\n    const stencil_bits: c_int = ... // get from GL or something\n\n    const backendRenderTarget = skia.gr_backendrendertarget_new_gl(640, 480, samples, stencil_bits, \u0026gl_info) orelse return error.SkiaCreateRenderTargetFailed;\n\n    const color_type = skia.RGBA_8888_SK_COLORTYPE;\n    const colorspace = null;\n    const props = null;\n    const surface = skia.sk_surface_new_backend_render_target(@ptrCast(gr_context), backendRenderTarget, skia.BOTTOM_LEFT_GR_SURFACE_ORIGIN, color_type, colorspace, props) orelse return error.SkiaCreateSurfaceFailed;\n    defer skia.sk_surface_unref(surface);\n\n    const canvas = skia.sk_surface_get_canvas(surface) orelse unreachable;\n\n    while (/* app is running */) {\n        skia.sk_canvas_clear(canvas, 0xffffffff);\n\n        const fill = skia.sk_paint_new() orelse return error.SkiaCreatePaintFailed;\n        defer skia.sk_paint_delete(fill);\n        skia.sk_paint_set_color(fill, 0xff0000ff);\n        skia.sk_canvas_draw_paint(canvas, fill);\n\n        // Your Skia drawing here\n\n        skia.sk_canvas_flush(canvas);\n    }\n}\n```\n\n\n### Setting your ABI to MSVC on Windows\n\nSkia requires the `msvc` ABI on Windows, so make sure you target that ABI. There are two possible \noptions to do so (only one of these is necessary):\n\n1. Set the target from the command line while building:\n\n    ```bash\n    zig build -Dtarget=x86_64-windows-msvc\n    ```\n\n2. Or better yet; replace the `const target = ...` line in your `build.zig` file:\n\n    ```zig\n    const target = b.standardTargetOptions(.{ .default_target = .{\n        .abi = if (b.graph.host.result.os.tag == .windows) .msvc else null,\n    } });\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasdp%2Fskia-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasdp%2Fskia-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasdp%2Fskia-zig/lists"}