Repository navigation
A picture may be drawn in a shape - #51
Merged
Merged
Conversation
A picture is drawn in a rectangle, and a picture can be drawn in another shape instead. The shape is the picture's own rather than a frame drawn around it: the file writes it as the geometry of the picture, which is what PowerPoint writes for a picture cropped to a shape. `mask` names it, and there are sixteen: circle, ellipse, roundrect, triangle, diamond, hexagon, chevron, arrow, star, heart, teardrop, cloud, moon, donut, frame and plaque. A name outside them is refused with the list of what would have worked, the way every other name outside a vocabulary is. The mask is a shape and not a size: the picture keeps the box it was given, and the shape is drawn in it. A circle and an ellipse are the same shape, and the picture's own proportions decide which of the two it looks like. It needs a PHPPresentation that can write it, which the patch this library carries now does: a drawing carries the name of a preset, and the writer writes it as the geometry of the picture.
A picture under words is a photograph with words on it, and the words are read against the photograph rather than against the page. A panel between the two is what gives them something of their own to be read against: a shape painted with a colour and an alpha, so that the picture shows through it and the words sit on the panel. The alpha is one percentage for the whole shape, and it is written into the colour of the fill and of the stroke. What is checked here is that it reaches the colours of every kind of shape that takes one -- the ink shapes, the placed text block and the stops of a gradient -- and that the panel is drawn between the picture and the words, so that it is between them. The library knows the colour of the panel and the colour of the words, and not what the photograph is made of, so how readable the words are is a thing to look at rather than a thing the library can promise. The example says so.
fabeat
force-pushed
the
feature/picture-mask
branch
from
November 8, 2026 18:14
a892ada to
fe0587d
Compare
The geometry is written inside the picture's own `p:spPr`, which is where PowerPoint writes it for a picture cropped to a shape -- and the test says that, rather than that the slide holds the shape somewhere.
The kind of a free shape that is a picture is `image`, and there is no other: the ten ink shapes are the ones that are asked for, because there are ten of them. Asking for it here made the method one parameter longer than the ceiling, and the parameter carried nothing. The ceiling is the suite's own: a method with more than seven parameters is one thing too many, and a picture that is a picture does not need to be told which kind it is.
The patch is the same file it was -- the fix and the re-rolled patch did not change -- and the commit it sits on has a new hash, because the commits that carry it now say what the change is called.
fabeat
marked this pull request as ready for review
November 8, 2026 19:54
The panel over the whole picture is one way to give words over a photograph something to be read against, and it veils the picture to do it. The other way is a box behind the words alone: the same shape, painted with the page's own colour and opaque, so the words have the page to be read against and the picture around the box keeps its own colours. `fill=lt1` alone would be opaque as well -- a colour without an alpha is whole -- so `alpha=100` says it rather than leaving it to be read.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What this is
A picture may be drawn in a shape, and the shape is the picture's own rather than a frame drawn around it: the file writes it as the geometry of the picture, which is what PowerPoint writes for a picture cropped to a shape.
masknames the shape, and there are sixteen of them:circle,ellipse,roundrect,triangle,diamond,hexagon,chevron,arrow,star,heart,teardrop,cloud,moon,donut,frameandplaque. A name outside them is refused with the list of what would have worked, the way every other name outside a vocabulary is.The mask is a shape and not a size: the picture keeps the box it was given, and the shape is drawn in it. A
circleand anellipseare the same shape, and the picture's own proportions decide which of the two it looks like.The dependency
Writing it needs a PHPPresentation that can write it: a drawing carries the name of a preset, and the writer writes it as the geometry of the picture.
That is a change in PHPPresentation, which is open as a draft, and the patch this library carries now has it. The patch is pinned by its checksum, and the pin moves with it.
The second example
examples/markdown/22-legible-over-image.mdis a picture and the words over it, three times: with nothing between them and the photograph, with a translucent panel over the whole picture, and in an opaque box behind the words alone — the two ways of giving words over a photograph something of their own to be read against. The tests around it check that the alpha reaches the colours of every kind of shape that takes one, and that the panel is drawn between the picture and the words.What the library cannot do is say how readable the words are: it knows the colour of the panel and the colour of the words, and not what the photograph is made of. The example says so.
The tests
tests/Unit/masks.php— the geometry that reaches the file, a picture without a mask keeping its rectangle, the refusal of a name outside the sixteen, and the mask not changing the picture's box.tests/Unit/opacity.php— the alpha on an ink shape, on a placed text block and on the stops of a gradient, an alpha of zero, the refusal of an alpha on a picture, and the order the three shapes are drawn in.1863 tests, PHPStan clean, coverage 100 %.