From ee4f37b9b78aaa88a05755fb6bf915d1d1566fbf Mon Sep 17 00:00:00 2001 From: "Egli Adrian (IT-SCI-API-PFI)" <adrian.egli@sbb.ch> Date: Tue, 28 May 2019 08:33:52 +0200 Subject: [PATCH] rendering: color fix --- flatland/utils/rendertools.py | 5 +++-- flatland/utils/svg.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/flatland/utils/rendertools.py b/flatland/utils/rendertools.py index 4256f0d2..f2200b97 100644 --- a/flatland/utils/rendertools.py +++ b/flatland/utils/rendertools.py @@ -781,8 +781,9 @@ class RenderTool(object): position = agent.position direction = agent.direction old_direction = agent.direction - - self.gl.setAgentAt(iAgent, *position, old_direction, direction) + + cmap = self.gl.get_cmap('hsv', lut=max(len(self.env.agents), len(self.env.agents_static) + 1)) + self.gl.setAgentAt(iAgent, *position, old_direction, direction,color=cmap(iAgent)) if show: self.gl.show() diff --git a/flatland/utils/svg.py b/flatland/utils/svg.py index 89730af2..0a6b895d 100644 --- a/flatland/utils/svg.py +++ b/flatland/utils/svg.py @@ -60,7 +60,7 @@ class SVG(object): sNewStyles = "\n" for sKey, sValue in self.dStyles.items(): if sKey == style_name: - sValue = "fill:#" + "".join([format(col, "#04x")[2:] for col in color]) + ";" + sValue = "fill:#" + "".join([ ('{:#04x}'.format(int(255.0*col))[2:4]) for col in color[0:3]]) + ";" sNewStyle = "\t.st" + sKey + "{" + sValue + "}\n" sNewStyles += sNewStyle -- GitLab