Example #1
0
 public function draw(OsuSignature $signature)
 {
     if (empty($this->hexColour)) {
         $this->hexColour = $signature->getHexColour();
     }
     $composite = new Imagick();
     $composite->newPseudoImage($this->getWidth(), $this->getHeight(), "canvas:transparent");
     // Background
     $draw = new ImagickDraw();
     $draw->setFillColor(new ImagickPixel("#555555"));
     $draw->rectangle(0, 0, $this->getWidth(), $this->getHeight());
     $composite->drawImage($draw);
     // Main bar
     $level = $signature->getUser()['level'];
     $xp = $level - floor($level);
     $draw = new ImagickDraw();
     $draw->setFillColor(new ImagickPixel($this->hexColour));
     $draw->rectangle(0, 0, $this->getWidth() * $xp, $this->getHeight());
     $composite->drawImage($draw);
     // Bar end glow
     $draw = new ImagickDraw();
     $draw->setFillColor(new ImagickPixel('#ffffff'));
     $draw->setFillOpacity(0.35);
     $draw->rectangle($this->getWidth() * $xp - $this->getHeight(), 0, $this->getWidth() * $xp, $this->getHeight());
     $composite->drawImage($draw);
     // Text draw & metrics
     $textDraw = new ImagickDraw();
     $textDraw->setFillColor(new ImagickPixel('#555555'));
     $textDraw->setFontSize(12);
     $textDraw->setFont(ComponentLabel::FONT_DIRECTORY . ComponentLabel::FONT_REGULAR);
     $textDraw->setGravity(Imagick::GRAVITY_NORTHWEST);
     $metrics = $composite->queryFontMetrics($textDraw, 'lv' . floor($level));
     // Text white bg
     $draw = new ImagickDraw();
     $draw->setFillColor(new ImagickPixel('#ffffff'));
     $draw->rectangle(($this->getWidth() - $metrics['textWidth']) / 2 - 2, 0, ($this->getWidth() + $metrics['textWidth']) / 2 + 1, $this->getHeight());
     $composite->drawImage($draw);
     // Rounding
     $roundMask = new Imagick();
     $roundMask->newPseudoImage($this->getWidth(), $this->getHeight(), "canvas:transparent");
     $draw = new ImagickDraw();
     $draw->setFillColor(new ImagickPixel("black"));
     $draw->roundRectangle(0, 0, $this->getWidth() - 1, $this->getHeight() - 1, $this->rounding, $this->rounding);
     $roundMask->drawImage($draw);
     $roundMask->setImageFormat('png');
     $composite->compositeImage($roundMask, Imagick::COMPOSITE_DSTIN, 0, 0, Imagick::CHANNEL_ALPHA);
     $signature->getCanvas()->compositeImage($composite, Imagick::COMPOSITE_DEFAULT, $this->x, $this->y);
     // Level text
     $signature->getCanvas()->annotateImage($textDraw, $this->x + ($this->getWidth() - $metrics['textWidth']) / 2, $this->y + ($this->getHeight() - $metrics['textHeight']) / 2 - 2, 0, 'lv' . floor($level));
 }
Example #2
0
 public function draw(OsuSignature $signature)
 {
     if (isset($this->text)) {
         $signature->getCanvas()->annotateImage($this->drawSettings, $this->x, $this->y, 0, $this->text);
     }
 }
Example #3
0
<?php

// Thanks to Cygnix
// Created by Lemmmy
require_once "p/.priv.php";
function __autoload($class_name)
{
    $directory = 'class/';
    if (file_exists($directory . $class_name . '.php')) {
        require_once $directory . $class_name . '.php';
        return;
    }
}
$api = new OsuAPI(constant("AKEY"));
$user = $api->getUserForMode($_GET['uname'], isset($_GET['mode']) ? $_GET['mode'] : 0);
if (!$user) {
    $errorImage = new ErrorImage();
    $errorImage->generate("User not found", "The user you tried to generate \na signature for was not found.");
}
$colour = isset($_GET['colour']) && !empty($_GET['colour']) ? $_GET['colour'] : 'pink';
$sig = new OsuSignature($user, 'TemplateNormal');
$sig->generate(PredefinedColours::getPredefinedColour($colour));