Display font awesome.

This commit is contained in:
Malte Hübner 2017-09-30 20:13:40 +02:00
parent 653b6c1877
commit aec3c45b8d
2 changed files with 21 additions and 9 deletions

Binary file not shown.

View File

@ -27,12 +27,7 @@ class ExtraMarkerPrinter
public function paint(Canvas $canvas): ExtraMarkerPrinter public function paint(Canvas $canvas): ExtraMarkerPrinter
{ {
$extramarkersImgUrl = __DIR__.'/../../../images/extramarkers.png'; $markerImage = $this->createMarker();
$extramarkers = imagecreatefrompng($extramarkersImgUrl);
$markerImage = imagecreatetruecolor(75, 100);
$trans_colour = imagecolorallocatealpha($markerImage, 0, 0, 0, 127);
imagefill($markerImage, 0, 0, $trans_colour);
$destX = floor(($canvas->getWidth() / 2) - $canvas->getTileSize() * ($canvas->getCenterX() - Util::lonToTile($this->marker->getLongitude(), $canvas->getZoom()))); $destX = floor(($canvas->getWidth() / 2) - $canvas->getTileSize() * ($canvas->getCenterX() - Util::lonToTile($this->marker->getLongitude(), $canvas->getZoom())));
$destY = floor(($canvas->getHeight() / 2) - $canvas->getTileSize() * ($canvas->getCenterY() - Util::latToTile($this->marker->getLatitude(), $canvas->getZoom()))); $destY = floor(($canvas->getHeight() / 2) - $canvas->getTileSize() * ($canvas->getCenterY() - Util::latToTile($this->marker->getLatitude(), $canvas->getZoom())));
@ -43,11 +38,28 @@ class ExtraMarkerPrinter
$destX -= $markerWidth / 2; $destX -= $markerWidth / 2;
$destY -= $markerHeight; $destY -= $markerHeight;
imagecopy($markerImage, $extramarkers, 0, 0, 0, 0, $markerWidth, $markerHeight);
imagecopy($canvas->getImage(), $markerImage, $destX, $destY, 0, 0, imagesx($markerImage), imagesy($markerImage)); imagecopy($canvas->getImage(), $markerImage, $destX, $destY, 0, 0, imagesx($markerImage), imagesy($markerImage));
return $this; return $this;
} }
protected function createMarker()
{
$extramarkersImgUrl = __DIR__.'/../../../images/extramarkers.png';
$extramarkers = imagecreatefrompng($extramarkersImgUrl);
$markerImage = imagecreatetruecolor(75, 100);
$trans_colour = imagecolorallocatealpha($markerImage, 0, 0, 0, 127);
imagefill($markerImage, 0, 0, $trans_colour);
$markerWidth = imagesx($markerImage);
$markerHeight = imagesy($markerImage);
imagecopy($markerImage, $extramarkers, 0, 0, 0, 0, $markerWidth, $markerHeight);
$white = imagecolorallocate($markerImage, 255, 255, 255);
imagettftext($markerImage, 24, 0, 16, 42, $white, __DIR__.'/../../../fonts/fontawesome-webfont.ttf', json_decode('""'));
return $markerImage;
}
} }