From 554de4adf71cb5150cd1a016c20081271ae674fd Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 12 Aug 2021 10:39:56 -0400 Subject: [PATCH] Make test tile source color more consistent across scale. --- sources/test/large_image_source_test/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sources/test/large_image_source_test/__init__.py b/sources/test/large_image_source_test/__init__.py index 9a199bc87..c1699fc64 100644 --- a/sources/test/large_image_source_test/__init__.py +++ b/sources/test/large_image_source_test/__init__.py @@ -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)), ) @@ -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)