[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-111230":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":13,"stars7d":13,"stars30d":14,"stars90d":13,"forks30d":13,"starsTrendScore":13,"compositeScore":15,"rankGlobal":8,"rankLanguage":8,"license":16,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":17,"hasPages":17,"topics":19,"createdAt":8,"pushedAt":20,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":13,"starSnapshotCount":13,"syncStatus":14,"lastSyncTime":24,"discoverSource":25},111230,"graphite","unixzii\u002Fgraphite","unixzii",null,"C",58,1,52,0,2,38.1,"MIT License",false,"main",[],"2026-11-09 17:01:57","2026-11-14 06:20:03","# Graphite\n\n![Screenshot](.\u002Fdocs\u002Fscreenshot.png)\n\n[Live Demo](https:\u002F\u002Fgraphite-mines.vercel.app\u002F)\n\nA cross-platform, retained-mode 2D compositing library with an immediate-mode\ndrawing API, written in C11. You build a tree of layers, and Graphite realizes\nthem onto the platform compositor: Core Animation on macOS, GTK \u002F GSK on Linux,\nand Windows Composition on Windows.\n\n- **Layers**: containers, shapes, gradients and content layers, with frames,\n  transforms, opacity, corner radii, borders, shadows, blur, clipping and masks.\n- **Canvas**: content layers draw on demand with paths, strokes, dashes,\n  gradients, images, clips and transforms.\n- **Text**: attributed text, layout and glyph-level drawing through each\n  platform's text system.\n- **Unconstrained Updating**: change properties whenever you like. The backend\n  commits pending changes at the platform's own commit point, and you can also\n  render offscreen into pixels.\n\n## A quick look\n\n```c\n#include \u003Cgraphite\u002Fgraphite.h>\n\n#include \u003Cmath.h>\n\n\u002F* Runs when the layer needs content and records drawing commands. *\u002F\nstatic void draw_bars(void *userdata, gr_canvas *canvas, const gr_draw_info *info)\n{\n    (void)userdata;\n    gr_paint *blue = gr_paint_new(&(gr_paint_desc){.kind = GR_PAINT_SOLID, .value.solid = {0.04f, 0.52f, 1, 1}});\n    for (int i = 0; i \u003C 6; ++i)\n    {\n        double height = 24 + 14 * i;\n        gr_canvas_fill_rect(canvas, (gr_rect){{i * 26.0, info->bounds.size.height - height}, {18, height}}, blue);\n    }\n    gr_paint_unref(blue);\n}\n\ngr_scene *make_scene(void)\n{\n    gr_scene *scene = gr_scene_new((gr_size){400, 300});\n\n    \u002F* A rounded white card with a soft shadow. *\u002F\n    gr_layer *card = gr_layer_new(scene, GR_LAYER_CONTAINER);\n    gr_layer_set_frame(card, (gr_rect){{40, 40}, {320, 220}});\n    gr_layer_set_background(card, &(gr_color){1, 1, 1, 1});\n    gr_layer_set_corner_radius(card, 16);\n    gr_layer_set_shadow(card, &(gr_shadow){.color = {0, 0, 0, 0.2f}, .offset = {0, 6}, .blur_sigma = 10});\n    gr_layer_add_child(gr_scene_get_root(scene), card);\n\n    \u002F* A vector shape: an orange circle. *\u002F\n    gr_path_builder *builder = gr_path_builder_new();\n    gr_path_builder_add_ellipse(builder, (gr_rect){{0, 0}, {48, 48}});\n    gr_path *circle = gr_path_builder_finish(builder);\n    gr_paint *orange = gr_paint_new(&(gr_paint_desc){.kind = GR_PAINT_SOLID, .value.solid = {1, 0.62f, 0.04f, 1}});\n    gr_layer *dot = gr_layer_new(scene, GR_LAYER_SHAPE);\n    gr_layer_set_frame(dot, (gr_rect){{248, 24}, {48, 48}});\n    gr_shape_layer_set_path(dot, circle);\n    gr_shape_layer_set_fill(dot, orange);\n    gr_layer_add_child(card, dot);\n\n    \u002F* Immediate-mode drawing inside a retained layer. *\u002F\n    gr_layer *bars = gr_layer_new(scene, GR_LAYER_CONTENT);\n    gr_layer_set_frame(bars, (gr_rect){{24, 80}, {160, 120}});\n    gr_content_layer_set_drawer(bars, &(gr_drawer){.draw = draw_bars});\n    gr_layer_add_child(card, bars);\n\n    \u002F* Parents keep their children and layers keep their resources, so local references can go. *\u002F\n    gr_path_builder_unref(builder);\n    gr_path_unref(circle);\n    gr_paint_unref(orange);\n    gr_layer_unref(dot);\n    gr_layer_unref(card);\n    gr_layer_unref(bars);\n    return scene;\n}\n```\n\nThe code above renders like this:\n\n![Example](.\u002Fdocs\u002Fexample.png)\n\nEvery object is an opaque, reference-counted handle: `*_new` returns a reference\nyou own and `*_unref` releases it. Setters return a `gr_result` (`GR_OK` on\nsuccess). See the full conventions in [types.h](include\u002Fgraphite\u002Ftypes.h).\n\nTo show the scene, attach it to a native view, then just change properties\nfrom your display callback:\n\n```c\ngr_scene *scene = make_scene();\n\n\u002F* macOS: an NSView filling the window (GTK: gr_gtk_attach, Windows: gr_windows_attach_to_hwnd).\n * Every platform returns the same gr_scene_host handle. *\u002F\ngr_scene_host *host = gr_macos_attach_to_view(scene, (__bridge void *)window.contentView);\n\n\u002F* Now you can update the layers anytime. The backend commits the changes for you. *\u002F\ngr_layer_set_position(...);\ngr_layer_set_transform(...);\n```\n\nFor offscreen rendering, `gr_macos_offscreen_new`, `gr_gtk_attach_offscreen` and\n`gr_windows_offscreen_new` render the same scene into RGBA pixels.\n\n## Run the examples\n\n```sh\ncmake -S . -B ..\u002Fgraphite-build -DCMAKE_BUILD_TYPE=Release\ncmake --build ..\u002Fgraphite-build --parallel\n..\u002Fgraphite-build\u002Fexamples\u002Fshowcase\u002Fshowcase\n```\n\nEach one is at `examples\u002F\u003Cname>\u002F\u003Cname>` in the build directory and accepts\n`--fps` (report the frame rate) or `--snapshot \u003Cout.png>`.\n\n- **macOS** 14 or later works out of the box.\n- **Linux** needs GTK 4.22+ development headers with `-DGRAPHITE_GTK=ON`.\n- **Windows 11**: use a Visual Studio developer prompt. The Visual Studio\n  generator ignores `CMAKE_BUILD_TYPE`, so build with `--config Release` and look\n  in `examples\\\u003Cname>\\Release\\` (`bin\\Release\\` for shared builds), or configure with `-G Ninja` to keep the layout above.\n\nSee the [examples guide](examples\u002FREADME.md) for how they are put together and\nhow to add one.\n\n## Use it in your project\n\nInstall Graphite into a prefix, then find it from CMake:\n\n```cmake\nfind_package(graphite 0.0.1 CONFIG REQUIRED COMPONENTS macos) # or gtk, windows\ntarget_link_libraries(my_app PRIVATE graphite::macos)\n```\n\n`graphite::graphite` is the platform-independent core. Each platform target links\nit for you. The [CMake guide](docs\u002Fcmake.md) covers installing, static or shared\npackages, and the build options.\n\n## Developing Graphite\n\n```sh\ncmake --build ..\u002Fgraphite-build --target check\n```\n\n`check` builds everything, verifies formatting with clang-format 18 and runs the\ntests. Native rendering tests need a graphical session and core-only CI does not.\n\n- [Documentation](docs\u002FREADME.md): architecture, layer semantics, lifetime and backends\n- [Public API conventions](include\u002Fgraphite\u002Ftypes.h)\n- [Conformance](conformance\u002FREADME.md)\n- [Benchmarks](benchmarks\u002FREADME.md)\n\n## License\n\nGraphite is released under the [MIT License](LICENSE).\n","Graphite 是一个跨平台的 C11 编写的 2D 合成图形库，采用保留模式（retained-mode）架构，同时提供即时模式（immediate-mode）绘图能力。核心功能包括分层渲染（容器、形状、内容层）、矢量路径绘制、属性化文本排版、硬件加速的阴影\u002F圆角\u002F模糊\u002F裁剪等视觉效果，并通过各平台原生合成器（macOS Core Animation、Linux GTK\u002FGSK、Windows Composition）实现高效渲染。适用于需要高性能、跨平台 UI 渲染的桌面应用、嵌入式 GUI 或自研渲染引擎场景。","2026-11-24 04:40:30","CREATED_QUERY"]