54 auto dl = builder.
Build();
55 ASSERT_TRUE(OpenPlaygroundHere(dl));
68 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
80 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
92 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
104 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
119 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
136 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
156 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
161 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
206 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
211 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
261 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
268 auto callback = [&]() -> sk_sp<DisplayList> {
270 ImGuiWindowFlags_AlwaysAutoResize)) {
271 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
272 ImGui::SliderFloat(
"Rotate", &rotation, 0, 90);
273 ImGui::SliderFloat(
"Offset", &offset, 0, 2);
278 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
289 builder.
Scale(scale, scale);
293 for (
int i = 0;
i < 5; ++
i) {
294 Scalar yoffset =
i * 25.25f + 300.f;
302 return builder.
Build();
305 ASSERT_TRUE(OpenPlaygroundHere(
callback));
312 auto callback = [&]() -> sk_sp<DisplayList> {
314 ImGuiWindowFlags_AlwaysAutoResize)) {
315 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
316 ImGui::SliderFloat(
"Rotate", &rotation, 0, 90);
317 ImGui::SliderFloat(
"Offset", &offset, 0, 2);
322 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
330 builder.
Scale(scale, scale);
334 for (
int i = 0;
i < 5; ++
i) {
335 Scalar yoffset =
i * 25.25f + 300.f;
340 return builder.
Build();
343 ASSERT_TRUE(OpenPlaygroundHere(
callback));
348 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
368 reference_builder.
MoveTo(component.p1);
369 constexpr int N = 100;
370 for (
int i = 1;
i < N;
i++) {
371 reference_builder.
LineTo(component.Solve(
static_cast<Scalar>(
i) / N));
373 reference_builder.
LineTo(component.p2);
392 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
403 .top_right = {25, 50},
404 .bottom_left = {25, 50},
405 .bottom_right = {50, 25},
422 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
448 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
461 path_builder.
Close();
470 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
475 auto callback = [&]() -> sk_sp<DisplayList> {
477 static float scale = 3;
478 static bool add_circle_clip =
true;
481 ImGuiWindowFlags_AlwaysAutoResize)) {
482 ImGui::ColorEdit4(
"Color",
reinterpret_cast<float*
>(&color));
483 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
484 ImGui::Checkbox(
"Circle clip", &add_circle_clip);
489 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
503 path_builder.
Close();
508 builder.
Scale(scale, scale);
510 if (add_circle_clip) {
515 auto [handle_a, handle_b] =
522 screen_to_canvas = screen_to_canvas.
Invert();
524 Point point_a = screen_to_canvas * handle_a;
525 Point point_b = screen_to_canvas * handle_b;
527 Point middle = point_a + point_b;
528 middle *= GetContentScale().
x / 2;
530 auto radius = point_a.GetDistance(middle);
536 {DlStrokeJoin::kBevel, DlStrokeJoin::kRound, DlStrokeJoin::kMiter}) {
539 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
547 return builder.
Build();
550 ASSERT_TRUE(OpenPlaygroundHere(
callback));
555 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
561 auto draw = [&builder](
DlPaint& paint) {
563 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
567 for (
int d = 15;
d < 90;
d += 15) {
569 Point origin = {100, 100};
572 auto a = origin + m * p0;
573 auto b = origin + m * p1;
587 std::vector<DlColor> colors = {
595 std::vector<Scalar> stops = {
606 CreateTextureForFixture(
"airplane.jpg",
612 colors.data(), stops.data(),
613 DlTileMode::kMirror));
618 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
619 DlImageSampling::kMipmapLinear, &matrix));
622 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
631 auto callback = [&]() -> sk_sp<DisplayList> {
633 ImGuiWindowFlags_AlwaysAutoResize)) {
634 ImGui::SliderFloat(
"Scale", &scale, 0.001, 5);
635 ImGui::SliderFloat(
"Width", &line_width, 1, 20);
640 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
654 builder.
Scale(scale, scale);
668 builder.
Scale(0.2, 0.2);
675 return builder.
Build();
677 ASSERT_TRUE(OpenPlaygroundHere(
callback));
682 float line_width = 10.f;
683 float rotation = 0.f;
685 auto callback = [&]() -> sk_sp<DisplayList> {
687 ImGuiWindowFlags_AlwaysAutoResize)) {
689 ImGui::SliderFloat(
"Scale", &scale, 0.001f, 5.0f);
690 ImGui::SliderFloat(
"Width", &line_width, 1.0f, 20.0f);
691 ImGui::SliderFloat(
"Rotation", &rotation, 0.0f, 180.0f);
696 builder.
Scale(
static_cast<float>(GetContentScale().
x),
697 static_cast<float>(GetContentScale().
y));
711 float r_sin60 = r * std::sqrt(3.0f) / 2.0f;
712 float r_cos60 = r / 2.0f;
722 DlPoint(cx + r_cos60, cy + r_sin60);
726 builder.
Scale(scale, scale);
730 builder.
DrawLine(v0, v1, hex_paint);
731 builder.
DrawLine(v1, v2, hex_paint);
732 builder.
DrawLine(v2, v3, hex_paint);
733 builder.
DrawLine(v3, v4, hex_paint);
734 builder.
DrawLine(v4, v5, hex_paint);
735 builder.
DrawLine(v5, v0, hex_paint);
738 return builder.
Build();
740 ASSERT_TRUE(OpenPlaygroundHere(
callback));
745 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
753 auto draw = [&builder](
DlPaint& paint) {
755 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
759 for (
int d = 15;
d < 90;
d += 15) {
761 Point origin = {100, 100};
764 auto a = origin + m * p0;
765 auto b = origin + m * p1;
781 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
794 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
808 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
813 for (
auto i = 0;
i < 10;
i++) {
820 path_builder.
Close();
822 path_builder.
MoveTo(
DlPoint(100.f + 50.f *
i - 100, 100.f + 50.f *
i));
823 path_builder.
LineTo(
DlPoint(100.f + 50.f *
i, 100.f + 50.f *
i - 100));
825 100.f + 50.f *
i - 100));
826 path_builder.
Close();
836 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
841 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
846 std::vector<DlColor> colors = {
DlColor::RGBA(1.0, 0.0, 0.0, 1.0),
848 std::vector<Scalar> stops = {0.0, 1.0};
852 stops.data(), DlTileMode::kMirror));
872 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
880 auto callback = [&]() -> sk_sp<DisplayList> {
882 ImGuiWindowFlags_AlwaysAutoResize)) {
883 ImGui::SliderFloat(
"Stroke Width", &stroke_width, 1, 300);
884 ImGui::SliderFloat(
"Aspect", &aspect, 0.5, 2.0);
885 ImGui::SliderFloat(
"Start Angle", &start_angle, 0, 360);
886 ImGui::SliderFloat(
"End Angle", &end_angle, 0, 360);
904 builder.
DrawArc(rect, start_angle, end_angle,
906 DlScalar frontier = rect.GetRight() + stroke_width / 2.0;
909 return builder.
Build();
911 ASSERT_TRUE(OpenPlaygroundHere(
callback));
922 .top_right =
DlSize(50, 50),
923 .bottom_left =
DlSize(50, 50),
924 .bottom_right =
DlSize(50, 50),
927 const Scalar kTriangleHeight = 100;
930 kTriangleHeight, kTriangleHeight),
945 path_builder.
Close();
946 path_builder.
AddPath(rrect_path);
958 path_builder.
Close();
959 path_builder.
AddPath(rrect_path);
964 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
984 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
989 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
994 for (
auto cap : std::vector<DlStrokeCap>{
995 DlStrokeCap::kButt, DlStrokeCap::kRound, DlStrokeCap::kSquare}) {
997 path_builder.
MoveTo({20, 50});
998 path_builder.
LineTo({50, 50});
999 path_builder.
MoveTo({120, 50});
1000 path_builder.
LineTo({120, 80});
1001 path_builder.
MoveTo({180, 50});
1002 path_builder.
LineTo({180, 50});
1027 for (
auto join : std::vector<DlStrokeJoin>{
1028 DlStrokeJoin::kBevel, DlStrokeJoin::kRound, DlStrokeJoin::kMiter}) {
1030 path_builder.
MoveTo({20, 50});
1031 path_builder.
LineTo({50, 50});
1032 path_builder.
LineTo({80, 50});
1033 path_builder.
MoveTo({20, 150});
1034 path_builder.
LineTo({50, 150});
1035 path_builder.
LineTo({50, 180});
1036 path_builder.
MoveTo({20, 250});
1037 path_builder.
LineTo({50, 250});
1038 path_builder.
LineTo({70, 270});
1039 path_builder.
MoveTo({20, 350});
1040 path_builder.
LineTo({50, 350});
1041 path_builder.
LineTo({30, 370});
1042 path_builder.
MoveTo({20, 450});
1043 path_builder.
LineTo({50, 450});
1044 path_builder.
LineTo({20, 450});
1045 path_builder.
MoveTo({120, 80});
1046 path_builder.
LineTo({150, 80});
1047 path_builder.
LineTo({180, 80});
1048 path_builder.
MoveTo({120, 180});
1049 path_builder.
LineTo({150, 180});
1050 path_builder.
LineTo({150, 150});
1051 path_builder.
MoveTo({120, 280});
1052 path_builder.
LineTo({150, 280});
1053 path_builder.
LineTo({170, 260});
1054 path_builder.
MoveTo({120, 380});
1055 path_builder.
LineTo({150, 380});
1056 path_builder.
LineTo({130, 360});
1057 path_builder.
MoveTo({120, 480});
1058 path_builder.
LineTo({150, 480});
1059 path_builder.
LineTo({120, 480});
1080 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1093 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
void DrawArc(const DlRect &bounds, DlScalar start, DlScalar sweep, bool useCenter, const DlPaint &paint) override
void DrawImage(const sk_sp< DlImage > &image, const DlPoint &point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
DlMatrix GetMatrix() const override
void DrawCircle(const DlPoint ¢er, DlScalar radius, const DlPaint &paint) override
void DrawLine(const DlPoint &p0, const DlPoint &p1, const DlPaint &paint) override
void Rotate(DlScalar degrees) override
void Scale(DlScalar sx, DlScalar sy) override
void Translate(DlScalar tx, DlScalar ty) override
void DrawPaint(const DlPaint &paint) override
sk_sp< DisplayList > Build()
void DrawPath(const DlPath &path, const DlPaint &paint) override
void ClipPath(const DlPath &path, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void Transform(const DlMatrix &matrix) override
void DrawRect(const DlRect &rect, const DlPaint &paint) override
static std::shared_ptr< DlMaskFilter > Make(DlBlurStyle style, SkScalar sigma, bool respect_ctm=true)
static std::shared_ptr< const DlColorFilter > MakeBlend(DlColor color, DlBlendMode mode)
static std::shared_ptr< DlColorSource > MakeSweep(DlPoint center, DlScalar start, DlScalar end, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeImage(const sk_sp< const DlImage > &image, DlTileMode horizontal_tile_mode, DlTileMode vertical_tile_mode, DlImageSampling sampling=DlImageSampling::kLinear, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeRadial(DlPoint center, DlScalar radius, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
DlPaint & setColor(DlColor color)
DlPaint & setStrokeCap(DlStrokeCap cap)
DlPaint & setStrokeWidth(float width)
DlPaint & setMaskFilter(std::nullptr_t filter)
DlPaint & setDrawStyle(DlDrawStyle style)
DlPaint & setStrokeJoin(DlStrokeJoin join)
DlPaint & setColorFilter(std::nullptr_t filter)
DlPaint & setColorSource(std::nullptr_t source)
DlPathBuilder & LineTo(DlPoint p2)
Draw a line from the current point to the indicated point p2.
DlPathBuilder & AddPath(const DlPath &path)
Append the provided path to this path as if the commands used to construct it were repeated on this p...
static constexpr const DlScalar kArcApproximationMagic
DlPathBuilder & MoveTo(DlPoint p2)
Start a new contour that will originate at the indicated point p2.
DlPathBuilder & SetFillType(DlPathFillType fill_type)
Set the fill type that should be used to determine the interior of this path to the indicated |fill_t...
const DlPath TakePath()
Returns the path constructed by this path builder and resets its internal state to the default state ...
DlPathBuilder & ConicCurveTo(DlPoint cp, DlPoint p2, DlScalar weight)
Draw a conic curve (a rational quadratic bezier curve) from the current point to the indicated point ...
DlPathBuilder & QuadraticCurveTo(DlPoint cp, DlPoint p2)
Draw a quadratic bezier curve from the current point to the indicated point p2, using the indicated p...
DlPathBuilder & Close()
The path is closed back to the location of the most recent MoveTo call. Contours that are filled are ...
DlPathBuilder & AddArc(const DlRect &bounds, DlDegrees start, DlDegrees sweep, bool use_center=false)
Append an arc contour to the path which:
DlPathBuilder & CubicCurveTo(DlPoint cp1, DlPoint cp2, DlPoint p2)
Draw a cubic bezier curve from the current point to the indicated point p2, using the indicated point...
static DlPath MakeLine(const DlPoint a, const DlPoint b)
static DlPath MakeRoundRect(const DlRoundRect &rrect)
static DlPath MakeCircle(const DlPoint center, DlScalar radius)
static DlPath MakeArc(const DlRect &bounds, DlDegrees start, DlDegrees sweep, bool use_center)
static DlPath MakeRect(const DlRect &rect)
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
FlutterDesktopBinaryReply callback
impeller::Scalar DlScalar
impeller::Degrees DlDegrees
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
TEST_P(AiksTest, DrawAtlasNoColor)
std::tuple< Point, Point > DrawPlaygroundLine(PlaygroundPoint &point_a, PlaygroundPoint &point_b)
constexpr float kSqrt2Over2
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor RGBA(DlScalar r, DlScalar g, DlScalar b, DlScalar a)
Construct a 32 bit color from floating point R, G, B, and A color channels.
static constexpr DlColor kBlack()
static constexpr DlColor ARGB(DlScalar a, DlScalar r, DlScalar g, DlScalar b)
Construct a 32 bit color from floating point A, R, G, and B color channels.
static constexpr DlColor kYellow()
static constexpr DlColor kFuchsia()
static constexpr DlColor kAliceBlue()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
static constexpr DlColor kGreenYellow()
static constexpr Color Black()
constexpr Color WithAlpha(Scalar new_alpha) const
static constexpr Color Red()
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
bool IsInvertible() const
static Matrix MakeRotationZ(Radians r)
static RoundRect MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TRect MakeSize(const TSize< U > &size)