1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94:
<?php
/**
* The osu! signature object.
*
* @author Lemmmy
*/
class OsuSignature extends Signature
{
/**
* The user data of the requested signature's subject
*
* @var array
*/
private $user;
/**
* The width of the signature excluding the margin and stroke width
* calculated by the size of all components.
*
* @var int
*/
private $baseWidth;
/**
* The height of the signature excluding the margin and stroke width
* calculated by the size of all components.
*
* @var int
*/
private $baseHeight;
/**
* The template this signature will use for its components.
*
* @var Template
*/
private $template;
/**
* The hex colour of the signature.
*
* @var string
*/
private $hexColour;
/**
* Creates a new osu! signature.
*
* @param array $user The user whom the signature will be the signature's subject
* @param Template $template The template this signature will be based on.
*/
public function __construct($user, $template) {
$this->user = $user;
$this->template = new $template($this);
$width = $this->template->calculateBaseWidth() + ($this->template->getImageMarginWidth());
$height = $this->template->calculateBaseHeight() + ($this->template->getImageMarginWidth());
parent::__construct($width, $height);
}
/**
* @return array The user data of the requested signature's subject
*/
public function getUser()
{
return $this->user;
}
/**
* @return string
*/
public function getHexColour()
{
return $this->hexColour;
}
public function generate($hexColour = "#bb1177") {
/*
The inner width and height of the signature card.
This excludes the margins.
*/
$this->baseWidth = $this->template->calculateBaseWidth();
$this->baseHeight = $this->template->calculateBaseHeight();
$this->hexColour = $hexColour;
$this->template->getCard()->draw($this->canvas, $hexColour, $this->template, $this->baseWidth, $this->baseHeight);
$this->template->drawComponents();
// Sets the headers and echoes the image
$this->output();
}
}