-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (35 loc) · 1.25 KB
/
main.cpp
File metadata and controls
38 lines (35 loc) · 1.25 KB
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
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkStrokeRec.h"
#include "include/effects/SkDashPathEffect.h"
#include "include/pathops/SkPathOps.h"
using namespace pk;
static void TestTightBounds() {
constexpr auto side = 300.f;
SkPath path;
path.moveTo(0.f, 0.f);
path.cubicTo(side * 0.25f, side, side * 0.75f, -side, side, 0.f);
path.cubicTo(side * 1.25f, side, side * 1.75f, -side, side * 2.f, 0.f);
const auto bounds = path.getBounds();
const auto tightBounds = path.computeTightBounds();
printf("TestTightBounds: bounds{%f, %f, %f, %f}, tightBounds{%f, %f, %f, %f}\n",
bounds.x(),
bounds.y(),
bounds.width(),
bounds.height(),
tightBounds.x(),
tightBounds.y(),
tightBounds.width(),
tightBounds.height());
}
int main() {
SkPath skPath{};
skPath.addRect(SkRect::MakeXYWH(100, 100, 100, 100));
Op(skPath, skPath, SkPathOp::kUnion_SkPathOp, &skPath);
float intervals[] = {1, 2, 3, 4};
auto dashEffect = SkDashPathEffect::Make(intervals, 4, 1);
SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle);
dashEffect->filterPath(&skPath, skPath, &rec, nullptr);
TestTightBounds();
return 0;
}