456 .
MoveTo({359.934, 96.6335})
457 .CubicCurveTo({358.189, 96.7055}, {356.436, 96.7908},
459 .CubicCurveTo({354.571, 96.8953}, {354.469, 96.9016},
461 .CubicCurveTo({352.672, 97.0038}, {350.969, 97.113},
463 .CubicCurveTo({349.048, 97.2506}, {348.836, 97.2678},
465 .CubicCurveTo({347.019, 97.4014}, {345.407, 97.5299},
467 .CubicCurveTo({343.428, 97.704}, {343.065, 97.7402},
469 .CubicCurveTo({341.221, 97.9086}, {339.736, 98.0505},
471 .CubicCurveTo({337.702, 98.2642}, {337.156, 98.3292},
473 .CubicCurveTo({335.284, 98.5356}, {333.956, 98.6837},
475 .CubicCurveTo({332.495, 98.8635}, {332.366, 98.8818},
477 .
LineTo({332.237, 102.601})
478 .
LineTo({321.778, 102.601})
479 .
LineTo({321.778, 100.382})
480 .CubicCurveTo({321.572, 100.413}, {321.367, 100.442},
482 .CubicCurveTo({319.22, 100.79}, {317.277, 101.123},
484 .CubicCurveTo({315.322, 101.481}, {315.311, 101.482},
486 .
LineTo({310.017, 105.94})
487 .
LineTo({309.779, 105.427})
488 .
LineTo({314.403, 101.651})
489 .CubicCurveTo({314.391, 101.653}, {314.379, 101.656},
491 .CubicCurveTo({312.528, 102.001}, {310.687, 102.366},
493 .CubicCurveTo({307.85, 102.955}, {306.855, 103.182}, {305.859, 103.4})
494 .CubicCurveTo({305.048, 103.579}, {304.236, 103.75},
496 .
LineTo({299.105, 107.578})
497 .
LineTo({298.867, 107.065})
498 .
LineTo({302.394, 104.185})
499 .
LineTo({302.412, 104.171})
500 .CubicCurveTo({301.388, 104.409}, {300.366, 104.67},
502 .CubicCurveTo({298.618, 105.1}, {297.89, 105.269}, {297.165, 105.455})
503 .CubicCurveTo({295.262, 105.94}, {293.36, 106.445},
505 .CubicCurveTo({291.132, 107.072}, {290.802, 107.163},
507 .CubicCurveTo({289.463, 107.544}, {288.455, 107.839},
509 .CubicCurveTo({286.476, 108.431}, {285.506, 108.73},
511 .CubicCurveTo({283.674, 109.304}, {282.812, 109.579},
513 .CubicCurveTo({281.177, 110.112}, {280.406, 110.377},
515 .CubicCurveTo({278.458, 111.037}, {277.256, 111.449},
517 .CubicCurveTo({276.76, 111.622}, {276.716, 111.637},
519 .CubicCurveTo({275.017, 112.239}, {273.365, 112.836},
521 .
LineTo({271.717, 113.449})
522 .CubicCurveTo({271.496, 113.496}, {271.238, 113.559},
524 .CubicCurveTo({270.893, 113.645}, {270.822, 113.663},
526 .CubicCurveTo({270.468, 113.755}, {270.169, 113.834},
528 .CubicCurveTo({269.789, 113.94}, {269.732, 113.957},
530 .CubicCurveTo({269.391, 114.053}, {269.081, 114.143},
532 .CubicCurveTo({268.628, 114.276}, {268.5, 114.314},
534 .CubicCurveTo({268.172, 114.412}, {267.959, 114.478},
536 .CubicCurveTo({263.349, 115.964}, {258.058, 117.695},
538 .CubicCurveTo({253.556, 119.255}, {253.547, 119.258},
540 .CubicCurveTo({251.844, 119.849}, {250.056, 120.474},
542 .CubicCurveTo({248, 121.197}, {247.812, 121.264}, {247.621, 121.331})
543 .CubicCurveTo({247.079, 121.522}, {246.531, 121.715},
545 .CubicCurveTo({245.554, 122.06}, {245.126, 122.212},
547 .CubicCurveTo({244.071, 122.586}, {243.437, 122.811},
549 .CubicCurveTo({242.189, 123.255}, {241.58, 123.472},
551 .CubicCurveTo({240.659, 123.801}, {240.357, 123.909},
553 .CubicCurveTo({239.12, 124.351}, {238.18, 124.687}, {237.22, 125.032})
554 .
LineTo({237.164, 125.003})
555 .CubicCurveTo({236.709, 125.184}, {236.262, 125.358},
557 .CubicCurveTo({235.413, 125.68}, {234.994, 125.832},
559 .CubicCurveTo({234.592, 125.977}, {234.591, 125.977},
561 .CubicCurveTo({222.206, 130.435}, {207.708, 135.753},
563 .CubicCurveTo({162.77, 151.336}, {122.17, 156.894}, {84.1123, 160})
568 .CubicCurveTo({359.978, 96.6317}, {359.956, 96.6326},
571 .
MoveTo({337.336, 124.143})
572 .CubicCurveTo({337.274, 122.359}, {338.903, 121.511},
574 .CubicCurveTo({338.903, 121.511}, {338.96, 123.303},
577 .
MoveTo({340.082, 121.849})
578 .CubicCurveTo({340.074, 121.917}, {340.062, 121.992},
580 .CubicCurveTo({340.039, 122.109}, {340.031, 122.142},
582 .CubicCurveTo({340.005, 122.26}, {339.98, 122.346},
584 .CubicCurveTo({339.941, 122.473}, {339.931, 122.507},
586 .CubicCurveTo({339.873, 122.672}, {339.819, 122.804},
588 .CubicCurveTo({339.747, 122.944}, {339.743, 122.949},
590 .CubicCurveTo({339.674, 123.08}, {339.593, 123.205},
592 .CubicCurveTo({339.473, 123.366}, {339.441, 123.401},
594 .CubicCurveTo({339.332, 123.534}, {339.243, 123.625},
596 .CubicCurveTo({339.105, 123.75}, {339.068, 123.786},
598 .CubicCurveTo({338.881, 123.937}, {338.724, 124.048},
600 .CubicCurveTo({338.532, 123.959}, {338.554, 123.79},
602 .CubicCurveTo({338.58, 123.625}, {338.58, 123.625}, {338.58, 123.625})
603 .CubicCurveTo({338.607, 123.455}, {338.65, 123.299},
605 .CubicCurveTo({338.708, 123.14}, {338.71, 123.127},
607 .CubicCurveTo({338.769, 122.971}, {338.833, 122.838},
609 .CubicCurveTo({338.911, 122.702}, {338.916, 122.69200000000001},
611 .CubicCurveTo({338.996, 122.557}, {339.072, 122.444},
613 .CubicCurveTo({339.161, 122.333}, {339.166, 122.326},
615 .CubicCurveTo({339.256, 122.215}, {339.339, 122.12},
617 .CubicCurveTo({339.428, 122.033}, {339.431, 122.03},
619 .CubicCurveTo({339.785, 121.687}, {340.106, 121.511},
621 .CubicCurveTo({340.106, 121.511}, {340.107, 121.645},
624 .
MoveTo({340.678, 113.245})
625 .CubicCurveTo({340.594, 113.488}, {340.356, 113.655},
627 .CubicCurveTo({339.817, 113.948}, {339.465, 114.059},
629 .CubicCurveTo({338.251, 114.379}, {337.34, 114.516},
631 .CubicCurveTo({335.761, 114.516}, {335.072, 114.527},
633 .CubicCurveTo({334.125, 114.508}, {333.862, 114.462},
635 .CubicCurveTo({332.865, 114.318}, {332.096, 114.184},
637 .CubicCurveTo({330.979, 113.695}, {330.442, 113.34},
639 .CubicCurveTo({331.135, 111.755}, {333.219, 112.946},
641 .CubicCurveTo({334.54, 113.816}, {334.554, 113.8}, {334.569, 113.784})
642 .CubicCurveTo({333.38, 112.708}, {331.749, 110.985},
644 .CubicCurveTo({333.769, 109.82}, {334.713, 111.93},
646 .CubicCurveTo({334.915, 111.889}, {334.59, 109.636},
648 .CubicCurveTo({336.733, 109.636}, {336.408, 111.889},
650 .CubicCurveTo({336.609, 111.93}, {337.553, 109.82},
652 .CubicCurveTo({339.574, 110.984}, {337.942, 112.708},
654 .CubicCurveTo({336.768, 113.8}, {336.782, 113.816},
656 .CubicCurveTo({338.104, 112.946}, {340.187, 111.755},
658 .CubicCurveTo({340.71, 112.95}, {340.728, 113.102},
661 .
MoveTo({346.357, 106.771})
662 .CubicCurveTo({346.295, 104.987}, {347.924, 104.139},
664 .CubicCurveTo({347.924, 104.139}, {347.982, 105.931},
667 .
MoveTo({347.56, 106.771})
668 .CubicCurveTo({347.498, 104.987}, {349.127, 104.139},
670 .CubicCurveTo({349.127, 104.139}, {349.185, 105.931},
679 auto contents = std::make_shared<SolidColorContents>();
681 contents->SetGeometry(geom.get());
684 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
950 CreateTextureForFixture(
"boston.jpg",
true);
954 const char* input_type_names[] = {
"Texture",
"Solid Color"};
955 const char* blur_type_names[] = {
"Image blur",
"Mask blur"};
956 const char* pass_variation_names[] = {
"New"};
957 const char* blur_style_names[] = {
"Normal",
"Solid",
"Outer",
"Inner"};
958 const char* tile_mode_names[] = {
"Clamp",
"Repeat",
"Mirror",
"Decal"};
967 static int selected_input_type = 0;
969 static int selected_blur_type = 0;
970 static int selected_pass_variation = 0;
971 static bool combined_sigma =
false;
972 static float blur_amount_coarse[2] = {0, 0};
973 static float blur_amount_fine[2] = {10, 10};
974 static int selected_blur_style = 0;
975 static int selected_tile_mode = 3;
976 static Color cover_color(1, 0, 0, 0.2);
977 static Color bounds_color(0, 1, 0, 0.1);
978 static float offset[2] = {500, 400};
979 static float rotation = 0;
980 static float scale[2] = {0.65, 0.65};
981 static float skew[2] = {0, 0};
982 static float path_rect[4] = {0, 0,
983 static_cast<float>(boston->GetSize().width),
984 static_cast<float>(boston->GetSize().height)};
986 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
988 ImGui::Combo(
"Input type", &selected_input_type, input_type_names,
989 sizeof(input_type_names) /
sizeof(
char*));
990 if (selected_input_type == 0) {
991 ImGui::SliderFloat(
"Input opacity", &input_color.
alpha, 0, 1);
993 ImGui::ColorEdit4(
"Input color",
994 reinterpret_cast<float*
>(&input_color));
996 ImGui::Combo(
"Blur type", &selected_blur_type, blur_type_names,
997 sizeof(blur_type_names) /
sizeof(
char*));
998 if (selected_blur_type == 0) {
999 ImGui::Combo(
"Pass variation", &selected_pass_variation,
1000 pass_variation_names,
1001 sizeof(pass_variation_names) /
sizeof(
char*));
1003 ImGui::Checkbox(
"Combined sigma", &combined_sigma);
1004 if (combined_sigma) {
1005 ImGui::SliderFloat(
"Sigma (coarse)", blur_amount_coarse, 0, 1000);
1006 ImGui::SliderFloat(
"Sigma (fine)", blur_amount_fine, 0, 10);
1007 blur_amount_coarse[1] = blur_amount_coarse[0];
1008 blur_amount_fine[1] = blur_amount_fine[0];
1010 ImGui::SliderFloat2(
"Sigma (coarse)", blur_amount_coarse, 0, 1000);
1011 ImGui::SliderFloat2(
"Sigma (fine)", blur_amount_fine, 0, 10);
1013 ImGui::Combo(
"Blur style", &selected_blur_style, blur_style_names,
1014 sizeof(blur_style_names) /
sizeof(
char*));
1015 ImGui::Combo(
"Tile mode", &selected_tile_mode, tile_mode_names,
1016 sizeof(tile_mode_names) /
sizeof(
char*));
1017 ImGui::ColorEdit4(
"Cover color",
reinterpret_cast<float*
>(&cover_color));
1018 ImGui::ColorEdit4(
"Bounds color ",
1019 reinterpret_cast<float*
>(&bounds_color));
1020 ImGui::SliderFloat2(
"Translation", offset, 0,
1021 pass.GetRenderTargetSize().width);
1022 ImGui::SliderFloat(
"Rotation", &rotation, 0,
kPi * 2);
1023 ImGui::SliderFloat2(
"Scale", scale, 0, 3);
1024 ImGui::SliderFloat2(
"Skew", skew, -3, 3);
1025 ImGui::SliderFloat4(
"Path XYWH", path_rect, -1000, 1000);
1029 auto blur_sigma_x =
Sigma{blur_amount_coarse[0] + blur_amount_fine[0]};
1030 auto blur_sigma_y =
Sigma{blur_amount_coarse[1] + blur_amount_fine[1]};
1032 std::shared_ptr<Contents>
input;
1036 Rect::MakeXYWH(path_rect[0], path_rect[1], path_rect[2], path_rect[3]);
1038 std::unique_ptr<Geometry> solid_color_input;
1039 if (selected_input_type == 0) {
1040 auto texture = std::make_shared<TextureContents>();
1042 texture->SetDestinationRect(input_rect);
1047 input_size = input_rect.GetSize();
1049 auto fill = std::make_shared<SolidColorContents>();
1050 fill->SetColor(input_color);
1054 fill->SetGeometry(solid_color_input.get());
1057 input_size = input_rect.GetSize();
1060 std::shared_ptr<FilterContents> blur;
1061 switch (selected_pass_variation) {
1063 blur = std::make_shared<GaussianBlurFilterContents>(
1064 blur_sigma_x.sigma, blur_sigma_y.sigma,
1065 tile_modes[selected_tile_mode], blur_styles[selected_blur_style],
1072 tile_modes[selected_tile_mode], blur_styles[selected_blur_style]);
1079 blur_styles[selected_blur_style]);
1088 auto target_contents = selected_blur_type == 0 ? blur : mask_blur;
1094 entity.
Render(context, pass);
1099 std::unique_ptr<Geometry> geom =
1101 auto contents = std::make_shared<SolidColorContents>();
1102 contents->SetColor(cover_color);
1103 contents->SetGeometry(geom.get());
1106 cover_entity.
Render(context, pass);
1110 std::optional<Rect> target_contents_coverage =
1112 if (target_contents_coverage.has_value()) {
1113 std::unique_ptr<Geometry> geom =
1115 target_contents->GetCoverage(entity).value()));
1116 auto contents = std::make_shared<SolidColorContents>();
1117 contents->SetColor(bounds_color);
1118 contents->SetGeometry(geom.get());
1122 bounds_entity.
Render(context, pass);
1127 ASSERT_TRUE(OpenPlaygroundHere(
callback));