Skip to content

Conversation

@seanlynchwv
Copy link
Contributor

@seanlynchwv seanlynchwv commented Sep 8, 2025

Description

It's now possible to set the radius to create rounded corners on rectangle shapes.

        $panel = new AutoShape();
        $panel->setType(AutoShape::TYPE_ROUNDED_RECTANGLE)
            ->setOffsetX($x)
            ->setOffsetY($y)
            ->setWidth($w)
            ->setHeight($h)
            ->setRoundRectCorner(4); // new

Previously the corners were hard coded to a large value making custom designs difficult.

Fixes # (issue)
#854

Checklist:

  • My CI is 🟢
  • I have covered by unit tests my new code (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes
  • I have updated the changelog

@auto-assign auto-assign bot requested a review from Progi1984 September 8, 2025 15:09
@seanlynchwv seanlynchwv changed the title Set Rounded Corners on Rectable Set Rounded Corners on Rectangle Sep 8, 2025
@coveralls
Copy link

coveralls commented Sep 8, 2025

Coverage Status

coverage: 91.69% (+0.05%) from 91.643%
when pulling a48a8a4 on seanlynchwv:feature/set-rounded-rect-corners
into 7018fd8 on PHPOffice:master.

@Progi1984 Progi1984 added this to the 1.3.0 milestone Oct 24, 2025
Copy link
Member

@Progi1984 Progi1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some feedbacks

- `phpoffice/phpspreadsheet`: Allow version 4.0 by [@nreynis](https://github.com/nreynis) in [#861](https://github.com/PHPOffice/PHPPresentation/pull/861)
- Smaller package size by [@nreynis](https://github.com/nreynis) in [#862](https://github.com/PHPOffice/PHPPresentation/pull/862)
- Added setFirstSliceAngle to Doughnut Chart by [@seanlynchwv](http://github.com/seanlynchwv) in [#872](https://github.com/PHPOffice/PHPPresentation/pull/872)
- Added ability to set rounded corner radius by [@seanlynchwv](http://github.com/seanlynchwv) in [#880](https://github.com/PHPOffice/PHPPresentation/pull/880)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seanlynchwv Could you move your change to 1.3.0.md, please ?

{
$minHalf = (int) floor(min($this->width, $this->height) / 2);
if ($minHalf > 0) {
$this->roundRectAdj = max(0, min(50000, (int) round($pixels / $minHalf * 50000)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does come from 50000 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must move this calcul on the writer side, not on the autoshape class.

self::assertEquals(AutoShape::TYPE_HEXAGON, $object->getType());
}

public function testPixelSetterComputesAdjAndAffectsHash(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-authored-by: Progi1984 <progi1984@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants