Skip to content

Region

import numpy as np

from fdray import *

x = np.zeros((3, 4, 5), dtype=np.uint8)
x[1:, 0, 0] = 1
x[0, 1:, 0] = 2
x[0, 0, 1:] = 3


def color_map(x):
    return ColorMap({0: Color("white"), 1: Color(x)})


region = Union.from_region(
    x,
    Box(-0.4, 0.4) - Box(0, 1),
    mapping={
        1: Pigment("granite", color_map("red")),
        2: Pigment("wood", color_map("blue")),
        3: Pigment("agate", color_map("green")),
    },
)

Scene(
    Camera(40, 20, view_scale=3.5),
    LightSource(0, "white"),
    region,
).render(500, 500)