Skip to content

Commit

Permalink
fix head position
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiabasone committed Mar 13, 2023
1 parent 2bc9e33 commit 15847d2
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Isometric/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ class Head implements IsometricImage

private const HEAD_BASE_SIZE = 512;

/**
* Margin (in pixels) in the final image.
*/
private const HEAD_MARGIN = 4;

public function __construct(private readonly string $rawSkinImagePath)
{
}
Expand Down Expand Up @@ -118,16 +113,16 @@ protected function renderFullSize(): \Imagick

// Head image
$doubleAvatarSize = self::HEAD_BASE_SIZE * 2;
$finalImageSize = $doubleAvatarSize + (self::HEAD_MARGIN * 2);
$finalImageSize = $doubleAvatarSize + 2;

$head = new \Imagick();
$head->newImage($finalImageSize, $finalImageSize, $this->getImagickPixelTransparent());

// This is weird, but it works
$faceX = ((int) round($doubleAvatarSize / 2)) - 2 + self::HEAD_MARGIN;
$faceY = $rightY = ((int) round($doubleAvatarSize / 4)) - 1 + self::HEAD_MARGIN;
$topX = $rightX = ((int) round($doubleAvatarSize / 16)) + self::HEAD_MARGIN;
$topY = -1 + self::HEAD_MARGIN;
$faceX = ((int) round($doubleAvatarSize / 2)) - 5;
$faceY = $rightY = ((int) round($doubleAvatarSize / 4));
$topX = $rightX = ((int) round($doubleAvatarSize / 16));
$topY = 0;

// Add Face Section
$head->compositeimage($face->getimage(), \Imagick::COMPOSITE_PLUS, $faceX, $faceY);
Expand Down

0 comments on commit 15847d2

Please sign in to comment.