How to add gradient color stops

Manually adding a color stop
The default gradientStops.add() method
var gStops = selection[0].fillColor.gradient.gradientStops,
beforeLastStop = gStops[gStops.length - 2],
lastStop = gStops[gStops.length - 1],
oldPos = lastStop.rampPoint;
var newStop = gStops.add();lastStop.rampPoint = beforeLastStop.rampPoint + (oldPos — beforeLastStop.rampPoint) / 2;gStops = selection[0].fillColor.gradient.gradientStops;
lastStop = gStops[gStops.length — 1];
lastStop.rampPoint = oldPos;
Improving the gradientStops.add() method

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store