I have an SVG with the following:
<linearGradient id="path-2_2_" gradientUnits="userSpaceOnUse" x1="-275.652" y1="410.9046" x2="-275.0113" y2="412.0578" gradientTransform="matrix(46 0 0 -45.9998 12690 18947.9102)">
<stop offset="0" style="stop-color: rgb(248, 64, 24);"></stop>
<stop offset="0.6458" style="stop-color: rgb(248, 64, 24); stop-opacity: 0.6009;"></stop>
<stop offset="1" style="stop-color: rgb(248, 64, 24); stop-opacity: 0.2527;"></stop>
</linearGradient>
I'm attempting to convert it to a CSS background, but it isn't quite coming out right:
background: linear-gradient(
rgb(248, 64, 24) 0%
rgba(248, 64, 24 0.60) 65%,
rgba(248, 64, 24 0.25) 100%,
);
The gradientTransform is doing something, but I'm not sure as to what, and how to replicate it in my CSS style.
To obtain the final gradient you need to first consider x1/y1/x2/y2 that are defining the direction (until now it's easy) then you need to be able to understand the transformation done to the gradient after using gradientTransform which is not trivial. So either you are an SVG and Mathematician guru and you can do the calculation to find the values you need to use in the CSS or you use a tool that can convert your gradient (like http://gradientfinder.com/) or you look at the gradient and you try to approximate it.
Personally I can do the approximation:
.box {
background:
linear-gradient(30deg, rgb(248, 64, 24) 30%, rgba(248, 64, 24, 0.60) 42%, rgba(248, 64, 24, 0.25) 50%);
width: 400px;
height: 150px;
}
<svg height="150" width="400">
<defs>
<linearGradient id="path-2_2_" gradientUnits="userSpaceOnUse" x1="-275.652" y1="410.9046" x2="-275.0113" y2="412.0578" gradientTransform="matrix(46 0 0 -45.9998 12690 18947.9102)">
<stop offset="0" style="stop-color: rgb(248, 64, 24);"></stop>
<stop offset="0.6458" style="stop-color: rgb(248, 64, 24); stop-opacity: 0.6009;"></stop>
<stop offset="1" style="stop-color: rgb(248, 64, 24); stop-opacity: 0.2527;"></stop>
</linearGradient>
</defs>
<rect x="0" y="0" width="400" height="150" fill="url(#path-2_2_)" />
</svg>
<div class="box">
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With