Overview

Classes

  • Card
  • CardRegular
  • Component
  • ComponentAvatar
  • ComponentFlag
  • ComponentImage
  • ComponentLabel
  • ComponentXPBar
  • ErrorImage
  • OsuAPI
  • OsuSignature
  • PredefinedColours
  • Signature
  • Template
  • TemplateNormal
  • Utils
  • Overview
  • Class
 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: 
<?php
/**
 * The base signature object, initialising the canvas and outputting it.
 *
 * @author Lemmmy
 */
class Signature
{
    /**
     * @var Imagick The Imagick object for the canvas.
     */
    protected $canvas;

    /**
     * Creates a new instance of a basic Signature class
     *
     * @param int $width The signature's canvas width
     * @param int $height The signature's canvas height
     */
    public function __construct($width, $height) {
        $this->canvas = new\Imagick();
        $this->canvas->newImage($width, $height, new ImagickPixel('transparent'));
    }

    /**
     * Draws the background colour for the signature.
     * Note that this has no relation to {@link Card}s.
     *
     * @param $hexColour string Hexadecimal colour value
     */
    protected function drawBackground($hexColour) {
        $background = new ImagickDraw();
        $background->setFillColor($hexColour);
        $background->rectangle(0, 0, $this->canvas->getImageWidth(), $this->canvas->getImageHeight());

        $this->canvas->drawImage($background);
    }

    /**
     * Renders the signature to the browser
     */
    public function output() {
        $cachingTime = isset($_GET['onlineindicator']) ? 60 : 300;

        $this->canvas->setImageFormat('png');

        header('Content-Type: image/'.$this->canvas->getImageFormat());

        header("Cache-Control: max-age=$cachingTime");
        header("Expires: ".gmdate("D, d M Y H:i:s", time()+$cachingTime)." GMT");

        $this->canvas->setImageProperty('Generated by', 'Lemmmy\'s osu!next signature generator');
        $this->canvas->setImageProperty('Generator URL', 'http://lemmmy.pw/osusig/');

        echo $this->canvas;
    }

    /**
     * @return Imagick The Imagick object of this signature.
     */
    public function getCanvas() {
        return $this->canvas;
    }
}
API documentation generated by ApiGen