Answer the question
In order to leave comments, you need to log in
Canvas: Is it possible to get the ColorStop value from a gradient?
I am already almost sure that the answer to my question is “no”, because. I googled a lot - but I'll ask just in case ...
// формируем градиент
var lingrad = ctx.createLinearGradient(0, 0, 0, 200);
lingrad.addColorStop(0, '#FFFFFF');
lingrad.addColorStop(0.5, '#8080FF');
lingrad.addColorStop(1, '#000000');
// а получить из готового? что-то наподобии такого:
var color = lingrad.getColorStop(0).color; // #FFFFFF
var position = lingrad.getColorStop(0).position; // 0
Answer the question
In order to leave comments, you need to log in
As far as I know, the Canvas API is pretty “low-level” - if you want convenience, you need to “wrap” the methods yourself. Write a library, so to speak.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question