valkyrie-types 0.0.8

Shard types for valkyrie language
Documentation


trait Pixel {
    count_channel(self) -> int;
}

trait Image {
    type Pixel;
    width: int;
    height: int;
    channels: int;
    dimensions(self): (w: int, h: int, c: int) {
        (self.width, self.height, self.channels)
    }
}

class ArrayND<T> {

}

class Array0D<T> {

}

type A: A;

@refine
type Array2D<T> = ArrayND<T> {
    require d2 {
        self.dimensions.length == 2
    }
}

class ArrayViewND<N, T> {

}

class RGBColor<T, A = T> {
    r: T;
    g: T;
    b: T;
    a: A;
}

extends<T, A> RGBColor<T, A>: Pixel {

}
/// A memory-intensive, CPU-bound image
class ImageBuffer<Pixel> {
    get width: int;
    get height: int;
    get bytes: Array<u8>;

    construct(bytes: Array<u8>, width: int, height: int) -> Self {
        @native
    }
}

extends<Pixel> Image<Pixel> {
    get_pixel(mut self, int, int) -> Pixel?;
    set_pixel(mut self, int, int, pixel: Pixel) -> bool;
    map_pixels(self, f: Function(Pixel) -> Pixel) -> Self;
    all_pixels(mut self) -> ImageBufferPixels<Pixel>;
}


class ImageView<Pixel> {
    @[get, ref]
    raw: ImageBuffer<Pixel>;
    @[get]
    rect: Rectangle<int, 2>;
}


namespace package.this;

extension TargetEx: MyEx + OtherEx {
    namespace Target {
        @inject
        class TargetClass {
            get name: string;
        }
    }
}