///|
fn main {
// Define a 10x10 canvas with a white background (0xffffff)
let width = 10
let height = 10
let pixels = Array::make(width * height, 0xffffff)
// Draw a red square (0xff0000) from (2,2) to (5,5)
for y in 2..<=5 {
for x in 2..<=5 {
pixels[y * width + x] = 0xff0000
}
}
// Draw a green square (0x00ff00) from (6,6) to (8,8)
for y in 6..<=8 {
for x in 6..<=8 {
pixels[y * width + x] = 0x00ff00
}
}
let img = @core.Image::new(width, height, pixels)
// Run trace planning with epsilon = 0.5 (simplifies boundary, ignores background)
let manifest = @trace.plan_trace(img, 0.5, bg_color=0xffffff)
// Output details
println("Vector tracing planning complete!")
println("Total layers traced: \{manifest.layers.length()}")
for layer in manifest.layers {
let r = (layer.color >> 16) & 0xff
let g = (layer.color >> 8) & 0xff
let b = layer.color & 0xff
println("Layer Color: R=\{r} G=\{g} B=\{b}")
println("Paths: \{layer.paths.length()}")
for i, path in layer.paths {
println(" Path #\{i + 1}: \{path.to_svg_d()}")
}
}
// Print SVG XML representation
println("\nGenerated SVG Output:")
println(manifest.to_svg())
}