shader_linear_gradient.rml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <rml>
  2. <head>
  3. <title>linear-gradient</title>
  4. <link type="text/rcss" href="../style.rcss"/>
  5. <meta name="Description" content="A variety of linear-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/#linear-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. .yellow_blue > :nth-child(1) { decorator: linear-gradient(yellow, blue); }
  28. .yellow_blue > :nth-child(2) { decorator: linear-gradient(yellow, blue); }
  29. .yellow_blue > :nth-child(3) { decorator: linear-gradient(180deg, yellow, blue); }
  30. .yellow_blue > :nth-child(4) { decorator: linear-gradient(to bottom, yellow, blue); }
  31. .yellow_blue > :nth-child(5) { decorator: linear-gradient(to top, blue, yellow); }
  32. .yellow_blue > :nth-child(6) { decorator: linear-gradient(to bottom, yellow 0%, blue 100%); }
  33. .yellow_blue-angle > :nth-child(1) { decorator: linear-gradient(135deg, yellow, blue); }
  34. .yellow_blue-angle > :nth-child(2) { decorator: linear-gradient(-45deg, blue, yellow); }
  35. .three_color > :nth-child(1) { decorator: linear-gradient(yellow, blue 20%, #0f0); }
  36. .overlapping_gradients > :nth-child(1) { decorator: linear-gradient(to bottom, #00f3, #0001, #00f3), linear-gradient(to top right, red, blue); }
  37. .corner_to_corner > :nth-child(1) { decorator: linear-gradient(to top right, red, white, blue); }
  38. .corner_to_corner > :nth-child(2) { decorator: linear-gradient(to bottom right, red, white, blue); }
  39. .corner_to_corner > :nth-child(3) { decorator: linear-gradient(to bottom left, red, white, blue); }
  40. .corner_to_corner > :nth-child(4) { decorator: linear-gradient(to top left, red, white, blue); }
  41. .corner_to_corner > :nth-child(5) { decorator: linear-gradient(to top right, red 49%, white, blue 51%); }
  42. .corner_to_corner > :nth-child(6) { decorator: linear-gradient(to bottom right, red 49%, white, blue 51%); }
  43. .corner_to_corner > :nth-child(7) { decorator: linear-gradient(to bottom left, red 48%, white, blue 52%); width: 50dp; }
  44. .corner_to_corner > :nth-child(8) { decorator: linear-gradient(to top left, red 48%, white, blue 52%); width: 50dp; }
  45. .repeating > :nth-child(1) { decorator: repeating-linear-gradient(50deg, red, white, blue 20%); }
  46. .repeating > :nth-child(2) { decorator: repeating-linear-gradient(red, blue 20px, red 40px); }
  47. .premultiplied_alpha > :nth-child(1) { decorator: linear-gradient(90deg, red, transparent, blue); background: #fff; }
  48. .premultiplied_alpha > :nth-child(2) { decorator: linear-gradient(90deg, red, white, blue); }
  49. .multiple_locations_per_color > :nth-child(1) { decorator: linear-gradient(to right, red, white 40% 60%, blue); }
  50. </style>
  51. </head>
  52. <body>
  53. Yellow (top) to blue (bottom) [equivalent]
  54. <group class="yellow_blue">
  55. <div/>
  56. <div/>
  57. <div/>
  58. <div/>
  59. <div/>
  60. <div/>
  61. </group>
  62. Yellow (top-left) to blue (bottom-right) [equivalent]
  63. <group class="yellow_blue-angle">
  64. <div/>
  65. <div/>
  66. </group>
  67. Yellow (top), blue, green (bottom)
  68. <group class="three_color">
  69. <div/>
  70. </group>
  71. Multiple overlapping gradients
  72. <group class="overlapping_gradients">
  73. <div/>
  74. </group>
  75. Corner-to-corner, first: red (bottom-left), white, blue (top-right)
  76. <group class="corner_to_corner">
  77. <div/>
  78. <div/>
  79. <div/>
  80. <div/>
  81. <div/>
  82. <div/>
  83. <div/>
  84. <div/>
  85. </group>
  86. Repeating linear gradients
  87. <group class="repeating">
  88. <div/>
  89. <div/>
  90. </group>
  91. Red (left), white, blue (right). Should not show any grayish transition colors if the backend correctly interpolates in premultiplied alpha space.
  92. <group class="premultiplied_alpha">
  93. <div/>
  94. <div/>
  95. </group>
  96. Multiple locations per color
  97. <group class="multiple_locations_per_color">
  98. <div/>
  99. </group>
  100. </body>
  101. </rml>