mpociot
Use this code snippet to create your very own JackedUp avatar - as seen in the Radical Design Course video!
I used remove.bg to get a transparent image.
To use this code, please install the intervention image package:
composer require intervention/image
$input = storage_path('marcel.png');
$mask = Image::make(storage_path('mask.png'));
$image = Image::make($input)->mask($mask);
$shapes = [
'#f7fe77', '#3dffe7', '#ee0d6b'
];
$shapeImages = [];
foreach ($shapes as $shapeColor) {
$shapeImage = Image::canvas(
$image->width(),
$image->height(),
$shapeColor
)->mask($image, true)
->rotate(rand(-10,10));
$shapeImages[] = $shapeImage;
}
$image = Image::canvas(
$image->width(),
$image->height(),
);
foreach ($shapeImages as $shapeImage) {
$image->insert($shapeImage, 'top-left', rand(-20, 20), rand(-30, -10));
}
$image->insert(Image::make($input)
->mask($mask));
$output = Image::canvas(
$image->width() + 100,
$image->height() + 100,
'#072d35'
);
$output->insert($image, 'center');
return view('__tinker__::tinker', [
'output' => (string)$output->encode('data-url')
]);
<body style="background: #fdf767">
<img src="{{ $output }}" />
</body>