Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Merge pull request #73 from mhearne-usgs/colormap
Browse files Browse the repository at this point in the history
Added an option to color palette class to return 8-bit RGBA arrays; r…
  • Loading branch information
emthompson-usgs authored Apr 18, 2018
2 parents c31519c + b46ac15 commit a814677
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 261 deletions.
4 changes: 4 additions & 0 deletions impactutils/colors/cpalette.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def getDataColor(self, value, color_format='mlab'):
- '255' Return a 4 element tuple of (R,G,B,A) with integer
values betwen 0 and 255.
- 'hex' Return an HTML-style hex color specification (#RRGGBB).
- 'array' Return an RGBA array of the same 1 or 2D dimensions as value.
Returns:
The color value associated with the input data value.
Expand All @@ -327,6 +328,9 @@ def getDataColor(self, value, color_format='mlab'):
elif color_format == '255':
color255 = tuple([int(c * 255) for c in color])
return color255
elif color_format == 'array':
rgba = np.uint8(color*255)
return rgba
elif color_format == 'hex':
color255 = [int(c * 255) for c in color]
hexcolor = ('#%02x%02x%02x'
Expand Down
Loading

0 comments on commit a814677

Please sign in to comment.