List<Color> (@NotNull Color color1, @NotNull Color color2, int colorsBetweenAnchors) { assert colorsBetweenAnchors >= 0; List<Color> result = new ArrayList<>(colorsBetweenAnchors + 2); result.add(color1); for (int i = 1; i <= colorsBetweenAnchors; i++) { float ratio = (float)i / (colorsBetweenAnchors + 1); //noinspection UseJBColor result.add(new Color( ratio(color1.getRed(), color2.getRed(), ratio), ratio(color1.getGreen(), color2.getGreen(), ratio), ratio(color1.getBlue(), color2.getBlue(), ratio) )); } result.add(color2); return result; }