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

shorten SVG inline syntax #445

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

shorten SVG inline syntax #445

wants to merge 2 commits into from

Conversation

xerc
Copy link

@xerc xerc commented Feb 25, 2024

may consider an option to deactivate width/height @ "header" for easier SVG handeling

svg.setAttribute("width", width + "px");
svg.setAttribute("height", height + "px");

@xerc xerc force-pushed the patch-1 branch 3 times, most recently from 4dd45b1 to 8841aa4 Compare February 25, 2024 16:32
Copy link
Owner

@lindell lindell left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. A few comments added.

There were also (needed) code style changes, but please never make them in a PR doing other things, it makes it a lot harder to see what is actualy going on with the PR.

@@ -15,13 +15,21 @@ class SVGRenderer{
var currentX = this.options.marginLeft;

this.prepareSVG();

// Create Background
if(!this.options.background.match(/transparent|#[a-f\d]{3}(?:[a-f\d]{3})?0/i)){
Copy link
Owner

Choose a reason for hiding this comment

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

This does not rga/hsl style colors etc. Why is the regexp added?

Copy link
Author

@xerc xerc Feb 29, 2024

Choose a reason for hiding this comment

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

i focused on the JsBarcode default values and common shortcut & will slow down the parsing
[rgb(a),hsl(a),(ok)lch,lab,hwb]

Copy link
Author

@xerc xerc Feb 29, 2024

Choose a reason for hiding this comment

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

legacyColorRegex = /(?:rgb|hsl)a?\([^,]+?\s*,\s*[^,]+?\s*,\s*[^,]+?\s*,\s*0(?:[\.0%\s]*)?\)/
modernColorRegex = /(ok)?[a-z]{3}\([^\/]+\/\s*0(?:[\.0%\s]*)?\)/

for(let i = 0; i < this.encodings.length; i++){
var encoding = this.encodings[i];
var encodingOptions = merge(this.options, encoding.options);

var group = this.createGroup(currentX, encodingOptions.marginTop, this.svg);

this.setGroupOptions(group, encodingOptions);
if(!encodingOptions.lineColor.match(/black|#000(?:000)?f?/i)){
Copy link
Owner

Choose a reason for hiding this comment

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

Please add a comment that it will default to black and that it will shorten the SVG syntax.

@xerc xerc force-pushed the patch-1 branch 5 times, most recently from 697fcf5 to 1db63b9 Compare February 29, 2024 11:30
@xerc
Copy link
Author

xerc commented Mar 11, 2024

[FIX] switch unicode to ascii parsing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants