Skia
2D Graphics Library
SkCubicMap.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkCubicMap_DEFINED
9 #define SkCubicMap_DEFINED
10 
11 #include "include/core/SkPoint.h"
12 
22 public:
24 
25  static bool IsLinear(SkPoint p1, SkPoint p2) {
26  return SkScalarNearlyEqual(p1.fX, p1.fY) && SkScalarNearlyEqual(p2.fX, p2.fY);
27  }
28 
29  float computeYFromX(float x) const;
30 
31  SkPoint computeFromT(float t) const;
32 
33 private:
34  enum Type {
35  kLine_Type, // x == y
36  kCubeRoot_Type, // At^3 == x
37  kSolver_Type, // general monotonic cubic solver
38  };
39 
40  SkPoint fCoeff[3];
41  Type fType;
42 };
43 
44 #endif
45 
SkCubicMap
Fast evaluation of a cubic ease-in / ease-out curve.
Definition: SkCubicMap.h:21
SkScalarNearlyEqual
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkScalar.h:142
SkCubicMap::SkCubicMap
SkCubicMap(SkPoint p1, SkPoint p2)
SkCubicMap::computeFromT
SkPoint computeFromT(float t) const
SkPoint
Definition: SkPoint.h:160
SK_API
#define SK_API
Definition: SkTypes.h:181
SkPoint::fY
SkScalar fY
y-axis value
Definition: SkPoint.h:162
SkPoint.h
SkPoint::fX
SkScalar fX
x-axis value
Definition: SkPoint.h:161
SkCubicMap::computeYFromX
float computeYFromX(float x) const
SkCubicMap::IsLinear
static bool IsLinear(SkPoint p1, SkPoint p2)
Definition: SkCubicMap.h:25