Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
HalfPlaneCoonsSlide Class Reference

Inherits CameraSlide.

Public Member Functions

 HalfPlaneCoonsSlide ()
 
void load (SkScalar w, SkScalar h) override
 
void draw (SkCanvas *canvas) override
 
bool onChar (SkUnichar uni) override
 

Protected Member Functions

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

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"; }
const char * fName

Member Function Documentation

◆ draw()

void HalfPlaneCoonsSlide::draw ( SkCanvas canvas)
inlineoverride

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
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710
void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint)
Definition: SkCanvas.cpp:2529
void restore()
Definition: SkCanvas.cpp:461
int save()
Definition: SkCanvas.cpp:447
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1241
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
const Paint & paint
Definition: color_source.cc:38

◆ load()

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

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
SkSamplingOptions(SkFilterMode::kLinear))

◆ onChar()

bool HalfPlaneCoonsSlide::onChar ( SkUnichar  uni)
inlineoverride

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
Definition: ClipSlide.cpp:475

◆ onClick()

bool HalfPlaneCoonsSlide::onClick ( Click *  click)
inlineoverrideprotected

Definition at line 651 of file ClipSlide.cpp.

651{ return false; }

◆ onFindClickHandler()

Click * HalfPlaneCoonsSlide::onFindClickHandler ( SkScalar  x,
SkScalar  y,
skui::ModifierKey  modi 
)
inlineoverrideprotected

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: