Skip to content

Commit

Permalink
updated force colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Arohan Ajit authored and Arohan Ajit committed Oct 21, 2024
1 parent d2be76b commit 2321064
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions scripts/d.rast.edit/d.rast.edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,28 +647,9 @@ def update_status(self, row, col):
if self.angles:
self.status["aspect"] = self.angles[row][col]

def force_color(self, val):
run("g.region", rows=1, cols=1)
run("r.mapcalc", expression="%s = %d" % (self.tempmap, val))
run("r.colors", map=self.tempmap, rast=self.inmap)
run("r.out.ppm", input=self.tempmap, out=self.tempfile)
run("g.remove", flags="f", type="raster", name=self.tempmap)

tempimg = wx.Image(self.tempfile)
gs.try_remove(self.tempfile)

rgb = tempimg.get(0, 0)
color = "#%02x%02x%02x" % rgb
self.colors[val] = color
tempimg.delete()

def get_color(self, val):
if val not in self.colors:
try:
self.force_color(val)
except ValueError:
self.colors[val] = "#ffffff"

self.colors[val] = "#ffffff"
return self.colors[val]

def refresh_canvas(self):
Expand Down

0 comments on commit 2321064

Please sign in to comment.