Add optional crop functionality to drawCropOutLine in machine_1

- Update `drawCropOutLine` to accept a `crop` parameter for conditional cropping alongside outline rendering.
- Adjust crop outline coordinates for improved alignment.
- Introduce logic to calculate and apply crop dimensions when `crop` is enabled.
This commit is contained in:
Jeppe Bundgaard
2026-01-29 16:03:32 +01:00
parent 71e2519e8b
commit 8972db3469
@@ -76,10 +76,10 @@ class machine_1 extends dynamicimages_image
$this->drawHighlightedButtons();
$this->drawAsset($this->getAsset(self::IMAGE_POWER_BUTTON), 0, 0);
$this->drawHighlightedStartButton();
$this->drawCropOutLine();
$this->drawCropOutLine(true);
}
public function drawCropOutLine(): void
public function drawCropOutLine(bool $crop = false): void
{
$line_template = [
'x' => [
@@ -98,15 +98,15 @@ class machine_1 extends dynamicimages_image
'to' => 6000
],
'y' => [
'from' => 260,
'to' => 260
'from' => 262,
'to' => 262
],
];
// Define the left crop line
$left_line = [
'x' => [
'from' => 193,
'to' => 193
'from' => 194,
'to' => 194
],
'y' => [
'from' => 0,
@@ -142,13 +142,24 @@ class machine_1 extends dynamicimages_image
$bottom_line
];
// Draw the crop outline
foreach ($lines as $line) {
$x1 = (int)$line['x']['from'];;
$y1 = (int)$line['y']['from'];;
$x2 = (int)$line['x']['to'];;
$y2 = (int)$line['y']['to'];;
$this->drawLine($x1, $y1, $x2, $y2, 'rgba(255,0,0,0.75)', 1);
// If the crop parameter is false, just draw the outline
if (!$crop) {
// Draw the crop outline
foreach ( $lines as $line ) {
$x1 = (int)$line['x']['from'];;
$y1 = (int)$line['y']['from'];;
$x2 = (int)$line['x']['to'];;
$y2 = (int)$line['y']['to'];;
$this->drawLine($x1, $y1, $x2, $y2, 'rgba(255,0,0,0.75)', 1);
}
}
// If the crop parameter is true, apply the crop
else {
$cropX = (int)$left_line['x']['from'];
$cropY = (int)$top_line['y']['from'];
$cropWidth = (int)6000 - $cropX - (6000 - (int)$right_line['x']['from']);
$cropHeight = (int)4500 - $cropY - (4500 - (int)$bottom_line['y']['from']);
$this->crop($cropWidth, $cropHeight, $cropX, $cropY);
}
}