Skip to content

Commit

Permalink
Fix main bringing new StepGeometrizationResult enum
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriyvan committed May 11, 2024
1 parent 160b716 commit 45a2cd9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Sources/geometrize-cli/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,32 @@ shapeData.append(ShapeResult(score: 0, color: targetBitmap.averageColor(), shape
var counter = 0
// Here in shapeCount set count of shapes final image should have.
// Remember background is the first shape.
while shapeData.count <= shapeCount {
loop: while shapeData.count <= shapeCount {
if options.verbose {
print("Step \(counter)", terminator: "")
}
let shapeResult = runner.step(
let stepResult = runner.step(
options: runnerOptions,
shapeCreator: nil,
energyFunction: defaultEnergyFunction,
addShapePrecondition: defaultAddShapePrecondition
)
if let shapeResult {
switch stepResult {
case .success(let shapeResult):
shapeData.append(shapeResult)
if options.verbose {
print(", \(shapeResult.shape.description) added.", terminator: "")
}
} else {
case .match:
if options.verbose {
print(", geometrizing matched source image.", terminator: "")
}
break loop
case .failure:
if options.verbose {
print(", no shapes added.", terminator: "")
}
// TODO: should it break as well?
}
if options.verbose {
print(" Total count of shapes \(shapeData.count ).")
Expand Down

0 comments on commit 45a2cd9

Please sign in to comment.