51static float sat(
float r,
float g,
float b) {
return max(r,g,
b) -
min(r,g,
b); }
52static float lum(
float r,
float g,
float b) {
return r*0.30f + g*0.59f +
b*0.11f; }
57static void set_sat(
float* r,
float* g,
float*
b,
float s) {
58 float mn =
min(*r,*g,*
b),
60 auto channel = [=](
float c) {
62 : (c - mn) *
s / (mx - mn);
69 float l =
lum(*r,*g,*
b),
72 auto clip = [=](
float c) {
73 if (mn < 0) { c = l + (c - l) * ( l) / (l - mn); }
74 if (mx > 1) { c = l + (c - l) * (1 - l) / (mx - l); }
83static void set_lum(
float* r,
float* g,
float*
b,
float l) {
84 float diff = l -
lum(*r,*g,*
b);
93 float* sr,
float* sg,
float* sb) {
106 float* sr,
float* sg,
float* sb) {
119 float* sr,
float* sg,
float* sb) {
131 float* sr,
float* sg,
float* sb) {
143 void (*
mode)(
float,
float,
float,
float*,
float*,
float*)) {
149 s = SkColor4f::FromColor(
src);
152 &
s.fR, &
s.fG, &
s.fB);
154 return s.toSkColor();
161 const char* comment =
"HSL blend modes are correct when you see no circles in the squares.";
162 canvas->drawString(comment, 10,10,
font,
paint);
181 canvas->drawRect({20,20,80,80}, bg);
184 canvas->drawRect({20,20,80,80}, fg);
186 if (
test.reference) {
189 canvas->drawCircle(50,50, 20, ref);
194 canvas->translate(100,0);
204 0xFF00CCCC, 0xFF0000CC, 0xFFCC00CC, 0xFFCC0000, 0xFFCCCC00, 0xFF00CC00,
217 canvas->translate(10, 50);
218 canvas->scale(0.5f, 0.5f);
235 for (
auto [_,
name] : recs) {
238 canvas->translate(r.
width() + 10, 0);
242 for (
SkScalar src_a : {1.0f, 0.5f}) {
244 for (
auto [
mode, _] : recs) {
247 canvas->drawRect(r,
p);
249 p.setShader(
nullptr);
250 p.setBlendMode(
mode);
254 canvas->translate(r.
width() + 10, 0);
257 str.
printf(
"alpha %g", src_a);
262 canvas->translate(0, r.
height() + 10);
SK_API const char * SkBlendMode_Name(SkBlendMode blendMode)
@ kSaturation
saturation of source with hue and luminosity of destination
@ kHue
hue of source with saturation and luminosity of destination
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kColor
hue and saturation of source with luminosity of destination
#define SkColorGetA(color)
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
@ kAntiAlias
may have transparent pixels on glyph edges
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
void setColor(SkColor color)
void setBlendMode(SkBlendMode mode)
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
static void set_sat(float *r, float *g, float *b, float s)
static SkColor blend(SkColor dst, SkColor src, void(*mode)(float, float, float, float *, float *, float *))
static void color(float dr, float dg, float db, float *sr, float *sg, float *sb)
static float sat(float r, float g, float b)
static void luminosity(float dr, float dg, float db, float *sr, float *sg, float *sb)
static void hue(float dr, float dg, float db, float *sr, float *sg, float *sb)
static void saturation(float dr, float dg, float db, float *sr, float *sg, float *sb)
static float max(float r, float g, float b)
DEF_SIMPLE_GM(hsl, canvas, 600, 100)
static void clip_color(float *r, float *g, float *b)
static sk_sp< SkShader > make_grad(SkScalar width)
static float lum(float r, float g, float b)
static float min(float r, float g, float b)
static void set_lum(float *r, float *g, float *b, float l)
PODArray< SkColor > colors
DEF_SWITCHES_START aot vmservice shared library name
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
font
Font Metadata and Metrics.
SkSamplingOptions(SkFilterMode::kLinear))
static SkRect MakeIWH(int w, int h)
constexpr float height() const
constexpr float width() const