58 storage[
count++] = pts[0];
114 SKELETON_COLOR = 0xFF0000FF,
115 WIREFRAME_COLOR = 0x80FF0000
150 #define kStrokerErrorMin 0.001f
151 #define kStrokerErrorMax 5
154 #define kWidthMax 100
187 fCubicButton.
fLabel =
'C';
189 fConicButton.
fLabel =
'K';
195 fRRectButton.
fLabel =
'R';
197 fCircleButton.
fLabel =
'O';
199 fCircleButton.
fFill =
true;
204 fName =
"QuadStroker";
214 fTextSize =
std::max(1.0f, fTextSize - 1);
221 fText.appendUnichar(uni);
242 draw_stroke(canvas,
path,
width, 950,
false);
250 draw_stroke(canvas,
path,
width, 950,
false);
258 draw_stroke(canvas,
path,
width, 950,
false);
266 draw_stroke(canvas,
path,
width, 950,
false);
283 draw_stroke(canvas,
path,
width, 950,
false);
292 paint.setAntiAlias(
true);
293 paint.setColor(0x40FF8844);
303 if (fCircleButton.
fFill) {
311 draw_fill(canvas, r,
width);
313 draw_stroke(canvas,
path,
width, 950,
false);
320 font.setSize(fTextSize);
324 draw_stroke(canvas,
path,
width * fWidthScale / fTextSize, fTextSize,
true);
331 }
else if (fDWidth < 0 && fWidth <
kWidthMin) {
337 draw_control(canvas, fWeightControl, fWeight, 0, 5,
"weight");
340 draw_control(canvas, fRadiusControl, fRadius, 0, 500,
"radius");
343 draw_control(canvas, fErrorControl, gDebugStrokerError, kStrokerErrorMin, kStrokerErrorMax,
346 draw_control(canvas, fWidthControl, fWidth * fWidthScale,
kWidthMin * fWidthScale,
348 draw_button(canvas, fQuadButton);
349 draw_button(canvas, fCubicButton);
350 draw_button(canvas, fConicButton);
351 draw_button(canvas, fArcButton);
352 draw_button(canvas, fRRectButton);
353 draw_button(canvas, fCircleButton);
354 draw_button(canvas, fTextButton);
370 if (fWeightControl.
contains(rectPt)) {
373 if (fRadiusControl.
contains(rectPt)) {
377 if (fErrorControl.
contains(rectPt)) {
381 if (fWidthControl.
contains(rectPt)) {
405 bool wasEnabled = fCircleButton.
fEnabled;
407 fCircleButton.
fFill = wasEnabled && !fCircleButton.
fFill;
418 int index = ((
MyClick*)click)->fIndex;
423 fWeight = MapScreenYtoValue(click->
fCurr.
fY, fWeightControl, 0, 5);
425 fRadius = MapScreenYtoValue(click->
fCurr.
fY, fRadiusControl, 0, 500);
429 gDebugStrokerError =
std::max(FLT_EPSILON, MapScreenYtoValue(click->
fCurr.
fY,
430 fErrorControl, kStrokerErrorMin, kStrokerErrorMax));
431 gDebugStrokerErrorSet =
true;
435 fWidth =
std::max(FLT_EPSILON, MapScreenYtoValue(click->
fCurr.
fY, fWidthControl,
444 fRadiusControl.
setXYWH(
w - 200, 30, 30, 400);
445 fWeightControl.
setXYWH(
w - 150, 30, 30, 400);
446 fErrorControl.
setXYWH(
w - 100, 30, 30, 400);
447 fWidthControl.
setXYWH(
w - 50, 30, 30, 400);
448 int buttonOffset = 450;
464 void copyMinToMax() {
469 fMinSurface->
draw(canvas, 0, 0);
474 for (
int iy = 1; iy < fH; ++iy) {
478 for (
int ix = 1; ix < fW; ++ix) {
501 paint.setAlpha(0x80);
502 paint.setAntiAlias(
true);
503 int n =
path.countPoints();
504 std::unique_ptr<SkPoint[]> pts{
new SkPoint[n]};
505 if (show_lines && fDrawTangents) {
509 for (
int i = 0;
i < contourCounts.
size(); ++
i) {
510 int count = contourCounts[
i];
518 paint.setStrokeWidth(5);
537 if (meas.getPosTan(dist, &
pos, &tan)) {
542 if (0 == index % 10) {
548 pos.
x() - tan.
x() * 1.25f,
pos.
y() - tan.
y() * 1.25f,
font, labelP);
575 for (
int index = 0; index < ribs; ++index) {
579 tan = pts[1] - pts[0];
591 tan =
conic.evalTangentAt(t);
604 if (0 == index % 10) {
608 pos.
x() + tan.
x() * 1.25f,
609 pos.
y() + tan.
y() * 1.25f,
618 if (
path.isEmpty()) {
627 paint.setColor(0x1f1f0f0f);
630 paint.setColor(0x3f0f1f3f);
633 this->copyMinToMax();
634 fMaxSurface->
draw(canvas, 0, 0);
636 paint.setAntiAlias(
true);
638 paint.setStrokeWidth(1);
640 paint.setColor(SKELETON_COLOR);
651 draw_points(canvas, scaled, SKELETON_COLOR,
true);
654 draw_ribs(canvas, scaled,
width, 0xFF00FF00);
658 draw_t_divs(canvas, scaled,
width, 0xFF3F3F00);
677 paint.setColor(WIREFRAME_COLOR);
679 draw_points(canvas, scaledFill, WIREFRAME_COLOR,
false);
683 if (
rect.isEmpty()) {
687 paint.setColor(0x1f1f0f0f);
698 paint.setColor(0x3f0f1f3f);
704 (maxSide +
width) * 2, (maxSide +
width) * 2);
705 path.addRect(outside);
711 paint.setAntiAlias(
true);
727 paint.setAntiAlias(
true);
732 paint.setColor(0xFFFF0000);
736 paint.setColor(0xFF000000);
744 void setForGeometry() {
746 fDrawTangents =
true;
752 fDrawRibs = fDrawTangents = fDrawTDivs =
false;
753 fWidthScale = 0.002f;
756 void setForSingles() {
773 path.moveTo(fPts[10]);
774 path.arcTo(fPts[11], fPts[12], fRadius);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static bool hittest(const SkPoint &target, SkScalar x, SkScalar y)
static void getContourCounts(const SkPath &path, TArray< int > *contourCounts)
static void erase(const sk_sp< SkSurface > &surface)
static int getOnCurvePoints(const SkPath &path, SkPoint storage[])
constexpr SkColor SK_ColorLTGRAY
constexpr SkColor SK_ColorTRANSPARENT
constexpr SkColor SK_ColorDKGRAY
@ kUTF8
uses bytes to represent UTF-8 or ASCII
void SkEvalCubicAt(const SkPoint src[4], SkScalar t, SkPoint *loc, SkVector *tangent, SkVector *curvature)
SkVector SkEvalQuadTangentAt(const SkPoint src[3], SkScalar t)
void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint *pt, SkVector *tangent)
@ kClose
SkPath::RawIter returns 0 points.
@ kCubic
SkPath::RawIter returns 4 points.
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
@ kQuad
SkPath::RawIter returns 3 points.
@ kMove
SkPath::RawIter returns 1 point.
@ kLine
SkPath::RawIter returns 2 points.
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
#define SkScalarRoundToInt(x)
#define SkScalarCeilToInt(x)
static SkScalar center(float pos0, float pos1)
void resize(SkScalar w, SkScalar h) override
void draw(SkCanvas *canvas) override
Click * onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override
bool onChar(SkUnichar uni) override
void load(SkScalar w, SkScalar h) override
bool onClick(Click *click) override
void drawRect(const SkRect &rect, const SkPaint &paint)
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void clear(SkColor color)
void drawPath(const SkPath &path, const SkPaint &paint)
void concat(const SkMatrix &matrix)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
@ kPolygon_PointMode
draw the array of points as a open polygon
@ kPoints_PointMode
draw each point separately
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
void setColor(SkColor color)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
static const uint8_t * VerbData(const SkPath &path)
static const SkScalar * ConicWeightData(const SkPath &path)
static const SkPoint * PointData(const SkPath &path)
SkPath & moveTo(SkScalar x, SkScalar y)
SkPath & lineTo(SkScalar x, SkScalar y)
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
static void RotateCCW(const SkPoint &src, SkPoint *dst)
static void RotateCW(const SkPoint &src, SkPoint *dst)
void inset(SkScalar dx, SkScalar dy, SkRRect *dst) const
void setRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
void printf(const char format[],...) SK_PRINTF_LIKE(2
void appendS32(int32_t value)
void draw(SkCanvas *canvas, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint)
static void GetPath(const void *text, size_t length, SkTextEncoding, SkScalar x, SkScalar y, const SkFont &, SkPath *)
static void Draw(SkCanvas *, const void *text, size_t size, SkTextEncoding, SkScalar x, SkScalar y, const SkFont &, const SkPaint &, Align=kLeft_Align)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
sk_sp< SkBlender > blender SkRect rect
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library name
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
font
Font Metadata and Metrics.
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
SINT T dot(const Vec< N, T > &a, const Vec< N, T > &b)
static SkImageInfo MakeN32Premul(int width, int height)
bool setLength(float length)
void offset(float dx, float dy)
static constexpr SkPoint Make(float x, float y)
void set(float x, float y)
static float Distance(const SkPoint &a, const SkPoint &b)
void scale(float scale, SkPoint *dst) const
constexpr float y() const
constexpr float x() const
SkScalar fBottom
larger y-axis bounds
void setXYWH(float x, float y, float width, float height)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
bool contains(SkScalar x, SkScalar y) const
constexpr float centerX() const
constexpr float height() const
void setIWH(int32_t width, int32_t height)
void setLTRB(float left, float top, float right, float bottom)
void setBounds(const SkPoint pts[], int count)
SkScalar fTop
smaller y-axis bounds