-
Notifications
You must be signed in to change notification settings - Fork 7
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
Implementation of simplify script #7
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
cef247d
Initial implementation of simplify script
LoveMHz f1f6ee6
Fix image element
LoveMHz b9b0e21
Formatting cleanup
LoveMHz 82a9cdb
Add license
LoveMHz feb9999
Implement default styles as dictionary
LoveMHz 80d27b7
Implement image element style attribute as dictionary
LoveMHz 377efb4
Improve readability of image_allowed_attrs
LoveMHz a37f20d
Implement default_svg_attrs
LoveMHz 1c7ceb1
Implement output file argument
LoveMHz 2f23501
Fix shebang on script
LoveMHz 8064a96
Fix file permissions
LoveMHz f327736
Remove SVG namespace dependency and unneeded attributes
LoveMHz 9c7fd82
Refactor element processing
LoveMHz a612c2d
Fix default_styles in format_group_elements
LoveMHz 6661683
Remove leftover variables
LoveMHz 5d47696
Refactor layer variable to group
LoveMHz ed2bdbe
Change default stroke width of traces to sane value
LoveMHz b84721f
Add pixel unit to stroke-width
LoveMHz 5ff7a98
Partial rewrite
LoveMHz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,30 @@ | |
'style': 'display:inline' | ||
} | ||
|
||
default_trace_style = 'fill:none;stroke:#ff0000;stroke-width:1.25;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1' | ||
default_zone_style = 'opacity:0.5;fill:#00ffff;stroke:#000000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' | ||
default_trace_style = { | ||
'fill': 'none', | ||
'stroke': '#ff0000', | ||
'stroke-width': '1.25', | ||
'stroke-linecap': 'round', | ||
'stroke-linejoin': 'round', | ||
'stroke-miterlimit': '4', | ||
'stroke-dasharray': 'none', | ||
'stroke-opacity': '1' | ||
} | ||
default_zone_style = { | ||
'opacity': '0.5', | ||
'fill': '#00ffff', | ||
'stroke': '#000000', | ||
'stroke-width': '0.99999994px', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed ed2bdbe |
||
'stroke-linecap': 'butt', | ||
'stroke-linejoin': 'miter', | ||
'stroke-opacity': '1' | ||
} | ||
default_zone_label = 'Copper Fill' | ||
|
||
def dict_to_style(dict): | ||
return ';'.join("{}:{}".format(key,val) for (key,val) in dict.items()) | ||
|
||
def sort_element_attr(element): | ||
attributes = element.attributes.items() | ||
|
||
|
@@ -75,7 +95,7 @@ def process_zones_layer(xml, layer, new_layer): | |
# TODO: Remove transforms | ||
|
||
# Assign default zone style | ||
new_zone.setAttribute('style', default_zone_style) | ||
new_zone.setAttribute('style', dict_to_style(default_zone_style)) | ||
|
||
# Assign default zone label | ||
if not new_zone.getAttribute('inkscape:label'): | ||
|
@@ -109,7 +129,7 @@ def process_traces_layer(xml, layer, new_layer): | |
new_trace.setAttribute(allowed_attr, trace.getAttribute(allowed_attr)) | ||
|
||
# Assign default trace style | ||
new_trace.setAttribute('style', default_trace_style) | ||
new_trace.setAttribute('style', dict_to_style(default_trace_style)) | ||
|
||
# Add UUID if needed | ||
if not new_trace.getAttribute('pcbre:uuid'): | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No unit?
default_zone_style
uses pixels.For compatibility with different files I'd prefer if we could use metric units, then we would have a fixed coordinate system and would only have to scale the images to match it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed this to use '1.25px' so it's not left without a unit of measurement. b84721f
I would rather address units of measurements and everything associated with that in a separate issue.