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

Public Member Functions

 ArcToSlide ()
 
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 199 of file PathSlide.cpp.

Constructor & Destructor Documentation

◆ ArcToSlide()

ArcToSlide::ArcToSlide ( )
inline

Definition at line 208 of file PathSlide.cpp.

208 : fDoFrame(false), fDoCorner(false), fDoConic(false) {
209 SkRandom rand;
210 for (int i = 0; i < N; ++i) {
211 fPts[i].fX = 20 + rand.nextUScalar1() * 640;
212 fPts[i].fY = 20 + rand.nextUScalar1() * 480;
213 }
214
215 const SkScalar rad = 50;
216
217 fPtsPaint.setAntiAlias(true);
218 fPtsPaint.setStrokeWidth(15);
220
221 fCornerPaint.setAntiAlias(true);
222 fCornerPaint.setStyle(SkPaint::kStroke_Style);
223 fCornerPaint.setStrokeWidth(13);
224 fCornerPaint.setColor(SK_ColorGREEN);
225 fCornerPaint.setPathEffect(SkCornerPathEffect::Make(rad*2));
226
227 fSkeletonPaint.setAntiAlias(true);
228 fSkeletonPaint.setStyle(SkPaint::kStroke_Style);
229 fSkeletonPaint.setColor(SK_ColorRED);
230
231 fName = "ArcTo";
232 }
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
static sk_sp< SkPathEffect > Make(SkScalar radius)
@ 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 setPathEffect(sk_sp< SkPathEffect > pathEffect)
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
SkScalar nextUScalar1()
Definition: SkRandom.h:101
SkString fName
Definition: Slide.h:54
float SkScalar
Definition: extension.cpp:12
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

Member Function Documentation

◆ draw()

void ArcToSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 243 of file PathSlide.cpp.

243 {
244 canvas->drawPoints(SkCanvas::kPoints_PointMode, N, fPts, fPtsPaint);
245
246 SkPath path;
247 this->makePath(&path);
248
249 if (fDoCorner) {
250 canvas->drawPath(path, fCornerPaint);
251 }
252
253 canvas->drawPath(path, fSkeletonPaint);
254 }
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710
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
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

◆ onChar()

bool ArcToSlide::onChar ( SkUnichar  uni)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 234 of file PathSlide.cpp.

234 {
235 switch (uni) {
236 case '1': this->toggle(fDoFrame); return true;
237 case '2': this->toggle(fDoCorner); return true;
238 case '3': this->toggle(fDoConic); return true;
239 default: break;
240 }
241 return false;
242 }

◆ onClick()

bool ArcToSlide::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 271 of file PathSlide.cpp.

271{ return false; }

◆ onFindClickHandler()

Click * ArcToSlide::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 257 of file PathSlide.cpp.

257 {
258 const SkScalar tol = 4;
259 const SkRect r = SkRect::MakeXYWH(x - tol, y - tol, tol * 2, tol * 2);
260 for (int i = 0; i < N; ++i) {
261 if (r.intersects(SkRect::MakeXYWH(fPts[i].fX, fPts[i].fY, 1, 1))) {
262 return new Click([this, i](Click* c) {
263 fPts[i] = c->fCurr;
264 return true;
265 });
266 }
267 }
268 return nullptr;
269 }
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

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