Skip to content

Commit

Permalink
Merge pull request #634 from girder/test-tilesource-coloring
Browse files Browse the repository at this point in the history
Make test tile source color more consistent across scale.
  • Loading branch information
manthey authored Aug 12, 2021
2 parents e7b4963 + 554de4a commit 903dd61
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sources/test/large_image_source_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,20 @@ def getInternalMetadata(self, **kwargs):

@methodcache()
def getTile(self, x, y, z, *args, **kwargs):
widthCount = 2 ** z
frame = int(kwargs.get('frame') or 0)
self._xyzInRange(x, y, z, frame, len(self._frames) if hasattr(self, '_frames') else None)

if not (self.minLevel <= z <= self.maxLevel):
raise TileSourceException('z layer does not exist')

xFraction = float(x) / (widthCount - 1) if z != 0 else 0
yFraction = float(y) / (widthCount - 1) if z != 0 else 0
xFraction = (x + 0.5) * self.tileWidth * 2 ** (self.levels - 1 - z) / self.sizeX
yFraction = (y + 0.5) * self.tileHeight * 2 ** (self.levels - 1 - z) / self.sizeY
fFraction = yFraction
if hasattr(self, '_frames'):
fFraction = float(frame) / (len(self._frames) - 1)

backgroundColor = colorsys.hsv_to_rgb(
h=(0.99 * xFraction),
h=xFraction,
s=(0.3 + (0.7 * fFraction)),
v=(0.3 + (0.7 * yFraction)),
)
Expand All @@ -193,7 +192,7 @@ def getTile(self, x, y, z, *args, **kwargs):
imageDraw = ImageDraw.Draw(image)

if self.fractal:
self.fractalTile(image, x, y, widthCount, rgbColor)
self.fractalTile(image, x, y, 2 ** z, rgbColor)

fontsize = 0.15
text = 'x=%d\ny=%d\nz=%d' % (x, y, z)
Expand Down

0 comments on commit 903dd61

Please sign in to comment.