///|
fn benchmark_image(width : Int, height : Int) -> @core.Image {
let pixels = Array::make(width * height, 0)
for y in 0..= 4 && x < width / 2 && y >= 4 && y < height / 2 {
0xff3344
} else if x >= width / 2 + 4 && x < width - 4 && y >= 8 && y < height - 8 {
0x33cc88
} else if (x + y) % 17 == 0 {
0x3355dd
} else {
0
}
pixels[y * width + x] = color
}
}
@core.Image::new(width, height, pixels)
}
///|
fn main {
let width = 128
let height = 128
let image = benchmark_image(width, height)
let options = {
..@trace.TraceOptions::default(),
background: Some(0),
maximum_colors: 4,
epsilon: 0.5,
}
let result = @trace.trace_with_options(image, options)
let inspection = @trace.trace_inspection(result)
let plan = @plan.plan_manifest(result.manifest)
let commands = @plan.commands_for_plan(plan)
let timing = @plan.estimate_command_timing(commands[:])
println("fixture.width=\{width}")
println("fixture.height=\{height}")
println("fixture.pixels=\{image.pixel_count()}")
println("fixture.colors=\{image.unique_colors().length()}")
println("trace.layers=\{inspection.layer_count}")
println("trace.paths=\{inspection.path_count}")
println("trace.points=\{inspection.point_count}")
println("trace.segments=\{inspection.segment_count}")
println("trace.drawing_length=\{inspection.drawing_length}")
println("plan.commands=\{commands.length()}")
println("plan.travel_length=\{plan.travel_length}")
println("plan.estimated_seconds=\{plan.estimated_seconds()}")
println("machine.estimated_seconds=\{timing.total_seconds}")
println("manifest.fingerprint=\{result.manifest.fingerprint()}")
println(
"export.svg_bytes=\{@trace.manifest_to_svg(result.manifest).length()}",
)
}