Skip to main content
alyx
February 1, 2023
Question

How to get linear gradient params from gradientTransform?

  • February 1, 2023
  • 4 replies
  • 1336 views

Hello, there!

{
  "type": "GRADIENT_LINEAR",
  "visible": true,
  "opacity": 1,
  "blendMode": "NORMAL",
  "gradientStops": [
    { "color": { "r": 0.9468026161193848, "g": 0.7801758050918579, "b": 1, "a": 1 }, "position": 0 },
    { "color": { "r": 1, "g": 0.8026315569877625, "b": 0.7916666865348816, "a": 1 }, "position": 1 }
  ],
  "gradientTransform": [
    [0.02942134626209736, 2.29868745803833, -0.01471067313104868],
    [153.8611602783203, -179.4796142578125, -76.43058013916016]
  ]
}

and I want to generate css code which is in Inspect tab
background: linear-gradient(179.27deg, #F1C7FF 0.63%, #FFCDCA 43.59%);
how can i get these percentage?

thanks!!

This topic has been closed for replies.

4 replies

Semi_Design_UED-MED
June 25, 2023

I have the same issue

jaclyntan
New Participant
June 29, 2023

The percentage in the CSS code is each colour’s alpha property. If you wanted to retrieve them from the api you would need to target the "a" property under each color.

The colour in your CSS example doesn’t seem to be the same as the plugin code btw.

December 8, 2023

I have the same issue too

June 18, 2024

Did you get this figured out?
(working through a similar issue – but trying to retrieve xy handle positions instead of angle)