:octocat: add logo space creation

This commit is contained in:
codemasher
2021-12-09 01:10:37 +01:00
parent 1aee1e90ca
commit 87f7f3aa4a
5 changed files with 127 additions and 29 deletions
+60
View File
@@ -284,6 +284,31 @@ trait QROptionsTrait{
*/
protected bool $readerIncreaseContrast = false;
/**
* Toggles logo space creation
*/
protected bool $addLogoSpace = false;
/**
* width of the logo space
*/
protected int $logoSpaceWidth = 0;
/**
* height of the logo space
*/
protected int $logoSpaceHeight = 0;
/**
* optional horizontal start position of the logo space (top left corner)
*/
protected ?int $logoSpaceStartX = null;
/**
* optional vertical start position of the logo space (top left corner)
*/
protected ?int $logoSpaceStartY = null;
/**
* clamp min/max version number
*/
@@ -412,4 +437,39 @@ trait QROptionsTrait{
: GDLuminanceSource::class;
}
/**
* clamp the logo space values between 0 and maximum length (177 modules at version 40)
*/
protected function clampLogoSpaceValue(int $value):int{
return (int)max(0, min(177, $value));
}
/**
* clamp/set logo space width
*/
protected function set_logoSpaceWidth(int $value):void{
$this->logoSpaceWidth = $this->clampLogoSpaceValue($value);
}
/**
* clamp/set logo space height
*/
protected function set_logoSpaceHeight(int $value):void{
$this->logoSpaceHeight = $this->clampLogoSpaceValue($value);
}
/**
* clamp/set horizontal logo space start
*/
protected function set_logoSpaceStartX(?int $value):void{
$this->logoSpaceStartX = $value === null ? null : $this->clampLogoSpaceValue($value);
}
/**
* clamp/set vertical logo space start
*/
protected function set_logoSpaceStartY(?int $value):void{
$this->logoSpaceStartY = $value === null ? null : $this->clampLogoSpaceValue($value);
}
}