├── .github
├── README.md
├── example_canvas_ity.png
├── example_html5.png
├── icon.png
└── workflows
│ └── tests.yml
├── LICENSE.txt
├── demos
└── tiger
│ ├── CMakeLists.txt
│ └── tiger.cpp
├── src
└── canvas_ity.hpp
└── test
├── CMakeLists.txt
├── test.cpp
└── test.html
/.github/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # canvas_ity
4 |
5 | [](../../../actions/workflows/tests.yml)
6 |
7 | This is a tiny, [single-header C++ library](../src/canvas_ity.hpp)
8 | for rasterizing immediate-mode 2D vector graphics, closely
9 | modeled on the basic [W3C (not WHATWG) HTML5 2D canvas
10 | specification](https://www.w3.org/TR/2015/REC-2dcontext-20151119/).
11 |
12 | The priorities for this library are high-quality rendering, ease of use, and
13 | compact size. Speed is important too, but secondary to the other priorities.
14 | Notably, this library takes an opinionated approach and does not provide
15 | options for trading off quality for speed.
16 |
17 | Despite its small size, it supports nearly everything listed in the W3C
18 | HTML5 2D canvas specification, except for hit regions and getting certain
19 | properties. The main differences lie in the surface-level API to make this
20 | easier for C++ use, while the underlying implementation is carefully based
21 | on the specification. In particular, stroke, fill, gradient, pattern,
22 | image, and font styles are specified slightly differently (avoiding strings
23 | and auxiliary classes). Nonetheless, the goal is that this library could
24 | produce a conforming HTML5 2D canvas implementation if wrapped in a thin
25 | layer of JavaScript bindings. See the accompanying [C++ automated test
26 | suite](../test/test.cpp) and its [HTML5 port](../test/test.html) for a mapping
27 | between the APIs and a comparison of this library's rendering output against
28 | browser canvas implementations.
29 |
30 | ## :memo: Example
31 |
32 | The following complete example program writes out a TGA image file and
33 | demonstrates path building, fills, strokes, line dash patterns, line joins,
34 | line caps, linear gradients, drop shadows, and compositing operations. See
35 | the HTML5 equivalent of the example on the right (scroll the code horizontally
36 | if needed) and compare them line-by-line. Note that the minor differences
37 | in shading are due to the library's use of gamma-correct blending whereas
38 | browsers typically ignore this.
39 |
40 |
canvas_ity | 43 |HTML5 | 44 |
---|---|
![]() |
47 | ![]() |
48 |
51 |
52 |
53 | ```c++
54 | #include |
127 |
128 |
129 |
130 | ```html
131 |
132 |
133 |
134 | |
206 |