Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
convexpolyclip.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkClipOp.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPathBuilder.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"

Go to the source code of this file.

Classes

class  skiagm::ConvexPolyClip
 

Namespaces

namespace  skiagm
 

Functions

static sk_sp< SkImagemake_img (int w, int h)
 

Function Documentation

◆ make_img()

static sk_sp< SkImage > make_img ( int  w,
int  h 
)
static

Definition at line 31 of file convexpolyclip.cpp.

31 {
33 auto canvas = surf->getCanvas();
34
35 SkScalar wScalar = SkIntToScalar(w);
36 SkScalar hScalar = SkIntToScalar(h);
37
38 SkPoint pt = { wScalar / 2, hScalar / 2 };
39
40 SkScalar radius = 3 * std::max(wScalar, hScalar);
41
43 ToolUtils::color_to_565(0xFF222255),
44 ToolUtils::color_to_565(0xFF331133),
45 ToolUtils::color_to_565(0xFF884422),
46 ToolUtils::color_to_565(0xFF000022),
48 ToolUtils::color_to_565(0xFFAABBCC)};
49
50 SkScalar pos[] = {0,
51 SK_Scalar1 / 6,
52 2 * SK_Scalar1 / 6,
53 3 * SK_Scalar1 / 6,
54 4 * SK_Scalar1 / 6,
55 5 * SK_Scalar1 / 6,
57
59 SkRect rect = SkRect::MakeWH(wScalar, hScalar);
60 SkMatrix mat = SkMatrix::I();
61 for (int i = 0; i < 4; ++i) {
63 pt, radius,
64 colors, pos,
65 std::size(colors),
67 0, &mat));
68 canvas->drawRect(rect, paint);
69 rect.inset(wScalar / 8, hScalar / 8);
70 mat.preTranslate(6 * wScalar, 6 * hScalar);
71 mat.postScale(SK_Scalar1 / 3, SK_Scalar1 / 3);
72 }
73
75
76 paint.setShader(nullptr);
77 paint.setColor(SK_ColorLTGRAY);
78 constexpr char kTxt[] = "Skia";
79 SkPoint texPos = { wScalar / 17, hScalar / 2 + font.getSize() / 2.5f };
80 canvas->drawSimpleText(kTxt, std::size(kTxt)-1, SkTextEncoding::kUTF8,
81 texPos.fX, texPos.fY, font, paint);
82 paint.setColor(SK_ColorBLACK);
84 paint.setStrokeWidth(SK_Scalar1);
85 canvas->drawSimpleText(kTxt, std::size(kTxt)-1, SkTextEncoding::kUTF8,
86 texPos.fX, texPos.fY, font, paint);
87 return surf->makeImageSnapshot();
88}
SkPoint pos
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
constexpr SkColor SK_ColorLTGRAY
Definition SkColor.h:118
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
constexpr SkColor SK_ColorDKGRAY
Definition SkColor.h:108
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define SK_Scalar1
Definition SkScalar.h:18
#define SkIntToScalar(x)
Definition SkScalar.h:57
static sk_sp< SkShader > MakeRadial(const SkPoint &center, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:360
static const SkMatrix & I()
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:263
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
const Paint & paint
float SkScalar
Definition extension.cpp:12
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350
PODArray< SkColor > colors
Definition SkRecords.h:276
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
sk_sp< SkTypeface > DefaultPortableTypeface()
SkColor color_to_565(SkColor color)
font
Font Metadata and Metrics.
SkScalar w
SkScalar h
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
float fX
x-axis value
float fY
y-axis value
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609