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()));
269 auto callback = [&]() -> sk_sp<DisplayList> {
271 ImGuiWindowFlags_AlwaysAutoResize)) {
272 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
273 ImGui::SliderFloat(
"Rotate", &rotation, 0, 90);
274 ImGui::SliderFloat(
"Offset", &offset, 0, 2);
275 ImGui::SliderFloat(
"Width", &
width, 0, 2);
280 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
291 builder.
Scale(scale, scale);
295 for (
int i = 0;
i < 5; ++
i) {
296 Scalar yoffset =
i * 25.25f + 300.f;
304 return builder.
Build();
307 ASSERT_TRUE(OpenPlaygroundHere(
callback));
314 auto callback = [&]() -> sk_sp<DisplayList> {
316 ImGuiWindowFlags_AlwaysAutoResize)) {
317 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
318 ImGui::SliderFloat(
"Rotate", &rotation, 0, 90);
319 ImGui::SliderFloat(
"Offset", &offset, 0, 2);
324 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
332 builder.
Scale(scale, scale);
336 for (
int i = 0;
i < 5; ++
i) {
337 Scalar yoffset =
i * 25.25f + 300.f;
342 return builder.
Build();
345 ASSERT_TRUE(OpenPlaygroundHere(
callback));
350 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
370 reference_builder.
MoveTo(component.p1);
371 constexpr int N = 100;
372 for (
int i = 1;
i < N;
i++) {
373 reference_builder.
LineTo(component.Solve(
static_cast<Scalar>(
i) / N));
375 reference_builder.
LineTo(component.p2);
394 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
405 .top_right = {25, 50},
406 .bottom_left = {25, 50},
407 .bottom_right = {50, 25},
424 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
450 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
463 path_builder.
Close();
472 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
477 auto callback = [&]() -> sk_sp<DisplayList> {
479 static float scale = 3;
480 static bool add_circle_clip =
true;
483 ImGuiWindowFlags_AlwaysAutoResize)) {
484 ImGui::ColorEdit4(
"Color",
reinterpret_cast<float*
>(&color));
485 ImGui::SliderFloat(
"Scale", &scale, 0, 6);
486 ImGui::Checkbox(
"Circle clip", &add_circle_clip);
491 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
505 path_builder.
Close();
510 builder.
Scale(scale, scale);
512 if (add_circle_clip) {
517 auto [handle_a, handle_b] =
524 screen_to_canvas = screen_to_canvas.
Invert();
526 Point point_a = screen_to_canvas * handle_a;
527 Point point_b = screen_to_canvas * handle_b;
529 Point middle = point_a + point_b;
530 middle *= GetContentScale().
x / 2;
532 auto radius = point_a.GetDistance(middle);
538 {DlStrokeJoin::kBevel, DlStrokeJoin::kRound, DlStrokeJoin::kMiter}) {
541 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
549 return builder.
Build();
552 ASSERT_TRUE(OpenPlaygroundHere(
callback));
557 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
563 auto draw = [&builder](
DlPaint& paint) {
565 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
569 for (
int d = 15;
d < 90;
d += 15) {
571 Point origin = {100, 100};
574 auto a = origin + m * p0;
575 auto b = origin + m *
p1;
589 std::vector<DlColor> colors = {
597 std::vector<Scalar> stops = {
608 CreateTextureForFixture(
"airplane.jpg",
614 colors.data(), stops.data(),
615 DlTileMode::kMirror));
620 texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
621 DlImageSampling::kMipmapLinear, &matrix));
624 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
633 auto callback = [&]() -> sk_sp<DisplayList> {
635 ImGuiWindowFlags_AlwaysAutoResize)) {
636 ImGui::SliderFloat(
"Scale", &scale, 0.001, 5);
637 ImGui::SliderFloat(
"Width", &line_width, 1, 20);
642 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
656 builder.
Scale(scale, scale);
670 builder.
Scale(0.2, 0.2);
677 return builder.
Build();
679 ASSERT_TRUE(OpenPlaygroundHere(
callback));
684 float line_width = 10.f;
685 float rotation = 0.f;
687 auto callback = [&]() -> sk_sp<DisplayList> {
689 ImGuiWindowFlags_AlwaysAutoResize)) {
691 ImGui::SliderFloat(
"Scale", &scale, 0.001f, 5.0f);
692 ImGui::SliderFloat(
"Width", &line_width, 1.0f, 20.0f);
693 ImGui::SliderFloat(
"Rotation", &rotation, 0.0f, 180.0f);
698 builder.
Scale(
static_cast<float>(GetContentScale().
x),
699 static_cast<float>(GetContentScale().
y));
713 float r_sin60 = r * std::sqrt(3.0f) / 2.0f;
714 float r_cos60 = r / 2.0f;
724 DlPoint(cx + r_cos60, cy + r_sin60);
728 builder.
Scale(scale, scale);
732 builder.
DrawLine(v0, v1, hex_paint);
733 builder.
DrawLine(v1, v2, hex_paint);
734 builder.
DrawLine(v2, v3, hex_paint);
735 builder.
DrawLine(v3, v4, hex_paint);
736 builder.
DrawLine(v4, v5, hex_paint);
737 builder.
DrawLine(v5, v0, hex_paint);
740 return builder.
Build();
742 ASSERT_TRUE(OpenPlaygroundHere(
callback));
747 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
755 auto draw = [&builder](
DlPaint& paint) {
757 {DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
761 for (
int d = 15;
d < 90;
d += 15) {
763 Point origin = {100, 100};
766 auto a = origin + m * p0;
767 auto b = origin + m *
p1;
783 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
796 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
810 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
815 for (
auto i = 0;
i < 10;
i++) {
822 path_builder.
Close();
824 path_builder.
MoveTo(
DlPoint(100.f + 50.f *
i - 100, 100.f + 50.f *
i));
825 path_builder.
LineTo(
DlPoint(100.f + 50.f *
i, 100.f + 50.f *
i - 100));
827 100.f + 50.f *
i - 100));
828 path_builder.
Close();
838 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
843 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
848 std::vector<DlColor> colors = {
DlColor::RGBA(1.0, 0.0, 0.0, 1.0),
850 std::vector<Scalar> stops = {0.0, 1.0};
854 stops.data(), DlTileMode::kMirror));
874 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
882 auto callback = [&]() -> sk_sp<DisplayList> {
884 ImGuiWindowFlags_AlwaysAutoResize)) {
885 ImGui::SliderFloat(
"Stroke Width", &stroke_width, 1, 300);
886 ImGui::SliderFloat(
"Aspect", &aspect, 0.5, 2.0);
887 ImGui::SliderFloat(
"Start Angle", &start_angle, 0, 360);
888 ImGui::SliderFloat(
"End Angle", &end_angle, 0, 360);
906 builder.
DrawArc(rect, start_angle, end_angle,
908 DlScalar frontier = rect.GetRight() + stroke_width / 2.0;
911 return builder.
Build();
913 ASSERT_TRUE(OpenPlaygroundHere(
callback));
924 .top_right =
DlSize(50, 50),
925 .bottom_left =
DlSize(50, 50),
926 .bottom_right =
DlSize(50, 50),
929 const Scalar kTriangleHeight = 100;
944 path_builder.
Close();
945 path_builder.
AddPath(rrect_path);
957 path_builder.
Close();
958 path_builder.
AddPath(rrect_path);
963 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
983 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
988 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
993 for (
auto cap : std::vector<DlStrokeCap>{
994 DlStrokeCap::kButt, DlStrokeCap::kRound, DlStrokeCap::kSquare}) {
996 path_builder.
MoveTo({20, 50});
997 path_builder.
LineTo({50, 50});
998 path_builder.
MoveTo({120, 50});
999 path_builder.
LineTo({120, 80});
1000 path_builder.
MoveTo({180, 50});
1001 path_builder.
LineTo({180, 50});
1026 for (
auto join : std::vector<DlStrokeJoin>{
1027 DlStrokeJoin::kBevel, DlStrokeJoin::kRound, DlStrokeJoin::kMiter}) {
1029 path_builder.
MoveTo({20, 50});
1030 path_builder.
LineTo({50, 50});
1031 path_builder.
LineTo({80, 50});
1032 path_builder.
MoveTo({20, 150});
1033 path_builder.
LineTo({50, 150});
1034 path_builder.
LineTo({50, 180});
1035 path_builder.
MoveTo({20, 250});
1036 path_builder.
LineTo({50, 250});
1037 path_builder.
LineTo({70, 270});
1038 path_builder.
MoveTo({20, 350});
1039 path_builder.
LineTo({50, 350});
1040 path_builder.
LineTo({30, 370});
1041 path_builder.
MoveTo({20, 450});
1042 path_builder.
LineTo({50, 450});
1043 path_builder.
LineTo({20, 450});
1044 path_builder.
MoveTo({120, 80});
1045 path_builder.
LineTo({150, 80});
1046 path_builder.
LineTo({180, 80});
1047 path_builder.
MoveTo({120, 180});
1048 path_builder.
LineTo({150, 180});
1049 path_builder.
LineTo({150, 150});
1050 path_builder.
MoveTo({120, 280});
1051 path_builder.
LineTo({150, 280});
1052 path_builder.
LineTo({170, 260});
1053 path_builder.
MoveTo({120, 380});
1054 path_builder.
LineTo({150, 380});
1055 path_builder.
LineTo({130, 360});
1056 path_builder.
MoveTo({120, 480});
1057 path_builder.
LineTo({150, 480});
1058 path_builder.
LineTo({120, 480});
1079 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1092 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 MakeCircleBounds(const TPoint< Type > ¢er, Type radius)
static constexpr TRect MakeSize(const TSize< U > &size)