Intervention / image

PHP Image Processing
https://image.intervention.io
MIT License
13.88k stars 1.5k forks source link

Add possibility to pass geometric objects directly to "draw" methods #1358

Closed olivervogel closed 3 months ago

olivervogel commented 4 months ago

Describe the feature you'd like Library should have a universal method to draw all DrawableInterface objects instead of calling one of the existing methods.

This way an object would be reusable for different draw processes and modified along the way.

Current Example

$image->drawCircle(function (CircleFactory $circle) {
    $circle->diameter(10);
    $circle->background('#b35187');
});

$image->drawCircle(function (CircleFactory $circle) {
    $circle->diameter(100); // change diameter!
    $circle->background('#b35187');
});

Improved

$circle = new Circle()
$circle->setDiameter(10);
$circle->setBackgroundColor('#35187');

// draw
$image->draw($circle);
$image->draw($circle->setDiameter(100));