Skip to content

Fix Color Lines with a single color stop, and multiple stops all at the same stop offset #25

Open
@justvanrossum

Description

@justvanrossum

See also the comment here:

def _normalizeColorLine(colorLine):
stops = [stopOffset for stopOffset, color in colorLine]
minStop = min(stops)
maxStop = max(stops)
if minStop != maxStop:
stopExtent = maxStop - minStop
colorLine = [
((stopOffset - minStop) / stopExtent, color)
for stopOffset, color in colorLine
]
else:
# Degenerate case. minStop and maxStop are used to reposition
# the gradients parameters (points, radii, angles), through
# interpolation. By setting minStop and maxStop to 0 and 1,
# we at least won't mess up the parameters.
# FIXME: should the gradient simply not be drawn in this case?
# 1. If there's only one color stop, we can just draw a solid
# color.
# 2. If there are > 1 color stops all at the same color stop
# offset, things get interesting: everything "to the left"
# should get color[0], everything "to the right" should get
# color[-1]. If there are more than 2 color stops, all but the
# first and last should be ignored.
minStop, maxStop = 0, 1
return minStop, maxStop, colorLine

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions