Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Protected Member Functions | List of all members
VariableWidthStrokerSlide Class Reference
Inheritance diagram for VariableWidthStrokerSlide:
ClickHandlerSlide Slide SkRefCnt SkRefCntBase

Public Member Functions

 VariableWidthStrokerSlide ()
 
void load (SkScalar w, SkScalar h) override
 
void resize (SkScalar w, SkScalar h) override
 
bool onChar (SkUnichar uni) override
 
void draw (SkCanvas *canvas) override
 
- Public Member Functions inherited from ClickHandlerSlide
bool onMouse (SkScalar x, SkScalar y, skui::InputState clickState, skui::ModifierKey modifierKeys) final
 
- Public Member Functions inherited from Slide
virtual SkISize getDimensions () const
 
virtual void gpuTeardown ()
 
virtual void draw (SkCanvas *canvas)=0
 
virtual bool animate (double nanos)
 
virtual void load (SkScalar winWidth, SkScalar winHeight)
 
virtual void resize (SkScalar winWidth, SkScalar winHeight)
 
virtual void unload ()
 
virtual bool onChar (SkUnichar c)
 
virtual bool onMouse (SkScalar x, SkScalar y, skui::InputState state, skui::ModifierKey modifiers)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
const SkStringgetName ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi) override
 
bool onClick (ClickHandlerSlide::Click *) override
 
virtual ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi)=0
 
virtual bool onClick (Click *)=0
 

Additional Inherited Members

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 1024 of file VariableWidthStrokerSlide.cpp.

Constructor & Destructor Documentation

◆ VariableWidthStrokerSlide()

VariableWidthStrokerSlide::VariableWidthStrokerSlide ( )
inline

Definition at line 1026 of file VariableWidthStrokerSlide.cpp.

1027 : fShowHidden(true)
1028 , fShowSkeleton(true)
1029 , fShowStrokePoints(false)
1030 , fShowUI(false)
1031 , fDifferentInnerFunc(false)
1032 , fShowErrorCurve(false) {
1033 resetToDefaults();
1034
1035 fPtsPaint.setAntiAlias(true);
1036 fPtsPaint.setStrokeWidth(10);
1038
1039 fStrokePointsPaint.setAntiAlias(true);
1040 fStrokePointsPaint.setStrokeWidth(5);
1041 fStrokePointsPaint.setStrokeCap(SkPaint::kRound_Cap);
1042
1043 fStrokePaint.setAntiAlias(true);
1044 fStrokePaint.setStyle(SkPaint::kStroke_Style);
1045 fStrokePaint.setColor(0x80FF0000);
1046
1047 fNewFillPaint.setAntiAlias(true);
1048 fNewFillPaint.setColor(0x8000FF00);
1049
1050 fHiddenPaint.setAntiAlias(true);
1051 fHiddenPaint.setStyle(SkPaint::kStroke_Style);
1052 fHiddenPaint.setColor(0xFF0000FF);
1053
1054 fSkeletonPaint.setAntiAlias(true);
1055 fSkeletonPaint.setStyle(SkPaint::kStroke_Style);
1056 fSkeletonPaint.setColor(SK_ColorRED);
1057
1058 fName = "VariableWidthStroker";
1059 }
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
void setStrokeCap(Cap cap)
Definition: SkPaint.cpp:179
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
SkString fName
Definition: Slide.h:54

Member Function Documentation

◆ draw()

void VariableWidthStrokerSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 1100 of file VariableWidthStrokerSlide.cpp.

