canvas->drawPath(path, paint);
}
+void draw_thin_right_angle(SkCanvas* canvas, const SkPaint& paint, SkScalar width) {
+ SkPath path;
+ path.moveTo(10 + width, 10 + width);
+ path.lineTo(40, 10 + width);
+ path.lineTo(40, 20);
+ path.lineTo(40 + width, 20 + width);
+ path.lineTo(40 + width, 10);
+ path.lineTo(10, 10);
+ canvas->drawPath(path, paint);
+}
+
};
DEF_SIMPLE_GM(thinconcavepaths, canvas, 400, 400) {
canvas->translate(0, 25);
}
canvas->restore();
+ canvas->translate(50, 0);
+ canvas->save();
+ for (SkScalar width = 0.5; width < 2.05; width += 0.25) {
+ draw_thin_right_angle(canvas, paint, width);
+ canvas->translate(0, 25);
+ }
+ canvas->restore();
+ canvas->translate(100, 0);
}
}
void get_edge_normal(const Edge* e, SkVector* normal) {
- normal->setNormalize(SkDoubleToScalar(-e->fLine.fB) * e->fWinding,
- SkDoubleToScalar(e->fLine.fA) * e->fWinding);
+ normal->setNormalize(SkDoubleToScalar(e->fLine.fA) * e->fWinding,
+ SkDoubleToScalar(e->fLine.fB) * e->fWinding);
}
// Stage 5c: detect and remove "pointy" vertices whose edge normals point in opposite directions
double dist = e->dist(prev->fPoint);
SkVector normal;
get_edge_normal(e, &normal);
- float denom = 0.25f * static_cast<float>(e->fLine.magSq());
+ float denom = 0.0625f * static_cast<float>(e->fLine.magSq());
if (prevNormal.dot(normal) < 0.0 && (dist * dist) <= denom) {
Edge* join = new_edge(prev, next, Edge::Type::kInner, c, alloc);
insert_edge(join, e, boundary);