Add start button rendering and update highlighted button logic in machine_1
- Introduce `drawHighlightedStartButton` method for dynamic rendering of the start button with step indicators. - Add new constants for `IMAGE_BUTTON_HIGHLIGHTED_GREEN`, `IMAGE_BUTTON_HIGHLIGHTED_GREY`, and `IMAGE_BUTTON_HIGHLIGHTED_COMPLETED`. - Refactor `getHighlightedAssetName` to provide conditional asset selection based on step completion. - Implement `drawStepThumb` for rendering step indicators on the washing thumb. - Adjust highlighted button logic to dynamically incorporate step counts and completion states. - Add new assets for highlighted button states (`completed`, `green`, `grey`).
This commit is contained in:
BIN
Binary file not shown.
|
After Width: | Height: | Size: 499 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 507 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 478 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 479 KiB |
@@ -14,8 +14,11 @@ class machine_1 extends dynamicimages_image
|
||||
const IMAGE_WASH_PROGRAMS = 'machine_1_programs_wheel_transparent.png';
|
||||
const IMAGE_BUTTON_HIGHLIGHTED = 'machine_1_button_highlighted_blue.png'; // 'machine_1_button_highlighted_transparent.png';
|
||||
const IMAGE_BUTTON_HIGHLIGHTED_BLUE = 'machine_1_button_highlighted_blue.png';
|
||||
const IMAGE_BUTTON_HIGHLIGHTED_GREY = 'machine_1_button_highlighted_grey.png';
|
||||
const IMAGE_BUTTON_HIGHLIGHTED_COMPLETED = 'machine_1_button_highlighted_completed_grey.png';
|
||||
const IMAGE_BUTTON_HIGHLIGHTED_GREEN = 'machine_1_button_highlighted_green.png';
|
||||
// Thumb
|
||||
public int $thumb_position = 9; // 0-11 (default: 0 = up = 270 degrees)
|
||||
public int $thumb_position = 1; // 0-11 (default: 0 = up = 270 degrees)
|
||||
public int $thumb_size = 1550; // height and width of the thumb
|
||||
// Buttons
|
||||
public int $button_highlight_size = 295; // size of the highlighted button
|
||||
@@ -30,8 +33,12 @@ class machine_1 extends dynamicimages_image
|
||||
];
|
||||
// Reset button
|
||||
public int $reset_button_highlight_size = 380; // size of the highlighted reset button
|
||||
// Start button
|
||||
public int $start_button_highlight_size = 300; // size of the highlighted start button
|
||||
// Button counts
|
||||
public int $button_counter = 0; // Is incremented every time a button is drawn
|
||||
// Current step
|
||||
public int $current_step = 3; // No "click counter" completed yet = 0
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
@@ -46,6 +53,8 @@ class machine_1 extends dynamicimages_image
|
||||
new dynamicimages_asset(self::getAssetPath(self::IMAGE_WASH_PROGRAMS)),
|
||||
new dynamicimages_asset(self::getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED)),
|
||||
new dynamicimages_asset(self::getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED_BLUE)),
|
||||
new dynamicimages_asset(self::getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED_COMPLETED)),
|
||||
new dynamicimages_asset(self::getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED_GREEN)),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -59,9 +68,39 @@ class machine_1 extends dynamicimages_image
|
||||
$this->drawAsset($this->getAsset(self::IMAGE_PANEL_BACKGROUND), 0, 0);
|
||||
$this->drawProgramWheel();
|
||||
$this->drawThumb();
|
||||
$this->drawHighlightedButtons();
|
||||
$this->drawStepThumb();
|
||||
$this->drawHighlightedResetButton();
|
||||
//$this->drawAsset($this->getAsset(self::IMAGE_POWER_BUTTON), 0, 0);
|
||||
$this->drawHighlightedButtons();
|
||||
$this->drawAsset($this->getAsset(self::IMAGE_POWER_BUTTON), 0, 0);
|
||||
$this->drawHighlightedStartButton();
|
||||
}
|
||||
|
||||
public function getHighlightedAssetName(): string
|
||||
{
|
||||
if ($this->button_counter == $this->current_step) {
|
||||
return self::IMAGE_BUTTON_HIGHLIGHTED_BLUE;
|
||||
}
|
||||
if ($this->button_counter < $this->current_step) {
|
||||
return self::IMAGE_BUTTON_HIGHLIGHTED_COMPLETED;
|
||||
}
|
||||
return self::IMAGE_BUTTON_HIGHLIGHTED_GREY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function drawHighlightedStartButton(): void
|
||||
{
|
||||
$x = 4965; // X position for the start button
|
||||
$y = 1980; // Y position for the start button
|
||||
$tmp = new dynamicimages_asset($this->getAssetPath(self::getHighlightedAssetName()));
|
||||
$tmp->resize($this->start_button_highlight_size, $this->start_button_highlight_size);
|
||||
$tmp = $this->drawStepCounterOnButton($tmp);
|
||||
$this->drawAsset($tmp, $x, $y);
|
||||
// Free memory used by temporary asset image, if any
|
||||
if (method_exists($tmp, 'clearMemoryImage')) {
|
||||
$tmp->clearMemoryImage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +110,7 @@ class machine_1 extends dynamicimages_image
|
||||
{
|
||||
$x = 1736; // X position for the reset button
|
||||
$y = 599; // Y position for the reset button
|
||||
$tmp = new dynamicimages_asset($this->getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED_BLUE));
|
||||
$tmp = new dynamicimages_asset($this->getAssetPath(self::getHighlightedAssetName()));
|
||||
$tmp->resize($this->reset_button_highlight_size, $this->reset_button_highlight_size);
|
||||
$tmp = $this->drawStepCounterOnButton($tmp);
|
||||
$this->drawAsset($tmp, $x, $y);
|
||||
@@ -161,6 +200,10 @@ class machine_1 extends dynamicimages_image
|
||||
$angle = 0;
|
||||
$color = [255, 255, 255]; // White color for the text
|
||||
$text = (string)$this->getNextButtonStepCount();
|
||||
// If the step has been completed, do not draw the number
|
||||
if ($this->button_counter <= $this->current_step) {
|
||||
$text = '';
|
||||
}
|
||||
$buttonAsset->addTextOverlay($text, [
|
||||
'font_size' => $fontSize,
|
||||
'font_color' => $color,
|
||||
@@ -198,8 +241,9 @@ class machine_1 extends dynamicimages_image
|
||||
if ($row === $this->button_rows - 1) {
|
||||
$y += $this->button_last_row_spacing_buffer;
|
||||
}
|
||||
$tmp = new dynamicimages_asset($this->getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED));
|
||||
$tmp = new dynamicimages_asset($this->getAssetPath(self::getHighlightedAssetName()));
|
||||
$tmp->resize($this->button_highlight_size, $this->button_highlight_size);
|
||||
$tmp = $this->drawStepCounterOnButton($tmp);
|
||||
$this->drawAsset($tmp, $x, $y);
|
||||
// Free memory used by temporary asset image, if any
|
||||
if (method_exists($tmp, 'clearMemoryImage')) {
|
||||
@@ -277,4 +321,33 @@ class machine_1 extends dynamicimages_image
|
||||
$tmp->clearMemoryImage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function drawStepThumb(): void
|
||||
{
|
||||
// Draw the blue step indicator on the thumb
|
||||
$thumbX = 650;
|
||||
$thumbY = 1290;
|
||||
$stepSize = 350; // Size of the step indicator
|
||||
// Base resized thumb to compute the visual pivot (center coordinates)
|
||||
$baseThumb = $this->getAsset(self::IMAGE_WASH_PROGRAMS_THUMB)->resize($this->calculateThumbWidth($this->thumb_size), $this->thumb_size);
|
||||
$centerX = $thumbX + (int)floor($baseThumb->getWidth() / 2);
|
||||
$centerY = $thumbY + (int)floor($baseThumb->getHeight() / 2);
|
||||
$angle = $this->getRotationThumbPosition();
|
||||
// Calculate position to draw the step indicator
|
||||
$radius = ($this->thumb_size / 2) - ($stepSize / 2) - 150; // Radius from center to position the step indicator
|
||||
$rad = deg2rad($angle);
|
||||
$stepX = $centerX + (int)round($radius * cos($rad)) - (int)floor($stepSize / 2);
|
||||
$stepY = $centerY + (int)round($radius * sin($rad)) - (int)floor($stepSize / 2);
|
||||
$tmp = new dynamicimages_asset($this->getAssetPath(self::getHighlightedAssetName()));
|
||||
$tmp->resize($stepSize, $stepSize);
|
||||
$tmp = $this->drawStepCounterOnButton($tmp);
|
||||
$this->drawAsset($tmp, $stepX, $stepY);
|
||||
// Free memory used by temporary asset image, if any
|
||||
if (method_exists($tmp, 'clearMemoryImage')) {
|
||||
$tmp->clearMemoryImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user