10 #include "third_party/imgui/imgui.h"
24 paint.stroke_width = 20.0;
35 paint.stroke_width = 25.0;
45 paint.stroke_width = 100.0;
57 paint.stroke_width = 0.01;
69 paint.stroke_width = 200;
85 paint.stroke_width = 20;
88 builder.
AddCubicCurve({0, 200}, {50, 400}, {350, 0}, {400, 200});
101 paint.stroke_width = 50;
106 builder.
MoveTo({250, 250});
132 std::make_shared<Image>(CreateTextureForFixture(
"boston.jpg")), {10, 10},
151 builder.
LineTo({50, 100});
152 builder.
LineTo({100, 100});
153 builder.
LineTo({100, 50});
158 paint.stroke_width = 10;
172 builder.
LineTo({520, 120});
173 builder.
LineTo({300, 310});
174 builder.
LineTo({100, 50});
180 paint.stroke_width = 10;
189 auto callback = [&](
AiksContext& renderer) -> std::optional<Picture> {
191 static float scale = 3;
192 static bool add_circle_clip =
true;
195 ImGuiWindowFlags_AlwaysAutoResize)) {
196 ImGui::ColorEdit4(
"Color",
reinterpret_cast<float*
>(&
color));
197 ImGui::SliderFloat(
"Scale", &
scale, 0, 6);
198 ImGui::Checkbox(
"Circle clip", &add_circle_clip);
203 canvas.
Scale(GetContentScale());
211 paint.stroke_width = 10;
215 .QuadraticCurveTo({60, 20}, {60, 60})
218 .QuadraticCurveTo({60, 60}, {20, 60})
223 if (add_circle_clip) {
228 auto [handle_a, handle_b] =
232 Point point_a = screen_to_canvas * handle_a * GetContentScale();
233 Point point_b = screen_to_canvas * handle_b * GetContentScale();
235 Point middle = (point_a + point_b) / 2;
241 paint.stroke_join = join;
243 paint.stroke_cap = cap;
253 ASSERT_TRUE(OpenPlaygroundHere(callback));
258 canvas.
Scale(GetContentScale());
261 paint.stroke_width = 10;
265 paint.stroke_cap = cap;
266 Point origin = {100, 100};
270 for (
int d = 15; d < 90; d += 15) {
284 std::vector<Color> colors = {
285 Color{0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0},
286 Color{0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0},
287 Color{0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0},
288 Color{0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0},
289 Color{0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0},
290 Color{0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0},
291 Color{0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0}};
292 std::vector<Scalar> stops = {
302 auto texture = CreateTextureForFixture(
"airplane.jpg",
308 {100, 100}, 200, std::move(colors), std::move(stops),
325 paint.stroke_width = 10;
340 paint.stroke_width = 10;
353 for (
auto i = 0; i < 10; i++) {
357 builder.
MoveTo({100.f + 50.f * i - 100, 100.f + 50.f * i});
358 builder.
LineTo({100.f + 50.f * i, 100.f + 50.f * i - 100});
359 builder.
LineTo({100.f + 50.f * i - 100, 100.f + 50.f * i - 100});
366 canvas.
DrawPath(builder.
TakePath(), {.color = Color::Red().WithAlpha(0.4)});
373 canvas.
Scale(GetContentScale());
377 std::vector<Color> colors = {
Color{1.0, 0.0, 0.0, 1.0},
378 Color{0.0, 0.0, 0.0, 1.0}};
379 std::vector<Scalar> stops = {0.0, 1.0};
419 const Scalar kTriangleHeight = 100;
426 .
MoveTo({0, kTriangleHeight})
427 .
LineTo({-kTriangleHeight / 2.0f, 0})
428 .
LineTo({kTriangleHeight / 2.0f, 0})
432 kTriangleHeight, kTriangleHeight),
442 .
MoveTo({0, kTriangleHeight})
443 .
LineTo({-kTriangleHeight / 2.0f, 0})
445 .
LineTo({kTriangleHeight / 2.0f, 0})
449 kTriangleHeight, kTriangleHeight),