Git Product home page Git Product logo

zig-cairo's Introduction

zig-cairo

CI

Thin wrapper for the cairo 2D graphics library.

Tested on Zig version 0.9.1.

๐Ÿšง Very much a work in progress... ๐Ÿšง

Naming convention

As suggested in the cairo Appendix, the type names and method names of the original C library were changed to follow the Zig Style Guide. For example, a method like cairo_set_source(cr, source) in cairo becomes cr.setSource(source) in zig-cairo.

Installation

Clone the repo and jump into it:

git clone [email protected]:jackdbd/zig-cairo.git
cd zig-cairo

In order to use this library and run the examples you will need zig version 0.9.1. You can get it using zigup:

zigup fetch 0.9.1
zigup 0.9.1

You will also need cairo, pango, pangocairo, xcb, and xvfb if you want to run some tests/examples in a virtual framebuffer. See this script.

Examples

You can find many examples in the examples directory.

arc.zig arc_negative.zig curve_to.zig fill_style.zig gradient.zig image.zig spiral.zig spirograph.zig

compositing.zig pango_simple.zig

Run zig build --help to see all the compilation targets.

Most examples generate a PNG. Here I use feh to view the generated file:

zig build rounded_rectangle && feh examples/generated/rounded_rectangle.png
zig build spirograph && feh examples/generated/spirograph.png
zig build text_extents && feh examples/generated/text_extents.png

A few examples generate a SVG:

zig build surface_svg && inkscape examples/generated/test-image.svg

Some other examples don't generate any image file. This one opens a window and renders cairo graphics inside of it (using a cairo XCB surface):

zig build surface_xcb

If you installed XVFB you can also run this example in a virtual framebuffer:

xvfb-run --server-args="-screen 0 1024x768x24" zig build surface_xcb

Tests

# run all tests, in all modes (debug, release-fast, release-safe, release-small)
zig build test

# run all tests, only in debug mode
zig build test-debug

zig-cairo's People

Contributors

jackdbd avatar vkcz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.