27static const char* verb_type_name(VerbType verbType) {
29 case VerbType::kTriangles:
return "kTriangles";
30 case VerbType::kQuadratics:
return "kQuadratics";
31 case VerbType::kCubics:
return "kCubics";
32 case VerbType::kConics:
return "kConics";
42 StrokeVerbSlide() {
fName =
"StrokeVerb"; }
59 void updateAndInval() { this->updatePath(); }
63 VerbType fVerbType = VerbType::kCubics;
66 {100.05f, 100.05f}, {400.75f, 100.05f}, {400.75f, 300.95f}, {100.05f, 300.95f}};
68 float fConicWeight = .5;
69 float fStrokeWidth = 40;
89 caption.
appendf(
"VerbType_%s", verb_type_name(fVerbType));
90 if (VerbType::kCubics == fVerbType) {
92 }
else if (VerbType::kConics == fVerbType) {
93 caption.
appendf(
" (w=%f)", fConicWeight);
96 caption.
appendf(
" (stroke_width=%f)", fStrokeWidth);
103 if (VerbType::kCubics == fVerbType) {
116void StrokeVerbSlide::updatePath() {
120 case VerbType::kCubics:
123 case VerbType::kQuadratics:
126 case VerbType::kConics:
129 case VerbType::kTriangles:
139 Click(
int ptIdx) : fPtIdx(ptIdx) {}
145 for (
int i = 0;
i < 4; ++
i) {
157 for (
int i = 0;
i < 4; ++
i) {
158 if (VerbType::kCubics != fVerbType && 2 ==
i) {
161 if (fabs(
x - fPoints[
i].
x()) < 20 && fabsf(
y - fPoints[
i].
y()) < 20) {
165 return new Click(-1);
169 Click* myClick = (Click*)click;
170 myClick->doClick(fPoints);
171 this->updateAndInval();
175bool StrokeVerbSlide::onChar(
SkUnichar unichar) {
176 if (unichar >=
'1' && unichar <=
'4') {
177 fVerbType = VerbType(unichar -
'1');
178 this->updateAndInval();
181 float* valueToScale =
nullptr;
182 if (VerbType::kConics == fVerbType) {
183 valueToScale = &fConicWeight;
185 valueToScale = &fStrokeWidth;
188 if (unichar ==
'+') {
190 this->updateAndInval();
193 if (unichar ==
'=') {
194 *valueToScale *= 5/4.f;
195 this->updateAndInval();
198 if (unichar ==
'-') {
199 *valueToScale *= 4/5.f;
200 this->updateAndInval();
203 if (unichar ==
'_') {
204 *valueToScale *= .5f;
205 this->updateAndInval();
209 if (unichar ==
'D') {
210 SkDebugf(
" SkPoint fPoints[4] = {\n");
211 SkDebugf(
" {%ff, %ff},\n", fPoints[0].
x(), fPoints[0].
y());
212 SkDebugf(
" {%ff, %ff},\n", fPoints[1].
x(), fPoints[1].
y());
213 SkDebugf(
" {%ff, %ff},\n", fPoints[2].
x(), fPoints[2].
y());
214 SkDebugf(
" {%ff, %ff}\n", fPoints[3].
x(), fPoints[3].
y());
218 if (unichar ==
'J') {
220 this->updateAndInval();
223 if (unichar ==
'C') {
225 this->updateAndInval();
static const int points[]
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SkCubicType SkClassifyCubic(const SkPoint P[4], double t[2], double s[2], double d[4])
static const char * SkCubicTypeName(SkCubicType type)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
virtual bool onClick(Click *)=0
virtual Click * onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi)=0
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
void clear(SkColor color)
void drawPath(const SkPath &path, const SkPaint &paint)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
@ kPoints_PointMode
draw each point separately
@ kButt_Cap
no stroke extension
void setStyle(Style style)
void setColor(SkColor color)
void setAntiAlias(bool aa)
void setStrokeCap(Cap cap)
@ kStroke_Style
set to stroke geometry
void setStrokeJoin(Join join)
@ kMiter_Join
extends to miter limit
void setStrokeWidth(SkScalar width)
SkPath & moveTo(SkScalar x, SkScalar y)
SkPath & lineTo(SkScalar x, SkScalar y)
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
virtual bool onChar(SkUnichar c)
virtual void load(SkScalar winWidth, SkScalar winHeight)
virtual void draw(SkCanvas *canvas)=0
@ kTriangles
The vertices are taken 3 at a time to form a triangle.
font
Font Metadata and Metrics.