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

Enables transparent backgrounds #10

Closed
wants to merge 1 commit into from
Closed

Enables transparent backgrounds #10

wants to merge 1 commit into from

Conversation

mkraemer
Copy link

This pull request introduces the option to render qrcodes with transparent backgrounds.

For the vector based renderers, this is achieved by simple not creating a white background by default any more.
For the png renderer, a transparent background layer is created when initialising the image; If no background color is set afterwards, the background remains transparent.

This breaks backwards compatibility because the the default (when not calling setBackgroundColor explicitly) are transparent backgrounds.
The only way to avoid that would be to introduce a new parameter to the constructor of the Renderer classes which toggles the behaviour, defaulting to non-transparent backgrounds. Semantically, I'd think a transparent background is a great starting point for an image and calling setBackgroundColor in case I want a color on top of that is ok :)
What do you think?

Thx for the great library :)

@mkraemer
Copy link
Author

Any updates on this? :)

@DASPRiD
Copy link
Member

DASPRiD commented Nov 25, 2014

Sorry, I was on vacation the last 2 weeks. Will go through this in the next few days :)

*/
public function getBackgroundColor()
{
if ($this->backgroundColor === null) {
$this->backgroundColor = new Color\Gray(100);
Copy link
Member

Choose a reason for hiding this comment

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

I'd argue that the default color should definitely be white. To make it possible to set transparency (by setting null as background color), I'd suggest to set the white value in the constructor.

@base-zero
Copy link

Tested this pull request and it works well. 👍 Would be nice to see this functionality added to the package and a new version tagged.

@base-zero
Copy link

@DASPRiD Please can we get this PR merged and a new version tagged ?

@DASPRiD DASPRiD added this to the 2.0 milestone Oct 26, 2017
@DASPRiD
Copy link
Member

DASPRiD commented Oct 26, 2017

I've taken (semi-)transparent backgrounds into account in the 2.0 rewrite. I'm planning to have that one working pretty soon.

@DASPRiD DASPRiD mentioned this pull request Oct 26, 2017
5 tasks
@DASPRiD DASPRiD closed this in #38 Apr 25, 2018
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.

3 participants