Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | List of all members
GlyphTransformView Class Reference
Inheritance diagram for GlyphTransformView:
Slide SkRefCnt SkRefCntBase

Public Member Functions

 GlyphTransformView ()
 
void load (SkScalar w, SkScalar h) override
 
void resize (SkScalar w, SkScalar h) override
 
void draw (SkCanvas *canvas) override
 
bool animate (double nanos) override
 
- 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
 

Additional Inherited Members

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 24 of file GlyphTransformSlide.cpp.

Constructor & Destructor Documentation

◆ GlyphTransformView()

GlyphTransformView::GlyphTransformView ( )
inline

Definition at line 26 of file GlyphTransformSlide.cpp.

26{ fName = "Glyph Transform"; }
SkString fName
Definition: Slide.h:54

Member Function Documentation

◆ animate()

bool GlyphTransformView::animate ( double  nanos)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 57 of file GlyphTransformSlide.cpp.

57 {
58 constexpr SkScalar maxt = 100000;
59 double t = TimeUtils::PingPong(1e-9 * nanos, 20, 0, 0, maxt); // d3 t is in milliseconds
60
61 fTranslate.set(sin(t / 3000) - t * fSize.width() * 0.7 / maxt, sin(t / 999) / t);
62 fScale = 4.5 - std::sqrt(t) / 99;
63 fRotate = sin(t / 734);
64
65 return true;
66 }
float SkScalar
Definition: extension.cpp:12
static float PingPong(double time, float period, float phase, float ends, float mid)
Definition: TimeUtils.h:37
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition: SkVx.h:706
void set(float x, float y)
Definition: SkPoint_impl.h:200
SkScalar width() const
Definition: SkSize.h:76

◆ draw()

void GlyphTransformView::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 35 of file GlyphTransformSlide.cpp.

35 {
37
38 SkFont font(fEmojiFont.typeface);
39 const char* text = fEmojiFont.sampleText;
40
41 double baseline = fSize.height() / 2;
42 canvas->drawLine(0, baseline, fSize.width(), baseline, paint);
43
44 SkMatrix ctm;
45 ctm.setRotate(fRotate); // d3 rotate takes degrees
46 ctm.postScale(fScale * 4, fScale * 4);
47 ctm.postTranslate(fTranslate.fX + fSize.width() * 0.8, fTranslate.fY + baseline);
48 canvas->concat(ctm);
49
50 // d3 by default anchors text around the middle
52 font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
53 canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, -bounds.centerX(), -bounds.centerY(),
54 font, paint);
55 }
@ kUTF8
uses bytes to represent UTF-8 or ASCII
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.cpp:2413
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
Definition: SkFont.h:35
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:281
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:360
SkMatrix & setRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:452
const Paint & paint
Definition: color_source.cc:38
std::u16string text
Optional< SkRect > bounds
Definition: SkRecords.h:189
font
Font Metadata and Metrics.
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
SkScalar height() const
Definition: SkSize.h:77
sk_sp< SkTypeface > typeface
Definition: FontToolUtils.h:48

◆ load()

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

Reimplemented from Slide.

Definition at line 28 of file GlyphTransformSlide.cpp.

28 {
29 fEmojiFont = ToolUtils::EmojiSample();
30 fSize = {w, h};
31 }
EmojiTestSample EmojiSample()
SkScalar w
SkScalar h

◆ resize()

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

Reimplemented from Slide.

Definition at line 33 of file GlyphTransformSlide.cpp.

33{ fSize = {w, h}; }

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