shader_radial_gradient.rml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <rml>
  2. <head>
  3. <title>radial-gradient</title>
  4. <link type="text/rcss" href="../style.rcss"/>
  5. <meta name="Description" content="A variety of radial-gradient backgrounds. Each group should match their description." />
  6. <meta name="Backend" content="Requires backend support for rendering with compiled shaders." />
  7. <link rel="source" href="https://www.w3.org/TR/css-images-3/#radial-gradients" />
  8. <style>
  9. body {
  10. background: #ddd;
  11. color: #444;
  12. width: 900dp;
  13. }
  14. div {
  15. margin: 5dp;
  16. width: 200dp;
  17. height: 100dp;
  18. box-sizing: border-box;
  19. border: 1dp #bbb;
  20. float: left;
  21. }
  22. group {
  23. margin-left: 1em;
  24. display: flow-root;
  25. margin-bottom: 1em;
  26. }
  27. button {
  28. decorator: radial-gradient(circle farthest-side at center, #ff6b6b, #fec84d, #4ecdc4);
  29. display: block;
  30. width: 200dp;
  31. margin: 8dp 0;
  32. padding: 15dp 0;
  33. border: 4dp #fff;
  34. border-radius: 50dp;
  35. box-shadow: #000a 0 4dp 12dp, #000a 0 1dp 3dp;
  36. color: white;
  37. font-size: 26dp;
  38. text-align: center;
  39. }
  40. .ellipse > :nth-child(1) { decorator: radial-gradient(yellow, green); }
  41. .ellipse > :nth-child(2) { decorator: radial-gradient(ellipse at center, yellow 0%, green 100%); }
  42. .ellipse > :nth-child(3) { decorator: radial-gradient(farthest-corner at 50% 50%, yellow, green); }
  43. .circle > :nth-child(1) { decorator: radial-gradient(circle, yellow, green); }
  44. .three_color > :nth-child(1) { decorator: radial-gradient(red, yellow, green); }
  45. .origin_bottom_left > :nth-child(1) { decorator: radial-gradient(farthest-side at left bottom, red, yellow 50px, green); }
  46. .closest_side_ellipse > :nth-child(1) { decorator: radial-gradient(closest-side at 20px 30px, red, yellow, green); }
  47. .closest_side_ellipse > :nth-child(2) { decorator: radial-gradient(20px 30px at 20px 30px, red, yellow, green); }
  48. .closest_side_circle > :nth-child(1) { decorator: radial-gradient(circle closest-side at 20px 30px, red, yellow, green); }
  49. .closest_side_circle > :nth-child(2) { decorator: radial-gradient(20px 20px at 20px 30px, red, yellow, green); }
  50. .closest_corner_ellipse > :nth-child(1) { decorator: radial-gradient(closest-corner at 20px 30px, red, yellow, green); }
  51. .closest_corner_circle > :nth-child(1) { decorator: radial-gradient(circle closest-corner at 20px 30px, red, yellow, green); }
  52. .sharp > :nth-child(1) { decorator: radial-gradient(circle closest-side, red 50%, yellow 50%, green); }
  53. .sharp > :nth-child(2) { decorator: radial-gradient(red 50%, yellow 50%, green); }
  54. .sharp > :nth-child(3) { decorator: radial-gradient(60% 10px, red 50%, yellow 50%, green); }
  55. .sharp > :nth-child(4) { decorator: radial-gradient(10px 60%, red 50%, yellow 50%, green); }
  56. .problematic > :nth-child(1) { decorator: radial-gradient(circle closest-side at 199px 30px, red, yellow, green); }
  57. .problematic > :nth-child(2) { decorator: radial-gradient(circle closest-side at 200px 30px, red, yellow, green); }
  58. .problematic > :nth-child(3) { decorator: radial-gradient(circle closest-side at -1px, red, yellow, green); }
  59. .problematic > :nth-child(4) { decorator: radial-gradient(circle closest-side at 0px, red, yellow, green); }
  60. .problematic > :nth-child(5) { decorator: radial-gradient(5px 0.1px, red, yellow, green); }
  61. .problematic > :nth-child(6) { decorator: radial-gradient(0px 0px, red, yellow, green); }
  62. .repeating > :nth-child(1) { decorator: repeating-radial-gradient(circle 30px, red, yellow, green 90%, red); }
  63. .repeating > :nth-child(2) { decorator: repeating-radial-gradient(farthest-side at left bottom, red, yellow 50px, green 90%, red); }
  64. .repeating > :nth-child(3) { decorator: repeating-radial-gradient(closest-side at 20px 30px, red, yellow, green 90%, red); }
  65. .repeating > :nth-child(4) { decorator: repeating-radial-gradient(circle closest-side at -15% 50%, red, yellow, green 90%, red); }
  66. .repeating > :nth-child(5) { decorator: repeating-radial-gradient(red, yellow 20px, green 40px); }
  67. .repeating > :nth-child(6) { decorator: repeating-radial-gradient(circle 20px, red, yellow, green 100%, yellow 150%, red 200%); }
  68. .repeating > :nth-child(7) { decorator: repeating-radial-gradient(circle 30px, red -30px, yellow); }
  69. .repeating > :nth-child(8) { decorator: repeating-radial-gradient(circle 30px, red 15px, yellow); }
  70. </style>
  71. </head>
  72. <body>
  73. Button with radial gradient background
  74. <group>
  75. <button>Button</button>
  76. </group>
  77. Ellipse, yellow (center) to green (corners) [equivalent]
  78. <group class="ellipse">
  79. <div/>
  80. <div/>
  81. <div/>
  82. </group>
  83. Circle, yellow (center) to green (corners)
  84. <group class="circle">
  85. <div/>
  86. </group>
  87. Ellipse, red (center), yellow, green (corners)
  88. <group class="three_color">
  89. <div/>
  90. </group>
  91. Red (bottom-left), yellow, green (top-right)
  92. <group class="origin_bottom_left">
  93. <div/>
  94. </group>
  95. Repeating radial gradients
  96. <group class="repeating">
  97. <div/>
  98. <div/>
  99. <div/>
  100. <div/>
  101. <div/>
  102. <div/>
  103. <div/>
  104. <div/>
  105. </group>
  106. Ellipse (top-left, closest-side), red, yellow, green [equivalent]
  107. <group class="closest_side_ellipse">
  108. <div/>
  109. <div/>
  110. </group>
  111. Circle (top-left, closest-side), red, yellow, green [equivalent]
  112. <group class="closest_side_circle">
  113. <div/>
  114. <div/>
  115. </group>
  116. Ellipse (top-left, closest-corner), red, yellow, green
  117. <group class="closest_corner_ellipse">
  118. <div/>
  119. </group>
  120. Circle (top-left, closest-corner), red, yellow, green
  121. <group class="closest_corner_circle">
  122. <div/>
  123. </group>
  124. Sharp color transitions for testing anti-aliasing
  125. <group class="sharp">
  126. <div/>
  127. <div/>
  128. <div/>
  129. <div/>
  130. </group>
  131. Edge cases, should be green, possibly with a tiny ellipse.
  132. <group class="problematic">
  133. <div/>
  134. <div/>
  135. <div/>
  136. <div/>
  137. <div/>
  138. <div/>
  139. </group>
  140. </body>
  141. </rml>