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

Implementation of simplify script #7

Merged
merged 19 commits into from
Jun 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions scripts/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',

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.

Copy link
Owner Author

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.

'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',

Choose a reason for hiding this comment

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

nit: 1.0? Close-enough?

Copy link
Owner Author

Choose a reason for hiding this comment

The 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()

Expand Down Expand Up @@ -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'):
Expand Down Expand Up @@ -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'):
Expand Down