59 lines
2.6 KiB
Ziran
59 lines
2.6 KiB
Ziran
Pixmap :: #import "kryon/pixmap";
|
|
#import "kryon/drawing_props"
|
|
#import "kryon/geometry"
|
|
pixels: [36000]u32;
|
|
BeginPaint :: () {
|
|
if !Pixmap.PixmapBeginInto(cast(u32)0, 300, 120, pixels[:], true) { failed = true }
|
|
}
|
|
EndPaint :: () { Pixmap.PixmapEndInto() }
|
|
PixelIs :: (x: s32, y: s32, rgba: u32) -> bool {
|
|
argb := (rgba >> 8) | ((rgba & cast(u32)255) << 24)
|
|
return pixels[y * 300 + x] == argb
|
|
}
|
|
HasInk :: (top: s32, rgba: u32) -> bool {
|
|
for y: top..top + 15 {
|
|
for x: 18..42 { if PixelIs(cast(s32)x, cast(s32)y, rgba) { return true } }
|
|
}
|
|
return false
|
|
}
|
|
labels: s32;
|
|
failed: bool;
|
|
#program_export "TableTestMeasureGlyphWidth"
|
|
MeasureGlyphWidth :: (text: string, font: s32, face: string) -> s32 { return cast(s32)text.count * 8 }
|
|
#program_export "TableTestMeasureGlyphLineHeight"
|
|
MeasureGlyphLineHeight :: (font: s32, face: string) -> s32 { return 14 }
|
|
ValidateClip :: (bounds: Rectangle) {
|
|
if bounds.x < 10.0 || bounds.y < 10.0 || bounds.x + bounds.width > 250.0 || bounds.y + bounds.height > 90.0 { failed = true }
|
|
}
|
|
#program_export "TableTestRasterRoundedRectangle"
|
|
RasterRoundedRectangle :: (bounds: Rectangle, radius: float32, segments: s32, color: Color) {
|
|
ValidateClip(bounds)
|
|
Pixmap.RasterRoundedRectangle(bounds, radius, segments, color)
|
|
}
|
|
#program_export "TableTestRasterRoundedRectangleOutline"
|
|
RasterRoundedRectangleOutline :: (bounds: Rectangle, radius: float32, segments: s32, width: float32, color: Color) {
|
|
ValidateClip(bounds)
|
|
Pixmap.RasterRoundedRectangleOutline(bounds, radius, segments, width, color)
|
|
}
|
|
#program_export "TableTestRasterTextClipped"
|
|
RasterTextClipped :: (text: string, x: s32, y: s32, font: s32, color: Color, clip: Rectangle) {
|
|
ValidateClip(clip)
|
|
Pixmap.RasterTextClipped(text, x, y, font, color, clip)
|
|
if text != "" { labels += 1 }
|
|
}
|
|
#program_export "TableTestRasterText"
|
|
RasterText :: (text: string, x: s32, y: s32, font: s32, color: Color) { failed = true }
|
|
#program_export "TableTestRasterLine"
|
|
RasterLine :: (bounds: Rectangle, color: Color) { failed = true }
|
|
#program_export "TableTestRasterImage"
|
|
RasterImage :: (asset: string, generation: u32, source: Rectangle, destination: Rectangle, clip: Rectangle, origin: Vector2, rotation: float32, radius: float32, tint: Color) { failed = true }
|
|
|
|
// These tests do not request rotated labels.
|
|
// Fail visibly if future widget behavior begins exercising this operation.
|
|
#program_export "TableTestRasterTextRotated"
|
|
RasterTextRotated :: (value: string, x: s32, y: s32, font: s32,
|
|
color: Color, clip: Rectangle, origin: Vector2, rotation: float32,
|
|
outer_clip: Rectangle, outer_clipped: bool, emphasis: bool, italic: bool) {
|
|
failed = true
|
|
}
|