mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
converting rgb to int
This commit is contained in:
parent
de695f4b63
commit
ffaea61874
1 changed files with 16 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import typing
|
||||
from abc import ABC, abstractmethod
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Iterable
|
||||
|
|
@ -20,6 +21,14 @@ from .plots import _SVG_COLORS
|
|||
from .surface import _BOUNDARY_TYPES
|
||||
|
||||
|
||||
def get_int_from_rgb(rgb: typing.Tuple[int, int, int]) -> int:
|
||||
"""Converts a tuple of ints into a single int"""
|
||||
red = rgb[0]
|
||||
green = rgb[1]
|
||||
blue = rgb[2]
|
||||
return (red << 16) + (green << 8) + blue
|
||||
|
||||
|
||||
class UniverseBase(ABC, IDManagerMixin):
|
||||
"""A collection of cells that can be repeated.
|
||||
|
||||
|
|
@ -401,10 +410,14 @@ class Universe(UniverseBase):
|
|||
fig.set_size_inches(width, height)
|
||||
|
||||
if outline:
|
||||
combined_rgb = np.sum(img, 2)
|
||||
|
||||
image_value = [
|
||||
[get_int_from_rgb(inner_entry) for inner_entry in outer_entry]
|
||||
for outer_entry in img
|
||||
]
|
||||
|
||||
axes.contour(
|
||||
combined_rgb.reshape(img.shape[0], img.shape[1]),
|
||||
image_value, #combined_rgb.reshape(img.shape[0], img.shape[1]),
|
||||
origin="upper",
|
||||
colors="k",
|
||||
linestyles="solid",
|
||||
|
|
@ -988,4 +1001,4 @@ class DAGMCUniverse(UniverseBase):
|
|||
clone.volume = self.volume
|
||||
clone.auto_geom_ids = self.auto_geom_ids
|
||||
clone.auto_mat_ids = self.auto_mat_ids
|
||||
return clone
|
||||
return clone
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue