Files
jabyengine/src/Tools/tim_tool/ui/vram-components.slint
2025-03-03 20:28:46 +01:00

47 lines
1.2 KiB
Plaintext

// TODO: Maybe make them inherit Windows...?
component VRAMSegment inherits Rectangle {
in property <image> img;
in property <int> clip_x;
in property <int> clip_y;
in property <float> scale: 1.0;
width: 64px*scale;
height: 256px*scale;
clip: true;
Image {
source: img;
x: -root.clip_x*1px*scale;
y: -root.clip_y*1px*scale;
width: img.width*1px*scale;
height: img.height*1px*scale;
image-rendering: pixelated;
}
}
export component VRAMArea inherits Rectangle {
in property <image> img;
in property <int> img_x;
in property <int> img_y;
in property <float> scale: 1.0;
width: ((64*16+15)*1px)*scale;
height: ((256*2+1)*1px)*scale;
for idx in 32 : VRAMSegment {
x: (root.get_x(idx)*(64px + 1px))*scale;
y: (root.get_y(idx)*(256px + 1px))*scale;
img: img;
clip_x: (root.get_x(idx)*64) - root.img_x;
clip_y: (root.get_y(idx)*256) - root.img_y;
scale: root.scale;
}
function get_x(idx: int) -> int {
return mod(idx, 16);
}
function get_y(idx: int) -> int {
return floor(idx/16);
}
}