Skip to content

Commit

Permalink
Add watermark support to all layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp committed Jan 15, 2024
1 parent bb8c2bc commit 20a4c65
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/Layout/Layouts/Avatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ public function features(): void
anchor: Position::MiddleTop,
)
);

if ($watermark = $this->watermark()) {
$this->addFeature((new PictureBox())
->path($watermark)
->box(100, 100)
->position(
x: 1180,
y: 610,
anchor: Position::BottomRight
)
);
}
}

public function url(): string
Expand Down
14 changes: 14 additions & 0 deletions src/Layout/Layouts/GitHubBasic.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use SimonHamp\TheOg\BorderPosition;
use SimonHamp\TheOg\Layout\AbstractLayout;
use SimonHamp\TheOg\Layout\PictureBox;
use SimonHamp\TheOg\Layout\Position;
use SimonHamp\TheOg\Layout\TextBox;

Expand Down Expand Up @@ -90,5 +91,18 @@ public function features(): void
)
);
}

if ($watermark = $this->watermark()) {
$this->addFeature((new PictureBox())
->path($watermark)
->box(100, 100)
->position(
x: 0,
y: 0,
relativeTo: fn () => $this->mountArea()->anchor(Position::BottomRight),
anchor: Position::BottomRight
)
);
}
}
}
12 changes: 12 additions & 0 deletions src/Layout/Layouts/TwoUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ public function features(): void
anchor: Position::BottomRight,
)
);

if ($watermark = $this->watermark()) {
$this->addFeature((new PictureBox())
->path($watermark)
->box(100, 100)
->position(
x: 20,
y: 610,
anchor: Position::BottomLeft
)
);
}
}

if ($url = $this->url()) {
Expand Down
9 changes: 6 additions & 3 deletions tests/Integration/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public static function snapshotImages(): iterable
->layout(new GitHubBasic)
->url('username/repo')
->title('An awesome package')
->background(BuiltInBackground::CloudyDay, 0.8),
->background(BuiltInBackground::CloudyDay, 0.8)
->watermark(__DIR__.'/../resources/logo.png'),
'githubbasic-layout',
];

Expand All @@ -135,7 +136,8 @@ public static function snapshotImages(): iterable
->url('https://my-ecommerce-store.com/')
->title('This layout is great for eCommerce!')
->callToAction('Buy Now →')
->background(BuiltInBackground::CloudyDay, 0.8),
->background(BuiltInBackground::CloudyDay, 0.8)
->watermark(__DIR__.'/../resources/logo.png'),
'twoup-layout',
];

Expand Down Expand Up @@ -186,7 +188,8 @@ public static function snapshotImages(): iterable
->layout(new Avatar)
->accentColor('#003')
->picture('https://i.pravatar.cc/300?img=10')
->title('Simone Hampstead'),
->title('Simone Hampstead')
->watermark(__DIR__.'/../resources/logo.png'),
'avatar-layout',
];
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 20a4c65

Please sign in to comment.