5#include "flutter/impeller/aiks/aiks_unittests.h"
10#include "third_party/imgui/imgui.h"
49 paint.stroke_width = 20.0;
60 paint.stroke_width = 25.0;
70 paint.stroke_width = 100.0;
82 paint.stroke_width = 200;
98 paint.stroke_width = 20;
101 builder.AddCubicCurve({0, 200}, {50, 400}, {350, 0}, {400, 200});
121 builder.AddRoundedRect(
Rect::MakeXYWH(100, 100, 200, 200), radii);
122 builder.AddCircle({200, 200}, 50);
126 std::make_shared<Image>(CreateTextureForFixture(
"boston.jpg")), {10, 10},
144 builder.MoveTo({50, 50});
145 builder.LineTo({50, 100});
146 builder.LineTo({100, 100});
147 builder.LineTo({100, 50});
152 paint.stroke_width = 10;
165 builder.MoveTo({50, 50});
166 builder.LineTo({520, 120});
167 builder.LineTo({300, 310});
168 builder.LineTo({100, 50});
174 paint.stroke_width = 10;
185 static float scale = 3;
186 static bool add_circle_clip =
true;
189 ImGuiWindowFlags_AlwaysAutoResize)) {
190 ImGui::ColorEdit4(
"Color",
reinterpret_cast<float*
>(&
color));
191 ImGui::SliderFloat(
"Scale", &
scale, 0, 6);
192 ImGui::Checkbox(
"Circle clip", &add_circle_clip);
197 canvas.
Scale(GetContentScale());
205 paint.stroke_width = 10;
209 .QuadraticCurveTo({60, 20}, {60, 60})
212 .QuadraticCurveTo({60, 60}, {20, 60})
217 if (add_circle_clip) {
222 auto [handle_a, handle_b] =
226 Point point_a = screen_to_canvas * handle_a * GetContentScale();
227 Point point_b = screen_to_canvas * handle_b * GetContentScale();
229 Point middle = (point_a + point_b) / 2;
235 paint.stroke_join = join;
237 paint.stroke_cap = cap;
247 ASSERT_TRUE(OpenPlaygroundHere(
callback));
252 canvas.
Scale(GetContentScale());
255 paint.stroke_width = 10;
259 paint.stroke_cap = cap;
260 Point origin = {100, 100};
264 for (
int d = 15;
d < 90;
d += 15) {
278 std::vector<Color> colors = {
279 Color{0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0},
280 Color{0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0},
281 Color{0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0},
282 Color{0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0},
283 Color{0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0},
284 Color{0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0},
285 Color{0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0}};
286 std::vector<Scalar> stops = {
296 auto texture = CreateTextureForFixture(
"airplane.jpg",
302 {100, 100}, 200, std::move(colors), std::move(stops),
319 paint.stroke_width = 10;
334 paint.stroke_width = 10;
347 for (
auto i = 0; i < 10; i++) {
349 builder.AddCircle(
Point(100 + 50 * i, 100 + 50 * i), 100);
351 builder.MoveTo({100.f + 50.f * i - 100, 100.f + 50.f * i});
352 builder.LineTo({100.f + 50.f * i, 100.f + 50.f * i - 100});
353 builder.LineTo({100.f + 50.f * i - 100, 100.f + 50.f * i - 100});
360 canvas.
DrawPath(builder.TakePath(), {.color = Color::Red().WithAlpha(0.4)});
367 canvas.
Scale(GetContentScale());
371 std::vector<Color> colors = {
Color{1.0, 0.0, 0.0, 1.0},
372 Color{0.0, 0.0, 0.0, 1.0}};
373 std::vector<Scalar> stops = {0.0, 1.0};
413 const Scalar kTriangleHeight = 100;
420 .
MoveTo({0, kTriangleHeight})
421 .
LineTo({-kTriangleHeight / 2.0f, 0})
422 .
LineTo({kTriangleHeight / 2.0f, 0})
426 kTriangleHeight, kTriangleHeight),
436 .
MoveTo({0, kTriangleHeight})
437 .
LineTo({-kTriangleHeight / 2.0f, 0})
439 .
LineTo({kTriangleHeight / 2.0f, 0})
443 kTriangleHeight, kTriangleHeight),
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
void DrawLine(const Point &p0, const Point &p1, const Paint &paint)
const Matrix & GetCurrentTransform() const
void ClipPath(const Path &path, Entity::ClipOperation clip_op=Entity::ClipOperation::kIntersect)
void Concat(const Matrix &transform)
void DrawImage(const std::shared_ptr< Image > &image, Point offset, const Paint &paint, SamplerDescriptor sampler={})
void DrawPaint(const Paint &paint)
void Scale(const Vector2 &scale)
Picture EndRecordingAsPicture()
void DrawPath(const Path &path, const Paint &paint)
void Translate(const Vector3 &offset)
void DrawCircle(const Point ¢er, Scalar radius, const Paint &paint)
static std::shared_ptr< ColorFilter > MakeBlend(BlendMode blend_mode, Color color)
static ColorSource MakeRadialGradient(Point center, Scalar radius, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeImage(std::shared_ptr< Texture > texture, Entity::TileMode x_tile_mode, Entity::TileMode y_tile_mode, SamplerDescriptor sampler_descriptor, Matrix effect_transform)
static ColorSource MakeSweepGradient(Point center, Degrees start_angle, Degrees end_angle, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
@ kNormal
Blurred inside and outside.
PathBuilder & AddRect(Rect rect)
Path TakePath(FillType fill=FillType::kNonZero)
PathBuilder & MoveTo(Point point, bool relative=false)
PathBuilder & AddCircle(const Point ¢er, Scalar radius)
PathBuilder & AddLine(const Point &p1, const Point &p2)
Move to point p1, then insert a line from p1 to p2.
PathBuilder & AddRoundedRect(Rect rect, RoundingRadii radii)
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
TEST_P(AiksTest, CanRenderAdvancedBlendColorFilterWithSaveLayer)
std::tuple< Point, Point > DrawPlaygroundLine(PlaygroundPoint &point_a, PlaygroundPoint &point_b)
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
void Close(PathBuilder *builder)
static constexpr Color Fuchsia()
static constexpr Color Black()
static constexpr Color White()
constexpr Color WithAlpha(Scalar new_alpha) const
static constexpr Color Red()
static constexpr Color AliceBlue()
static constexpr Color Blue()
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static Matrix MakeRotationZ(Radians r)
FilterContents::BlurStyle style
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
constexpr Type GetDistance(const TPoint &p) const
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TRect MakeSize(const TSize< U > &size)