"""干渉 / Interference — two sets of concentric rings and a threshold."""
import numpy as np
from PIL import Image
from _common import W, H, C, rgb, paper, cli


def render(seed):
    rng = np.random.default_rng(seed)
    c1, c2 = C["kon"], C["kinari"]
    y, x = np.mgrid[0:H, 0:W].astype(np.float32)
    p = [(W * 0.35, H * 0.4), (W * 0.66, H * 0.58)]
    v = sum(np.sin(np.hypot(x - px, y - py) / 9.5) for px, py in p)
    t = (v > 0.4)[..., None]
    a = np.where(t, np.array(rgb(c1), np.uint8), np.array(rgb(c2), np.uint8)).astype(np.uint8)
    return paper(Image.fromarray(a), rng, 4)


SEED = 97

if __name__ == "__main__":
    cli(render, SEED)
