457 .
MoveTo({359.934, 96.6335})
458 .CubicCurveTo({358.189, 96.7055}, {356.436, 96.7908},
460 .CubicCurveTo({354.571, 96.8953}, {354.469, 96.9016},
462 .CubicCurveTo({352.672, 97.0038}, {350.969, 97.113},
464 .CubicCurveTo({349.048, 97.2506}, {348.836, 97.2678},
466 .CubicCurveTo({347.019, 97.4014}, {345.407, 97.5299},
468 .CubicCurveTo({343.428, 97.704}, {343.065, 97.7402},
470 .CubicCurveTo({341.221, 97.9086}, {339.736, 98.0505},
472 .CubicCurveTo({337.702, 98.2642}, {337.156, 98.3292},
474 .CubicCurveTo({335.284, 98.5356}, {333.956, 98.6837},
476 .CubicCurveTo({332.495, 98.8635}, {332.366, 98.8818},
478 .
LineTo({332.237, 102.601})
479 .
LineTo({321.778, 102.601})
480 .
LineTo({321.778, 100.382})
481 .CubicCurveTo({321.572, 100.413}, {321.367, 100.442},
483 .CubicCurveTo({319.22, 100.79}, {317.277, 101.123},
485 .CubicCurveTo({315.322, 101.481}, {315.311, 101.482},
487 .
LineTo({310.017, 105.94})
488 .
LineTo({309.779, 105.427})
489 .
LineTo({314.403, 101.651})
490 .CubicCurveTo({314.391, 101.653}, {314.379, 101.656},
492 .CubicCurveTo({312.528, 102.001}, {310.687, 102.366},
494 .CubicCurveTo({307.85, 102.955}, {306.855, 103.182}, {305.859, 103.4})
495 .CubicCurveTo({305.048, 103.579}, {304.236, 103.75},
497 .
LineTo({299.105, 107.578})
498 .
LineTo({298.867, 107.065})
499 .
LineTo({302.394, 104.185})
500 .
LineTo({302.412, 104.171})
501 .CubicCurveTo({301.388, 104.409}, {300.366, 104.67},
503 .CubicCurveTo({298.618, 105.1}, {297.89, 105.269}, {297.165, 105.455})
504 .CubicCurveTo({295.262, 105.94}, {293.36, 106.445},
506 .CubicCurveTo({291.132, 107.072}, {290.802, 107.163},
508 .CubicCurveTo({289.463, 107.544}, {288.455, 107.839},
510 .CubicCurveTo({286.476, 108.431}, {285.506, 108.73},
512 .CubicCurveTo({283.674, 109.304}, {282.812, 109.579},
514 .CubicCurveTo({281.177, 110.112}, {280.406, 110.377},
516 .CubicCurveTo({278.458, 111.037}, {277.256, 111.449},
518 .CubicCurveTo({276.76, 111.622}, {276.716, 111.637},
520 .CubicCurveTo({275.017, 112.239}, {273.365, 112.836},
522 .
LineTo({271.717, 113.449})
523 .CubicCurveTo({271.496, 113.496}, {271.238, 113.559},
525 .CubicCurveTo({270.893, 113.645}, {270.822, 113.663},
527 .CubicCurveTo({270.468, 113.755}, {270.169, 113.834},
529 .CubicCurveTo({269.789, 113.94}, {269.732, 113.957},
531 .CubicCurveTo({269.391, 114.053}, {269.081, 114.143},
533 .CubicCurveTo({268.628, 114.276}, {268.5, 114.314},
535 .CubicCurveTo({268.172, 114.412}, {267.959, 114.478},
537 .CubicCurveTo({263.349, 115.964}, {258.058, 117.695},
539 .CubicCurveTo({253.556, 119.255}, {253.547, 119.258},
541 .CubicCurveTo({251.844, 119.849}, {250.056, 120.474},
543 .CubicCurveTo({248, 121.197}, {247.812, 121.264}, {247.621, 121.331})
544 .CubicCurveTo({247.079, 121.522}, {246.531, 121.715},
546 .CubicCurveTo({245.554, 122.06}, {245.126, 122.212},
548 .CubicCurveTo({244.071, 122.586}, {243.437, 122.811},
550 .CubicCurveTo({242.189, 123.255}, {241.58, 123.472},
552 .CubicCurveTo({240.659, 123.801}, {240.357, 123.909},
554 .CubicCurveTo({239.12, 124.351}, {238.18, 124.687}, {237.22, 125.032})
555 .
LineTo({237.164, 125.003})
556 .CubicCurveTo({236.709, 125.184}, {236.262, 125.358},
558 .CubicCurveTo({235.413, 125.68}, {234.994, 125.832},
560 .CubicCurveTo({234.592, 125.977}, {234.591, 125.977},
562 .CubicCurveTo({222.206, 130.435}, {207.708, 135.753},
564 .CubicCurveTo({162.77, 151.336}, {122.17, 156.894}, {84.1123, 160})
569 .CubicCurveTo({359.978, 96.6317}, {359.956, 96.6326},
572 .
MoveTo({337.336, 124.143})
573 .CubicCurveTo({337.274, 122.359}, {338.903, 121.511},
575 .CubicCurveTo({338.903, 121.511}, {338.96, 123.303},
578 .
MoveTo({340.082, 121.849})
579 .CubicCurveTo({340.074, 121.917}, {340.062, 121.992},
581 .CubicCurveTo({340.039, 122.109}, {340.031, 122.142},
583 .CubicCurveTo({340.005, 122.26}, {339.98, 122.346},
585 .CubicCurveTo({339.941, 122.473}, {339.931, 122.507},
587 .CubicCurveTo({339.873, 122.672}, {339.819, 122.804},
589 .CubicCurveTo({339.747, 122.944}, {339.743, 122.949},
591 .CubicCurveTo({339.674, 123.08}, {339.593, 123.205},
593 .CubicCurveTo({339.473, 123.366}, {339.441, 123.401},
595 .CubicCurveTo({339.332, 123.534}, {339.243, 123.625},
597 .CubicCurveTo({339.105, 123.75}, {339.068, 123.786},
599 .CubicCurveTo({338.881, 123.937}, {338.724, 124.048},
601 .CubicCurveTo({338.532, 123.959}, {338.554, 123.79},
603 .CubicCurveTo({338.58, 123.625}, {338.58, 123.625}, {338.58, 123.625})
604 .CubicCurveTo({338.607, 123.455}, {338.65, 123.299},
606 .CubicCurveTo({338.708, 123.14}, {338.71, 123.127},
608 .CubicCurveTo({338.769, 122.971}, {338.833, 122.838},
610 .CubicCurveTo({338.911, 122.702}, {338.916, 122.69200000000001},
612 .CubicCurveTo({338.996, 122.557}, {339.072, 122.444},
614 .CubicCurveTo({339.161, 122.333}, {339.166, 122.326},
616 .CubicCurveTo({339.256, 122.215}, {339.339, 122.12},
618 .CubicCurveTo({339.428, 122.033}, {339.431, 122.03},
620 .CubicCurveTo({339.785, 121.687}, {340.106, 121.511},
622 .CubicCurveTo({340.106, 121.511}, {340.107, 121.645},
625 .
MoveTo({340.678, 113.245})
626 .CubicCurveTo({340.594, 113.488}, {340.356, 113.655},
628 .CubicCurveTo({339.817, 113.948}, {339.465, 114.059},
630 .CubicCurveTo({338.251, 114.379}, {337.34, 114.516},
632 .CubicCurveTo({335.761, 114.516}, {335.072, 114.527},
634 .CubicCurveTo({334.125, 114.508}, {333.862, 114.462},
636 .CubicCurveTo({332.865, 114.318}, {332.096, 114.184},
638 .CubicCurveTo({330.979, 113.695}, {330.442, 113.34},
640 .CubicCurveTo({331.135, 111.755}, {333.219, 112.946},
642 .CubicCurveTo({334.54, 113.816}, {334.554, 113.8}, {334.569, 113.784})
643 .CubicCurveTo({333.38, 112.708}, {331.749, 110.985},
645 .CubicCurveTo({333.769, 109.82}, {334.713, 111.93},
647 .CubicCurveTo({334.915, 111.889}, {334.59, 109.636},
649 .CubicCurveTo({336.733, 109.636}, {336.408, 111.889},
651 .CubicCurveTo({336.609, 111.93}, {337.553, 109.82},
653 .CubicCurveTo({339.574, 110.984}, {337.942, 112.708},
655 .CubicCurveTo({336.768, 113.8}, {336.782, 113.816},
657 .CubicCurveTo({338.104, 112.946}, {340.187, 111.755},
659 .CubicCurveTo({340.71, 112.95}, {340.728, 113.102},
662 .
MoveTo({346.357, 106.771})
663 .CubicCurveTo({346.295, 104.987}, {347.924, 104.139},
665 .CubicCurveTo({347.924, 104.139}, {347.982, 105.931},
668 .
MoveTo({347.56, 106.771})
669 .CubicCurveTo({347.498, 104.987}, {349.127, 104.139},
671 .CubicCurveTo({349.127, 104.139}, {349.185, 105.931},
680 auto contents = std::make_shared<SolidColorContents>();
682 contents->SetGeometry(geom.get());
685 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
951 CreateTextureForFixture(
"boston.jpg",
true);
955 const char* input_type_names[] = {
"Texture",
"Solid Color"};
956 const char* blur_type_names[] = {
"Image blur",
"Mask blur"};
957 const char* pass_variation_names[] = {
"New"};
958 const char* blur_style_names[] = {
"Normal",
"Solid",
"Outer",
"Inner"};
959 const char* tile_mode_names[] = {
"Clamp",
"Repeat",
"Mirror",
"Decal"};
968 static int selected_input_type = 0;
970 static int selected_blur_type = 0;
971 static int selected_pass_variation = 0;
972 static bool combined_sigma =
false;
973 static float blur_amount_coarse[2] = {0, 0};
974 static float blur_amount_fine[2] = {10, 10};
975 static int selected_blur_style = 0;
976 static int selected_tile_mode = 3;
977 static Color cover_color(1, 0, 0, 0.2);
978 static Color bounds_color(0, 1, 0, 0.1);
979 static float offset[2] = {500, 400};
980 static float rotation = 0;
981 static float scale[2] = {0.65, 0.65};
982 static float skew[2] = {0, 0};
983 static float path_rect[4] = {0, 0,
984 static_cast<float>(boston->GetSize().width),
985 static_cast<float>(boston->GetSize().height)};
987 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
989 ImGui::Combo(
"Input type", &selected_input_type, input_type_names,
990 sizeof(input_type_names) /
sizeof(
char*));
991 if (selected_input_type == 0) {
992 ImGui::SliderFloat(
"Input opacity", &input_color.
alpha, 0, 1);
994 ImGui::ColorEdit4(
"Input color",
995 reinterpret_cast<float*
>(&input_color));
997 ImGui::Combo(
"Blur type", &selected_blur_type, blur_type_names,
998 sizeof(blur_type_names) /
sizeof(
char*));
999 if (selected_blur_type == 0) {
1000 ImGui::Combo(
"Pass variation", &selected_pass_variation,
1001 pass_variation_names,
1002 sizeof(pass_variation_names) /
sizeof(
char*));
1004 ImGui::Checkbox(
"Combined sigma", &combined_sigma);
1005 if (combined_sigma) {
1006 ImGui::SliderFloat(
"Sigma (coarse)", blur_amount_coarse, 0, 1000);
1007 ImGui::SliderFloat(
"Sigma (fine)", blur_amount_fine, 0, 10);
1008 blur_amount_coarse[1] = blur_amount_coarse[0];
1009 blur_amount_fine[1] = blur_amount_fine[0];
1011 ImGui::SliderFloat2(
"Sigma (coarse)", blur_amount_coarse, 0, 1000);
1012 ImGui::SliderFloat2(
"Sigma (fine)", blur_amount_fine, 0, 10);
1014 ImGui::Combo(
"Blur style", &selected_blur_style, blur_style_names,
1015 sizeof(blur_style_names) /
sizeof(
char*));
1016 ImGui::Combo(
"Tile mode", &selected_tile_mode, tile_mode_names,
1017 sizeof(tile_mode_names) /
sizeof(
char*));
1018 ImGui::ColorEdit4(
"Cover color",
reinterpret_cast<float*
>(&cover_color));
1019 ImGui::ColorEdit4(
"Bounds color ",
1020 reinterpret_cast<float*
>(&bounds_color));
1021 ImGui::SliderFloat2(
"Translation", offset, 0,
1022 pass.GetRenderTargetSize().width);
1023 ImGui::SliderFloat(
"Rotation", &rotation, 0,
kPi * 2);
1024 ImGui::SliderFloat2(
"Scale", scale, 0, 3);
1025 ImGui::SliderFloat2(
"Skew", skew, -3, 3);
1026 ImGui::SliderFloat4(
"Path XYWH", path_rect, -1000, 1000);
1030 auto blur_sigma_x =
Sigma{blur_amount_coarse[0] + blur_amount_fine[0]};
1031 auto blur_sigma_y =
Sigma{blur_amount_coarse[1] + blur_amount_fine[1]};
1033 std::shared_ptr<Contents>
input;
1037 Rect::MakeXYWH(path_rect[0], path_rect[1], path_rect[2], path_rect[3]);
1039 std::unique_ptr<Geometry> solid_color_input;
1040 if (selected_input_type == 0) {
1041 auto texture = std::make_shared<TextureContents>();
1043 texture->SetDestinationRect(input_rect);
1048 input_size = input_rect.GetSize();
1050 auto fill = std::make_shared<SolidColorContents>();
1051 fill->SetColor(input_color);
1055 fill->SetGeometry(solid_color_input.get());
1058 input_size = input_rect.GetSize();
1061 std::shared_ptr<FilterContents> blur;
1062 switch (selected_pass_variation) {
1064 blur = std::make_shared<GaussianBlurFilterContents>(
1065 blur_sigma_x.sigma, blur_sigma_y.sigma,
1066 tile_modes[selected_tile_mode], std::nullopt,
1067 blur_styles[selected_blur_style],
1074 tile_modes[selected_tile_mode],
1075 std::nullopt, blur_styles[selected_blur_style]);
1082 blur_styles[selected_blur_style]);
1091 auto target_contents = selected_blur_type == 0 ? blur : mask_blur;
1097 entity.
Render(context, pass);
1102 std::unique_ptr<Geometry> geom =
1104 auto contents = std::make_shared<SolidColorContents>();
1105 contents->SetColor(cover_color);
1106 contents->SetGeometry(geom.get());
1109 cover_entity.
Render(context, pass);
1113 std::optional<Rect> target_contents_coverage =
1115 if (target_contents_coverage.has_value()) {
1116 std::unique_ptr<Geometry> geom =
1118 target_contents->GetCoverage(entity).value()));
1119 auto contents = std::make_shared<SolidColorContents>();
1120 contents->SetColor(bounds_color);
1121 contents->SetGeometry(geom.get());
1125 bounds_entity.
Render(context, pass);
1130 ASSERT_TRUE(OpenPlaygroundHere(
callback));