@@ -381,6 +381,59 @@ TEST_P(AiksTest, CanRenderLinearGradient) {
381
381
ASSERT_TRUE (OpenPlaygroundHere (callback));
382
382
}
383
383
384
+ TEST_P (AiksTest, CanRenderLinearGradientWithOverlappingStops) {
385
+ auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
386
+ const char * tile_mode_names[] = {" Clamp" , " Repeat" , " Mirror" , " Decal" };
387
+ const Entity::TileMode tile_modes[] = {
388
+ Entity::TileMode::kClamp , Entity::TileMode::kRepeat ,
389
+ Entity::TileMode::kMirror , Entity::TileMode::kDecal };
390
+
391
+ static int selected_tile_mode = 0 ;
392
+ static float alpha = 1 ;
393
+ ImGui::Begin (" Controls" , nullptr , ImGuiWindowFlags_AlwaysAutoResize);
394
+ ImGui::SliderFloat (" Alpha" , &alpha, 0 , 1 );
395
+ ImGui::Combo (" Tile mode" , &selected_tile_mode, tile_mode_names,
396
+ sizeof (tile_mode_names) / sizeof (char *));
397
+ static Matrix matrix = {
398
+ 1 , 0 , 0 , 0 , //
399
+ 0 , 1 , 0 , 0 , //
400
+ 0 , 0 , 1 , 0 , //
401
+ 0 , 0 , 0 , 1 //
402
+ };
403
+ std::string label = " ##1" ;
404
+ for (int i = 0 ; i < 4 ; i++) {
405
+ ImGui::InputScalarN (label.c_str (), ImGuiDataType_Float, &(matrix.vec [i]),
406
+ 4 , NULL , NULL , " %.2f" , 0 );
407
+ label[2 ]++;
408
+ }
409
+ ImGui::End ();
410
+
411
+ Canvas canvas;
412
+ Paint paint;
413
+ canvas.Translate ({100.0 , 100.0 , 0 });
414
+ auto tile_mode = tile_modes[selected_tile_mode];
415
+ paint.color_source = [tile_mode]() {
416
+ std::vector<Color> colors = {Color{0.9568 , 0.2627 , 0.2118 , 1.0 },
417
+ Color{0.9568 , 0.2627 , 0.2118 , 1.0 },
418
+ Color{0.1294 , 0.5882 , 0.9529 , 1.0 },
419
+ Color{0.1294 , 0.5882 , 0.9529 , 1.0 }};
420
+ std::vector<Scalar> stops = {0.0 , 0.5 , 0.5 , 1.0 };
421
+
422
+ auto contents = std::make_shared<LinearGradientContents>();
423
+ contents->SetEndPoints ({0 , 0 }, {500 , 500 });
424
+ contents->SetColors (std::move (colors));
425
+ contents->SetStops (std::move (stops));
426
+ contents->SetTileMode (tile_mode);
427
+ contents->SetEffectTransform (matrix);
428
+ return contents;
429
+ };
430
+ paint.color = Color (1.0 , 1.0 , 1.0 , alpha);
431
+ canvas.DrawRect ({0 , 0 , 500 , 500 }, paint);
432
+ return renderer.Render (canvas.EndRecordingAsPicture (), render_target);
433
+ };
434
+ ASSERT_TRUE (OpenPlaygroundHere (callback));
435
+ }
436
+
384
437
TEST_P (AiksTest, CanRenderLinearGradientManyColors) {
385
438
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
386
439
const char * tile_mode_names[] = {" Clamp" , " Repeat" , " Mirror" , " Decal" };
@@ -1117,7 +1170,8 @@ TEST_P(AiksTest, CanRenderItalicizedText) {
1117
1170
1118
1171
TEST_P (AiksTest, CanRenderEmojiTextFrame) {
1119
1172
Canvas canvas;
1120
- ASSERT_TRUE (RenderTextInCanvas (GetContext (), canvas, " 😀 😃 😄 😁 😆 😅 😂 🤣 🥲 😊" ,
1173
+ ASSERT_TRUE (RenderTextInCanvas (GetContext (), canvas,
1174
+ " 😀 😃 😄 😁 😆 😅 😂 🤣 🥲 😊" ,
1121
1175
#if FML_OS_MACOSX
1122
1176
" Apple Color Emoji.ttc" ));
1123
1177
#else
0 commit comments