store background_rgb as 0-1 float, not 0-255 int
This commit is contained in:
parent
f82c7de5da
commit
c87780dd75
3 changed files with 4 additions and 4 deletions
|
@ -43,7 +43,7 @@ class RenderEngine(ABC):
|
|||
self.buffered_width = self.width + 2 * self.buffer
|
||||
self.buffered_height = self.height + 2 * self.buffer
|
||||
|
||||
self.background_rgb = tuple(int(background[i:i + 2], 16) for i in range(1, 6, 2))
|
||||
self.background_rgb = tuple(int(background[i:i + 2], 16)/255 for i in range(1, 6, 2))
|
||||
|
||||
# keep track which area of the image has which altitude currently
|
||||
self.altitudes = {}
|
||||
|
|
|
@ -104,7 +104,7 @@ class OpenGLWorker(threading.Thread):
|
|||
task = self._queue.get()
|
||||
|
||||
ctx = self._get_ctx(task.width*task.samples, task.height*task.samples)
|
||||
ctx.ctx.clear(*(i / 255 for i in task.background_rgb))
|
||||
ctx.ctx.clear(*task.background_rgb)
|
||||
|
||||
if task.vertices:
|
||||
vbo = ctx.ctx.buffer(task.vertices)
|
||||
|
|
|
@ -81,7 +81,7 @@ class SVGEngine(RenderEngine):
|
|||
|
||||
if self.width == 256 and self.height == 256 and not self.g:
|
||||
# create empty tile png with minimal size, indexed color palette with only one entry
|
||||
plte = b'PLTE' + bytearray(self.background_rgb)
|
||||
plte = b'PLTE' + bytearray(tuple(int(i*255) for i in self.background_rgb))
|
||||
return (b'\x89PNG\r\n\x1a\n' +
|
||||
b'\x00\x00\x00\rIHDR\x00\x00\x01\x00\x00\x00\x01\x00\x01\x03\x00\x00\x00f\xbc:%\x00\x00\x00\x03' +
|
||||
plte + zlib.crc32(plte).to_bytes(4, byteorder='big') +
|
||||
|
@ -103,7 +103,7 @@ class SVGEngine(RenderEngine):
|
|||
context = cairocffi.Context(surface)
|
||||
|
||||
# set background color
|
||||
context.set_source(cairocffi.SolidPattern(*(i/255 for i in self.background_rgb)))
|
||||
context.set_source(cairocffi.SolidPattern(*self.background_rgb))
|
||||
context.paint()
|
||||
|
||||
# paste buffered immage with offset
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue