1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! `dinamika-cpu` — a raster 2D renderer on the CPU.
//!
//! Creating images, building vector contours, anti-aliased fill and stroke,
//! gradients and blend modes. The only external dependency is the
//! [`png`](https://docs.rs/png) crate for saving frames.
//!
//! # Main types
//!
//! - [`Pixmap`] — a pixel buffer (premultiplied RGBA) and the entry point for
//! drawing. It can composite another [`Pixmap`] on top of itself
//! ([`Pixmap::draw_pixmap`]) and decode PNG ([`Pixmap::decode_png`]).
//! - [`Path`] / [`PathBuilder`] — vector contours with Bézier curves; there are
//! ready-made rectangle, rounded rectangle, ellipse and circle.
//! - [`Paint`] — a brush: color/gradient/texture ([`Shader`]), blend mode
//! ([`BlendMode`]), anti-aliasing.
//! - [`Shader`] — a color source: solid, linear/radial/conic
//! gradient or texture ([`Pattern`]).
//! - [`Stroke`] — stroke parameters (width, caps, joins, dashes,
//! "hairline").
//! - [`Mask`] — a clipping mask (`overflow: hidden`).
//! - [`Transform`] — an affine transformation.
//! - [`Font`] — a TrueType/OpenType face ([`ttf-parser`]) that turns text into a
//! fillable [`Path`]; [`Pixmap::fill_text`] draws it in one call.
//!
//! # Example
//!
//! ```
//! use dinamika_cpu::*;
//!
//! let mut pixmap = Pixmap::new(200, 200).unwrap();
//! pixmap.fill(Color::WHITE);
//!
//! let path = PathBuilder::from_circle(100.0, 100.0, 80.0).unwrap();
//! let paint = Paint::from_color(Color::from_rgba8(220, 40, 90, 255));
//! pixmap.fill_path(&path, &paint, FillRule::NonZero, Transform::identity(), None);
//!
//! // The ready pixels (premultiplied RGBA) live in `pixmap.data()`.
//! assert_eq!(pixmap.data().len(), 200 * 200 * 4);
//! ```
//!
//! # Known limitations
//!
//! Deliberate trade-offs for the sake of MVP simplicity (details are in the
//! documentation of the respective modules):
//!
//! - **Color is computed in sRGB, not in linear light.** Blending and
//! gradient interpolation operate directly on the gamma components — as in
//! most 8-bit engines. Gradients are slightly "dirtier", semi-transparent
//! edges darken a little (see the `paint` module).
//! - **Stroke width is isotropic.** Under non-uniform scaling or shearing the
//! stroke comes out circular rather than elliptical (see
//! [`Pixmap::stroke_path`]).
//! - **Thin AA seams are possible at the junctions of stroke stamps**
//! (segment↔join); acceptable for an MVP (see the `stroke` module).
//! - **Text layout is minimal.** [`Font`] places glyphs by their horizontal
//! advance only — no kerning, shaping or bidi (see the `text` module).
//!
//! [`ttf-parser`]: https://docs.rs/ttf-parser
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Pixmap;
pub use Mask;
pub use ;