Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RTM] Implement effects #10

Merged
merged 2 commits into from
Mar 1, 2018
Merged

[RTM] Implement effects #10

merged 2 commits into from
Mar 1, 2018

Conversation

ausi
Copy link
Member

@ausi ausi commented Feb 25, 2018

Followup to #9

Implements all effects from the Effects interface.

Some notes about why certain things are implemented this way:

  • Direct CSS filters like filter: blur(1) are not supported in SVG context in some browsers, so we have to use the <filter> element.
  • Working around that by using url() with a data URI doesn’t work everywhere either.
  • filter attribute on the main <svg> element is not supported in IE/Edge, this is why we are using a <g> wrapper.
  • Multiple values for the filter attribute are not supported in some browsers, so we are using multiple elements in <filter>.
  • To avoid duplicate IDs we generate them with some random bytes a hash of the SVG itself.

@ausi ausi self-assigned this Feb 25, 2018
@ausi ausi mentioned this pull request Feb 25, 2018
src/Effects.php Outdated

if ($gamma <= 0) {
throw new InvalidArgumentException(sprintf(
'Invalid gamma correction value %s, must be a positive float or interger',
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: interger

Copy link
Member Author

@ausi ausi Feb 26, 2018

Choose a reason for hiding this comment

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

Thanks for checking!
Fixed in 72a3839

src/Effects.php Outdated

if ($deviation <= 0) {
throw new InvalidArgumentException(sprintf(
'Invalid sigma %s, must be a positive float or interger',
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: interger

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 72a3839

@ausi ausi requested a review from leofeyer February 26, 2018 07:34
@Toflar
Copy link
Member

Toflar commented Feb 26, 2018

To avoid duplicate IDs we generate them with some random bytes.

This would be against the reproducible builds philosophy. Can we fix that by a deterministic algorithm?

@ausi
Copy link
Member Author

ausi commented Feb 26, 2018

Can we fix that by a deterministic algorithm?

We could create a hash over the whole SVG, but that would result in the same hash if two SVGs have the exact same contents which could result in duplicate IDs. But this case may be very unlikely. Do you think we should switch to the hash?

@Toflar
Copy link
Member

Toflar commented Feb 26, 2018

That's exactly the thing. Imho it would be correct to create exactly the same twice. It's the very same image so it should result in the same output. I mean, for thumbnails that doesn't really make sense because I guess nobody would apply other logic to it like selecting an ID using JS. But it's a general purpose library, it doesn't have to generate thumbnails and I think in that case it would make sense to always create the same output.

@ausi
Copy link
Member Author

ausi commented Feb 26, 2018

Done in bfd29db.

@Toflar
Copy link
Member

Toflar commented Feb 26, 2018

Looks like PHP is blocking AppVeyor downloads or something?

@ausi
Copy link
Member Author

ausi commented Feb 26, 2018

I think so too, we should probably switch to a different source for the downloads. See symfony/symfony@51b82f5#diff-180360612c6b8c4ed830919bbb4dd459L20

@ausi ausi changed the title Implement effects [RTM] Implement effects Mar 1, 2018
@ausi ausi requested a review from Toflar March 1, 2018 15:49
Copy link
Member

@Toflar Toflar left a comment

Choose a reason for hiding this comment

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

Awesome work! LGTM.

chregu and others added 2 commits March 1, 2018 20:20
Some notes about why certain things are implemented this way:

- Direct CSS filters like `filter: blur(1)` are not supported in SVG context in some browsers, so we have to use the `<filter>` element.
- Working around that by using `url()` with a data URI doesn’t work everywhere either.
- To avoid duplicate IDs we generate them with a hash of the SVG itself.
- Multiple values for the `filter` attribute are not supported in some browsers, so we are using multiple elements in `<filter>`.
- `filter` attribute on the main `<svg>` element is not supported in IE/Edge, this is why we are using a `<g>` wrapper.
@ausi ausi force-pushed the feature/effects branch from 3d00908 to d51d38e Compare March 1, 2018 19:29
@ausi ausi merged commit ba853e2 into contao:master Mar 1, 2018
@ausi ausi deleted the feature/effects branch March 1, 2018 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants