Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
HalfPlaneCoonsSlide Class Reference
Inheritance diagram for HalfPlaneCoonsSlide:
CameraSlide Slide ClickHandlerSlide SkRefCnt Slide SkRefCntBase SkRefCnt SkRefCntBase

Public Member Functions

 HalfPlaneCoonsSlide ()
 
void load (SkScalar w, SkScalar h) override
 
void draw (SkCanvas *canvas) override
 
bool onChar (SkUnichar uni) override
 
- Public Member Functions inherited from CameraSlide
SkM44 get44 (const SkRect &r) const
 
- Public Member Functions inherited from Slide
virtual SkISize getDimensions () const
 
virtual void gpuTeardown ()
 
virtual bool animate (double nanos)
 
virtual void resize (SkScalar winWidth, SkScalar winHeight)
 
virtual void unload ()
 
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
 
- Public Member Functions inherited from ClickHandlerSlide
bool onMouse (SkScalar x, SkScalar y, skui::InputState clickState, skui::ModifierKey modifierKeys) final
 

Protected Member Functions

ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi) override
 
bool onClick (Click *click) override
 

Additional Inherited Members

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 562 of file ClipSlide.cpp.

Constructor & Destructor Documentation

◆ HalfPlaneCoonsSlide()

HalfPlaneCoonsSlide::HalfPlaneCoonsSlide ( )
inline

Definition at line 573 of file ClipSlide.cpp.

573{ fName = "halfplane-coons"; }
SkString fName
Definition Slide.h:54

Member Function Documentation

◆ draw()

void HalfPlaneCoonsSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 593 of file ClipSlide.cpp.

593 {
595
596 canvas->save();
597 canvas->concat(this->get44({0, 0, 300, 300}));
598
599 const SkPoint* tex = nullptr;
600 const SkColor* col = nullptr;
601 if (!fShowSkeleton) {
602 if (fShowTex) {
603 paint.setShader(fShader);
604 tex = fTex;
605 } else {
606 col = fColors;
607 }
608 }
609 canvas->drawPatch(fPatch, col, tex, SkBlendMode::kSrc, paint);
610 paint.setShader(nullptr);
611
612 if (fShowHandles) {
613 paint.setAntiAlias(true);
614 paint.setStrokeCap(SkPaint::kRound_Cap);
615 paint.setStrokeWidth(8);
616 canvas->drawPoints(SkCanvas::kPoints_PointMode, 12, fPatch, paint);
617 paint.setColor(SK_ColorWHITE);
618 paint.setStrokeWidth(6);
619 canvas->drawPoints(SkCanvas::kPoints_PointMode, 12, fPatch, paint);
620 }
621
622 canvas->restore();
623 }
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
SkM44 get44(const SkRect &r) const
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint)
void restore()
Definition SkCanvas.cpp:465
int save()
Definition SkCanvas.cpp:451
void concat(const SkMatrix &matrix)
@ kPoints_PointMode
draw each point separately
Definition SkCanvas.h:1241
@ kRound_Cap
adds circle
Definition SkPaint.h:335
const Paint & paint

◆ load()

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

Reimplemented from Slide.

Definition at line 575 of file ClipSlide.cpp.

575 {
576 fPatch[0] = { 0, 0 };
577 fPatch[1] = { 100, 0 };
578 fPatch[2] = { 200, 0 };
579 fPatch[3] = { 300, 0 };
580 fPatch[4] = { 300, 100 };
581 fPatch[5] = { 300, 200 };
582 fPatch[6] = { 300, 300 };
583 fPatch[7] = { 200, 300 };
584 fPatch[8] = { 100, 300 };
585 fPatch[9] = { 0, 300 };
586 fPatch[10] = { 0, 200 };
587 fPatch[11] = { 0, 100 };
588
589 fShader = ToolUtils::GetResourceAsImage("images/mandrill_256.png")
591 }
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition SkImage.cpp:179
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition DecodeUtils.h:25

◆ onChar()

bool HalfPlaneCoonsSlide::onChar ( SkUnichar  uni)
inlineoverridevirtual

Reimplemented from CameraSlide.

Definition at line 625 of file ClipSlide.cpp.

625 {
626 switch (uni) {
627 case 'h': fShowHandles = !fShowHandles; return true;
628 case 'k': fShowSkeleton = !fShowSkeleton; return true;
629 case 't': fShowTex = !fShowTex; return true;
630 default: break;
631 }
632 return this->CameraSlide::onChar(uni);
633 }
bool onChar(SkUnichar uni) override

◆ onClick()

bool HalfPlaneCoonsSlide::onClick ( Click )
inlineoverrideprotectedvirtual

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

Implements ClickHandlerSlide.

Definition at line 651 of file ClipSlide.cpp.

651{ return false; }

◆ onFindClickHandler()

Click * HalfPlaneCoonsSlide::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 636 of file ClipSlide.cpp.

636 {
637 auto dist = [](SkPoint a, SkPoint b) { return (b - a).length(); };
638
639 const float tol = 15;
640 for (int i = 0; i < 12; ++i) {
641 if (dist({x,y}, fPatch[i]) <= tol) {
642 return new Click([this, i](Click* c) {
643 fPatch[i] = c->fCurr;
644 return true;
645 });
646 }
647 }
648 return nullptr;
649 }
static bool b
struct MyStruct a[10]
double y
double x

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