The OpenD Programming Language

NVGPathOutline

charOutline will return NVGPathOutline.

some usage samples:

1 float[4] bounds = void;
2 
3 nvg.scale(0.5, 0.5);
4 nvg.translate(500, 800);
5 nvg.evenOddFill;
6 
7 nvg.newPath();
8 nvg.charToPath('&', bounds[]);
9 conwriteln(bounds[]);
10 nvg.fillPaint(nvg.linearGradient(0, 0, 600, 600, NVGColor("#f70"), NVGColor("#ff0")));
11 nvg.strokeColor(NVGColor("#0f0"));
12 nvg.strokeWidth = 3;
13 nvg.fill();
14 nvg.stroke();
15 // glyph bounds
16 nvg.newPath();
17 nvg.rect(bounds[0], bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]);
18 nvg.strokeColor(NVGColor("#00f"));
19 nvg.stroke();
20 
21 nvg.newPath();
22 nvg.charToPath('g', bounds[]);
23 conwriteln(bounds[]);
24 nvg.fill();
25 nvg.strokeColor(NVGColor("#0f0"));
26 nvg.stroke();
27 // glyph bounds
28 nvg.newPath();
29 nvg.rect(bounds[0], bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]);
30 nvg.strokeColor(NVGColor("#00f"));
31 nvg.stroke();
32 
33 nvg.newPath();
34 nvg.moveTo(0, 0);
35 nvg.lineTo(600, 0);
36 nvg.strokeColor(NVGColor("#0ff"));
37 nvg.stroke();
38 
39 if (auto ol = nvg.charOutline('Q')) {
40   scope(exit) ol.kill();
41   nvg.newPath();
42   conwriteln("==== length: ", ol.length, " ====");
43   foreach (const ref cmd; ol.commands) {
44     //conwriteln("  ", cmd.code, ": ", cmd.args[]);
45     assert(cmd.valid);
46     final switch (cmd.code) {
47       case cmd.Kind.MoveTo: nvg.moveTo(cmd.args[0], cmd.args[1]); break;
48       case cmd.Kind.LineTo: nvg.lineTo(cmd.args[0], cmd.args[1]); break;
49       case cmd.Kind.QuadTo: nvg.quadTo(cmd.args[0], cmd.args[1], cmd.args[2], cmd.args[3]); break;
50       case cmd.Kind.BezierTo: nvg.bezierTo(cmd.args[0], cmd.args[1], cmd.args[2], cmd.args[3], cmd.args[4], cmd.args[5]); break;
51     }
52   }
53   nvg.strokeColor(NVGColor("#f00"));
54   nvg.stroke();
55 }

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Functions

clear
void clear()

Clear storage.

commands
auto commands()

Returns forward range with all glyph commands.

flatten
NVGPathOutline flatten()

Returns "flattened" path. Flattened path consists of only two commands kinds: MoveTo and LineTo.

flatten
NVGPathOutline flatten(NVGMatrix mt)

Returns "flattened" path, transformed by the given matrix. Flattened path consists of only two commands kinds: MoveTo and LineTo.

Properties

empty
empty [@property getter]

Is this outline empty?

length
int length [@property getter]

Returns number of commands in outline.

Static functions

createNewBezier
NVGPathOutline createNewBezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)

Create new path with cubic bezier (first command is MoveTo, second command is BezierTo).

createNewQuad
NVGPathOutline createNewQuad(float x0, float y0, float cx, float cy, float x, float y)

Create new path with quadratic bezier (first command is MoveTo, second command is QuadTo).

Structs

Command
struct Command

commands

See Also

Meta