Skip to content

Commit ff513bf

Browse files
committed
#16 add code for rendering stroke using a fill
Exposes rendering artifacts in testBasic.
1 parent c155c71 commit ff513bf

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Sources/vger/vger.mm

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,30 @@ void vgerStrokeBezier(vgerContext vg, vgerBezierSegment s, float width, vgerPain
250250

251251
if(!vg->checkPaint(paint)) return;
252252

253+
#if 0
254+
// Improve quality of beziers by rendering as fills.
255+
256+
// 90 degrees CCW
257+
float2x2 rot90{
258+
float2{0, 1},
259+
float2{-1, 0}
260+
};
261+
262+
// Tangents.
263+
float2 d0 = rot90 * width * normalize(s.b - s.a);
264+
float2 d1 = rot90 * width * normalize(s.c - s.a);
265+
float2 d2 = rot90 * width * normalize(s.c - s.b);
266+
267+
vgerMoveTo(vg, s.a - d0);
268+
vgerQuadTo(vg, s.b - d1, s.c - d2);
269+
vgerLineTo(vg, s.c + d2);
270+
vgerQuadTo(vg, s.b + d1, s.a + d0);
271+
vgerLineTo(vg, s.a - d0);
272+
vgerFill(vg, paint);
273+
#endif
274+
275+
#if 1
276+
253277
// Are the points degenerate?
254278
// This may not work in general because these are pre-transformed coordinates.
255279
// Could instead check in the vertex function after transforming.
@@ -283,6 +307,7 @@ void vgerStrokeBezier(vgerContext vg, vgerBezierSegment s, float width, vgerPain
283307

284308
vg->addPrim(prim);
285309
}
310+
#endif
286311
}
287312

288313
void vgerStrokeSegment(vgerContext vg, vector_float2 a, vector_float2 b, float width, vgerPaintIndex paint) {

0 commit comments

Comments
 (0)