shader_linear_gradient.rml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. .corner_to_corner > :nth-child(1) { decorator: linear-gradient(to top right, red, white, blue); }
  37. .corner_to_corner > :nth-child(2) { decorator: linear-gradient(to bottom right, red, white, blue); }
  38. .corner_to_corner > :nth-child(3) { decorator: linear-gradient(to bottom left, red, white, blue); }
  39. .corner_to_corner > :nth-child(4) { decorator: linear-gradient(to top left, red, white, blue); }
  40. .corner_to_corner > :nth-child(5) { decorator: linear-gradient(to top right, red 49%, white, blue 51%); }
  41. .corner_to_corner > :nth-child(6) { decorator: linear-gradient(to bottom right, red 49%, white, blue 51%); }
  42. .corner_to_corner > :nth-child(7) { decorator: linear-gradient(to bottom left, red 48%, white, blue 52%); width: 50dp; }
  43. .corner_to_corner > :nth-child(8) { decorator: linear-gradient(to top left, red 48%, white, blue 52%); width: 50dp; }
  44. .repeating > :nth-child(1) { decorator: repeating-linear-gradient(50deg, red, white, blue 20%); }
  45. .repeating > :nth-child(2) { decorator: repeating-linear-gradient(red, blue 20px, red 40px); }
  46. .premultiplied_alpha > :nth-child(1) { decorator: linear-gradient(90deg, red, transparent, blue); background: #fff; }
  47. .premultiplied_alpha > :nth-child(2) { decorator: linear-gradient(90deg, red, white, blue); }
  48. .multiple_locations_per_color > :nth-child(1) { decorator: linear-gradient(to right, red, white 40% 60%, blue); }
  49. </style>
  50. </head>
  51. <body>
  52. Yellow (top) to blue (bottom) [equivalent]
  53. <group class="yellow_blue">
  54. <div/>
  55. <div/>
  56. <div/>
  57. <div/>
  58. <div/>
  59. <div/>
  60. </group>
  61. Yellow (top-left) to blue (bottom-right) [equivalent]
  62. <group class="yellow_blue-angle">
  63. <div/>
  64. <div/>
  65. </group>
  66. Yellow (top), blue, green (bottom)
  67. <group class="three_color">
  68. <div/>
  69. </group>
  70. Corner-to-corner, first: red (bottom-left), white, blue (top-right)
  71. <group class="corner_to_corner">
  72. <div/>
  73. <div/>
  74. <div/>
  75. <div/>
  76. <div/>
  77. <div/>
  78. <div/>
  79. <div/>
  80. </group>
  81. Repeating linear gradients
  82. <group class="repeating">
  83. <div/>
  84. <div/>
  85. </group>
  86. Red (left), white, blue (right). Should not show any grayish transition colors if the backend correctly interpolates in premultiplied alpha space.
  87. <group class="premultiplied_alpha">
  88. <div/>
  89. <div/>
  90. </group>
  91. Multiple locations per color
  92. <group class="multiple_locations_per_color">
  93. <div/>
  94. </group>
  95. </body>
  96. </rml>