1100 {
1101 canvas->drawColor(0xFFEEEEEE);
1102
1103 SkPath path;
1104 this->makePath(&path);
1105
1106 fStrokePaint.setStrokeWidth(fWidth);
1107
1108 // Elber-Cohen stroker result
1109 ScalarBezCurve distFnc = makeDistFnc(fDistFncs, fWidth);
1110 ScalarBezCurve distFncInner =
1111 fDifferentInnerFunc ? makeDistFnc(fDistFncsInner, fWidth) : distFnc;
1112 SkVarWidthStroker stroker;
1113 SkPath fillPath =
1114 stroker.getFillPath(path, fStrokePaint, distFnc, distFncInner, fLengthMetric);
1116 canvas->drawPath(fillPath, fNewFillPaint);
1117
1118 if (fShowHidden) {
1119 canvas->drawPath(fillPath, fHiddenPaint);
1120 }
1121
1122 if (fShowSkeleton) {
1123 canvas->drawPath(path, fSkeletonPaint);
1124 canvas->drawPoints(SkCanvas::kPoints_PointMode, fPathPts.size(), fPathPts.data(),
1125 fPtsPaint);
1126 }
1127
1128 if (fShowStrokePoints) {
1129 drawStrokePoints(canvas, fillPath);
1130 }
1131
1132 if (fShowUI) {
1133 drawUI();
1134 }
1135
1136 if (fShowErrorCurve && viz::outerErr != nullptr) {
1137 SkPaint firstApproxPaint;
1138 firstApproxPaint.setStrokeWidth(4);
1139 firstApproxPaint.setStyle(SkPaint::kStroke_Style);
1140 firstApproxPaint.setColor(SK_ColorRED);
1141 canvas->drawPath(viz::outerFirstApprox, firstApproxPaint);
1142 drawErrorCurve(canvas, *viz::outerErr);
1143 }
1144 }
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1241
Definition: SkPath.h:59
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
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
Definition: switches.h:57

◆ load()

void VariableWidthStrokerSlide::load ( SkScalar  w,
SkScalar  h 
)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 1061 of file VariableWidthStrokerSlide.cpp.

1061{ fWinSize = {w, h}; }
SkScalar w
SkScalar h

◆ onChar()

bool VariableWidthStrokerSlide::onChar ( SkUnichar  uni)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 1065 of file VariableWidthStrokerSlide.cpp.

1065 {
1066 switch (uni) {
1067 case '0':
1068 this->toggle(fShowUI);
1069 return true;
1070 case '1':
1071 this->toggle(fShowSkeleton);
1072 return true;
1073 case '2':
1074 this->toggle(fShowHidden);
1075 return true;
1076 case '3':
1077 this->toggle(fShowStrokePoints);
1078 return true;
1079 case '4':
1080 this->toggle(fShowErrorCurve);
1081 return true;
1082 case '5':
1083 this->toggle(fLengthMetric);
1084 return true;
1085 case 'x':
1086 resetToDefaults();
1087 return true;
1088 case '-':
1089 fWidth -= 5;
1090 return true;
1091 case '=':
1092 fWidth += 5;
1093 return true;
1094 default:
1095 break;
1096 }
1097 return false;
1098 }

◆ onClick()

bool VariableWidthStrokerSlide::onClick ( ClickHandlerSlide::Click )
inlineoverrideprotectedvirtual

Override to track clicks. Return true as long as you want to track the pen/mouse.

Implements ClickHandlerSlide.

Definition at line 1161 of file VariableWidthStrokerSlide.cpp.

1161{ return false; }

◆ onFindClickHandler()

Click * VariableWidthStrokerSlide::onFindClickHandler ( SkScalar  x,
SkScalar  y,
skui::ModifierKey  modi 
)
inlineoverrideprotectedvirtual

Return a Click object to handle the click. onClick will be called repeatedly with the latest mouse state tracked on the Click object until it returns false.

Implements ClickHandlerSlide.

Definition at line 1147 of file VariableWidthStrokerSlide.cpp.

1147 {
1148 const SkScalar tol = 4;
1149 const SkRect r = SkRect::MakeXYWH(x - tol, y - tol, tol * 2, tol * 2);
1150 for (size_t i = 0; i < fPathPts.size(); ++i) {
1151 if (r.intersects(SkRect::MakeXYWH(fPathPts[i].fX, fPathPts[i].fY, 1, 1))) {
1152 return new Click([this, i](Click* c) {
1153 fPathPts[i] = c->fCurr;
1154 return true;
1155 });
1156 }
1157 }
1158 return nullptr;
1159 }
float SkScalar
Definition: extension.cpp:12
double y
double x
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
bool intersects(const SkRect &r) const
Definition: SkRect.h:1121

◆ resize()

void VariableWidthStrokerSlide::resize ( SkScalar  w,
SkScalar  h 
)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 1063 of file VariableWidthStrokerSlide.cpp.

1063{ fWinSize = {w, h}; }

The documentation for this class was generated from the following file: