The plot surface moves here from Kryon, which no longer ships it. Plot exports PlotWidget for apps that draw their own series next to the Plot charts, and every Kryon import names its package (kryon/Kryon, kryon/session, ...). The widget's behavior test runs as a portable bundle and in Go, binding Kryon's host capabilities by import path.
123 lines
3.7 KiB
Ziran
123 lines
3.7 KiB
Ziran
#import "kryon/drawing_props"
|
|
#import "kryon/geometry"
|
|
|
|
backgrounds: s32;
|
|
marks: s32;
|
|
outlines: s32;
|
|
lines: s32;
|
|
labels: s32;
|
|
failed: bool;
|
|
|
|
#program_export
|
|
MeasureGlyphWidth :: (value: string, font: s32, typeface: string) -> s32 {
|
|
if font != 14 || typeface.count != 0 { failed = true }
|
|
return cast(s32)value.count * 8
|
|
}
|
|
|
|
#program_export
|
|
RasterRoundedRectangle :: (bounds: Rectangle, radius: float32,
|
|
segments: s32, color: Color) {
|
|
unused segments
|
|
if bounds.x < 10.0 || bounds.y < 10.0 ||
|
|
bounds.x + bounds.width > 110.0 ||
|
|
bounds.y + bounds.height > 150.0 { failed = true }
|
|
if radius == 0.0 {
|
|
if color.r != cast(u8)59 || color.g != cast(u8)96 ||
|
|
color.b != cast(u8)155 || color.a != cast(u8)255 {
|
|
failed = true
|
|
}
|
|
which: s32 = marks % 3
|
|
if which == 0 && (bounds.x <= 10.9 || bounds.x >= 11.1 ||
|
|
bounds.y != 120.0 || bounds.height != 30.0) { failed = true }
|
|
if which == 1 && (bounds.x <= 44.2 || bounds.x >= 44.5 ||
|
|
bounds.y != 90.0 || bounds.height != 60.0) { failed = true }
|
|
if which == 2 && (bounds.x <= 77.5 || bounds.x >= 77.8 ||
|
|
bounds.y != 135.0 || bounds.height != 15.0) { failed = true }
|
|
marks += 1
|
|
} else {
|
|
if radius != 4.0 || color.r != cast(u8)245 ||
|
|
color.g != cast(u8)245 || color.b != cast(u8)245 ||
|
|
color.a != cast(u8)255 { failed = true }
|
|
backgrounds += 1
|
|
}
|
|
}
|
|
|
|
#program_export
|
|
RasterRoundedRectangleOutline :: (bounds: Rectangle, radius: float32,
|
|
segments: s32, width: float32, color: Color) {
|
|
unused segments
|
|
if bounds.x != 10.0 || bounds.width != 100.0 ||
|
|
bounds.height != 60.0 ||
|
|
(bounds.y != 10.0 && bounds.y != 90.0) ||
|
|
radius != 4.0 || width != 1.0 ||
|
|
color.r != cast(u8)115 || color.g != cast(u8)115 ||
|
|
color.b != cast(u8)115 || color.a != cast(u8)255 { failed = true }
|
|
outlines += 1
|
|
}
|
|
|
|
#program_export
|
|
RasterLine :: (line: Rectangle, color: Color) {
|
|
if line.x < 10.0 || line.x + line.width > 110.0 ||
|
|
line.y < 10.0 || line.y > 70.0 ||
|
|
line.y + line.height < 10.0 || line.y + line.height > 70.0 ||
|
|
color.r != cast(u8)59 || color.g != cast(u8)96 ||
|
|
color.b != cast(u8)155 || color.a != cast(u8)255 { failed = true }
|
|
lines += 1
|
|
}
|
|
|
|
#program_export
|
|
RasterText :: (value: string, x: s32, y: s32, font: s32,
|
|
color: Color) {
|
|
unused value
|
|
unused x
|
|
unused y
|
|
unused font
|
|
unused color
|
|
failed = true
|
|
}
|
|
|
|
#program_export
|
|
RasterTextClipped :: (value: string, x: s32, y: s32, font: s32,
|
|
color: Color, clip: Rectangle) {
|
|
if value.count == 0 || x < 10 || x > 110 || y < 10 || y > 150 ||
|
|
font != 14 || clip.x != 10.0 || clip.width != 100.0 ||
|
|
(clip.y != 10.0 && clip.y != 90.0) || clip.height != 60.0 ||
|
|
color.r != cast(u8)23 || color.g != cast(u8)23 ||
|
|
color.b != cast(u8)23 || color.a != cast(u8)255 { failed = true }
|
|
labels += 1
|
|
}
|
|
|
|
#program_export
|
|
RasterImage :: (path: string, texture_id: u32,
|
|
source: Rectangle, destination: Rectangle, clip: Rectangle,
|
|
origin: Vector2, rotation: float32, radius: float32, tint: Color) {
|
|
unused path
|
|
unused texture_id
|
|
unused source
|
|
unused destination
|
|
unused clip
|
|
unused origin
|
|
unused rotation
|
|
unused radius
|
|
unused tint
|
|
failed = true
|
|
}
|
|
|
|
#program_export
|
|
PlotHostFailed :: () -> bool { return failed }
|
|
|
|
#program_export
|
|
PlotBackgrounds :: () -> s32 { return backgrounds }
|
|
|
|
#program_export
|
|
PlotMarks :: () -> s32 { return marks }
|
|
|
|
#program_export
|
|
PlotOutlines :: () -> s32 { return outlines }
|
|
|
|
#program_export
|
|
PlotLineCount :: () -> s32 { return lines }
|
|
|
|
#program_export
|
|
PlotLabels :: () -> s32 { return labels }
|