-
-
Save watous/ffd299a322657673bfd0b5d3c4e14e19 to your computer and use it in GitHub Desktop.
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="600" height="600" viewBox="-10 -10 120 120"> | |
<style> | |
#rgb-triangle { isolation: isolate; } | |
#rgb-triangle>* { mix-blend-mode: screen; } | |
</style> | |
<defs> | |
<polygon id="triangle" points="0,0 100,0 50,86.6" stroke="none"/> | |
<linearGradient id="red" x1="50" y1="86.6" x2="50" y2="0" gradientUnits="userSpaceOnUse"> | |
<stop offset="0%" stop-color="#f00" /> | |
<stop offset="100%" stop-color="#000" /> | |
</linearGradient> | |
<linearGradient id="green" x1="0" y1="0" x2="75" y2="43.3" gradientUnits="userSpaceOnUse"> | |
<stop offset="0%" stop-color="#0f0" /> | |
<stop offset="100%" stop-color="#000" /> | |
</linearGradient> | |
<linearGradient id="blue" x1="100" y1="0" x2="25" y2="43.3" gradientUnits="userSpaceOnUse"> | |
<stop offset="0%" stop-color="#00f" /> | |
<stop offset="100%" stop-color="#000" /> | |
</linearGradient> | |
</defs> | |
<g id="rgb-triangle" transform="matrix(1 0 0 -1 0 90)"> | |
<use href="#triangle" fill="url('#green')"/> | |
<use href="#triangle" fill="url('#blue')"/> | |
<use href="#triangle" fill="url('#red')"/> | |
</g> | |
</svg> |
@donhatch Now that I look at it again I think it actually needs some fixing. The rotations of gradients don't work as I expected.
As for your suggestion, it's quite possible that it will look better. But I think the purpose of this triangle was to be linear in the numbers, e.g. to have the color (255/3, 255/3, 255/3) in the center, which works with sRGB I guess (?).
"(?)" is right! I do not claim to understand what it's thinking-- multiple spooky layers of gamma correction and anticorrection everywhere, I suppose. But you're right, in the end sRGB seems to make it come out with #555555 in the center (and e.g. #800080 in the middle of the magenta edge), which seems like what we want, whereas linearRGB seems to make them come out gamma-adjusted to be somewhat brighter than that in the end.
I have at least fixed the gradients.
Nice triangle! I think it'll look even better (and it'll interact with subsequent filter operations such as feColorMatrix better) if you add to the style: