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

Minimal XML representation of Penpot shapes #69

Closed
opcode81 opened this issue Jun 12, 2024 · 2 comments
Closed

Minimal XML representation of Penpot shapes #69

opcode81 opened this issue Jun 12, 2024 · 2 comments
Assignees
Labels
data conversion Converting different data representations to each other

Comments

@opcode81
Copy link
Collaborator

From the Penpot SVG export, determine the minimal XML representation, removing the actual SVG content which is not used by Penpot when importing the format.
This representation could serve as the basis for variation generation (#68).

@opcode81
Copy link
Collaborator Author

We definitely need to retain

  • all elements in the penpot namespace
  • <g> tags that are immediate parents of <penpot:shape> elements

@opcode81
Copy link
Collaborator Author

opcode81 commented Jun 12, 2024

There are penpot shapes for which the SVG representation must be retained:

  • A penpot shape with type="path" requires the shape's <g> sibling and the contained path element for the import to work.
  • Similarly, a penpot shape with type="circle" require's the shape's <g> sibling and the contained ellipse element.

This gives rise to a simplified conversion rule:
It appears that a penpot shape's <g> sibling must be retained unless the subsequent sibling is a penpot element.

Examples:

<g>
   <penpot:shape type="bool">...</penpot:shape>
   <defs/>
   <g>...</g>   <!-- can be removed -->
   <penpot:bool>...</penpot:bool>
</g>

<g>
   <penpot:shape type="circle">...</penpot:shape>
   <defs/>
   <g>...</g>   <!-- must be retained -->
</g>

Problem: redundant representation

While the conversion rule is simple enough, it's highly unfortunate from a representational point of view, because it makes the representation quite redundant.
Example with a circle:

<g id="shape-459cc494-9782-8033-8004-753e7ef8b63c">
	<penpot:shape penpot:name="Circle-6" penpot:type="circle" penpot:transform="matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)" penpot:transform-inverse="matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)" penpot:proportion="1" penpot:proportion-lock="false" penpot:rotation="0" penpot:center-x="1172" penpot:center-y="510" penpot:constraints-h="scale" penpot:constraints-v="scale" viewBox="0.0 0.0 0.0 0.0">
		<penpot:svg-import/>
		<penpot:fills>
			<penpot:fill penpot:fill-color="#b1b2b5" penpot:fill-opacity="1"/>
		</penpot:fills>
	</penpot:shape>
	<defs/>
	<g class="fills" id="fills-459cc494-9782-8033-8004-753e7ef8b63c">
		<ellipse cx="1172" cy="510" rx="36" ry="36" transform="matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)" style="fill:#b1b2b5;fill-opacity:1"/>
	</g>
</g>

In this example, the penpot:shape element of type circle already contains all the information in the ellipse tag, except, oddly enough, the radius. Yet the Penpot import fails if the <g> and containing <ellipse> are removed.

@opcode81 opcode81 added the data conversion Converting different data representations to each other label Jun 12, 2024
opcode81 added a commit that referenced this issue Jun 12, 2024
@opcode81 opcode81 self-assigned this Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data conversion Converting different data representations to each other
Projects
None yet
Development

No branches or pull requests

1 participant