package eu.jonahbauer.raytracing.render.canvas;

import eu.jonahbauer.raytracing.render.texture.Color;
import org.jetbrains.annotations.NotNull;

import java.util.function.Function;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public interface Canvas {
    int getWidth();
    int getHeight();

    void set(int x, int y, @NotNull Color color);
    @NotNull Color get(int x, int y);

    default @NotNull Stream<Color> pixels() {
        return IntStream.range(0, getHeight())
                .mapToObj(y -> IntStream.range(0, getWidth()).mapToObj(x -> get(x, y)))
                .flatMap(Function.identity());
    }
}
