Pebble Draw Command preview and export#1587
Conversation
|
The StreamPeer and StreamPeerBuffer classes are currently disabled in .github/disabled_classes.gdbuild as this PR is the first time they are used in the codebase. They need to be enabled for the artifacts to build correctly. |
|
It should be possible for me to make it use the PackedByteArray buffer directly without StreamPeer, I just prefer the API of StreamPeer. Would that be a better solution? |
|
Whatever you prefer. |
|
Should all be fixed now |
|
I'm against adding PDC-specific things in previews in this PR. We can do it later, but I think we should first investigate the idea of having utilities to preview every format, and to configure the previews just like in the image export menu. |
286d40d to
986fd4f
Compare
|
Right, should all be fixed now |
|
Could you rebase? I made some changes to the CI that make it so changing the disabled_classes file should result in new cache. Edit: Nevermind, the CI needs more work |
|
The issues have been fixed, seems like they might have been from Godot 4.6.1. Could you rebase now? |
d150a6d to
d2475af
Compare
|
Rebased! |
|
Other notes:
|
|
I actually realized the reason why the other formats have no size indication - there's no way to get one without converting the image, and there's no way to convert the image without a lag spike. Previews are limited to 512x512 for this reason. So it would either need to be reverted to how it was, or have some kind of indication that it's not the real deal for bigger images - I can't think of a good one. The two SVGs in the PR seem cool, but are now unused if I'm not mistaken? If they are still necessary, import them as DPITexture. |
|
I could estimate the size of the image with the actual resolution by extrapolating the The two SVGs are unused, but they were for the PDC preview checkbox in the previews panel — if we plan on bringing that back, I'll still need them. |
|
Hmm, okay, I have a different idea, but let's still keep them until then, just reimport both as DPITexture. As for size estimation, I think that's a good idea! |
3ebd72c to
f8d2ee1
Compare
|
All fixed now. Would there be any interest in generating the export on a separate thread, then showing a throbber or something while it loads? That would sort of fix the slowness issue |
|
I tried that, but I needed a separate threadless solution for web and the complexity didn't feel worth it. Will test in a bit in my lunch break. |
|
One more rebase, please? I broke context popups right as you were rebasing :( |
…d PDC filepath, the preview is generated by parsing the PDC buffer so it should be extra accurate, more quality controls
…pses, add estimated file size
f8d2ee1 to
afbac4a
Compare
|
Rebased on top of upstream/main |
|
Rectangles are broken and the "Precise:" section should be left-aligned. I'll go over the code in a bit. |
There was a problem hiding this comment.
Other notes: The ThemeUtils changes should be reverted. They aren't utilized yet and they seem very hacky.
Edit: Also, maybe pull the whole export size estimation inside an if else block after checking if the format is SVG? Right now you have a bug where big SVGs will trigger the "approximate" label, and also have this weird match setup.
| var focus_sequence: Array[Control] | ||
| focus_sequence.append(clipboard_button) | ||
| focus_sequence.append(format_dropdown) | ||
| focus_sequence.append(path_quality_edit) | ||
| focus_sequence.append(precise_path_mode_dropdown) | ||
| focus_sequence.append(lossless_checkbox) | ||
| focus_sequence.append(quality_edit) | ||
| focus_sequence.append(scale_edit) | ||
| focus_sequence.append(width_edit) | ||
| focus_sequence.append(height_edit) | ||
| focus_sequence.append(cancel_button) | ||
| focus_sequence.append(export_button) | ||
|
|
||
| HandlerGUI.register_focus_sequence(self, focus_sequence, true) | ||
| clipboard_button.grab_focus(true) |
There was a problem hiding this comment.
I prefer that this doesn't get changed.
| func update() -> void: | ||
| # Determine which fields are visible. | ||
| quality_related_container.visible = export_data.format in ["jpg", "jpeg", "webp"] | ||
| path_quality_container.visible = export_data.format in ["pdc"] |
There was a problem hiding this comment.
| path_quality_container.visible = export_data.format in ["pdc"] | |
| path_quality_container.visible = (export_data.format == "pdc") |
| export_size = roundi(texture_preview.last_image_size * maxf(1.0, export_size_fac)) | ||
| final_size_label.text = Translator.translate("Size") + ": " + String.humanize_size(export_size) | ||
| if export_size_fac > 1.0: | ||
| final_size_label.text += Translator.translate(" (approximate)") |
There was a problem hiding this comment.
Based on current conventions, only the "approximate" string should be translated and not the surrounding punctuation
|
|
||
| window/size/viewport_width=1040 | ||
| window/size/viewport_height=650 | ||
| window/size/mode=2 |
| static func generate_ellipse( | ||
| start: Vector2, end: Vector2, r: Vector2, | ||
| rot: float, | ||
| large_arc_flag: bool, sweep_flag: bool, | ||
| path_generator: PathGenerator = default_path_generator | ||
| ) -> PackedVector2Array: |
There was a problem hiding this comment.
Do the params in a single line like the rest of the codebase, also rename to generate_elliptical_arc.
| size = Vector2i( | ||
| sp.get_16(), | ||
| sp.get_16(), | ||
| ) |
| ## [br][br] | ||
| ## Implementation based on the specification at [url]https://developer.rebble.io/guides/app-resources/pdc-format/[/url] and | ||
| ## [url=https://github.com/pebble-examples/cards-example/blob/master/tools/svg2pdc.py]svg2pdc.py[/url]. | ||
| class_name PDCImage |
There was a problem hiding this comment.
Is it meant to extend RefCounted (as by default)? If so, I think this should be explicit.
| var x := sp.get_16() | ||
| var y := sp.get_16() | ||
| center = Vector2(x, y) |
There was a problem hiding this comment.
I'd say no need for intermediate variables.
| var x := float(sp.get_16()) / (1 << 3) | ||
| var y := float(sp.get_16()) / (1 << 3) | ||
| points.append(Vector2(x, y)) |
There was a problem hiding this comment.
I'd say no need for intermediate variables. Divide the whole thing by (1 << 3).
| var x := sp.get_16() | ||
| var y := sp.get_16() | ||
| points.append(Vector2(x, y)) |
There was a problem hiding this comment.
I'd say no need for intermediate variables.
|
I also found that curves no longer have tangents to their control points. |
|
The export menu was reworked, which requires significant changes for the PR. But it should overall fit into the new systems way better than it did with the old ones. |



The Pebble Draw Command (PDC) format is a vector format used by the Pebble smartwatches to draw scalable graphics. This PR adds export support for it, as well as extending the preview panel to look similar what the images would like like on real hardware. This includes quantization to 64 colors and snapping vertices to 1 or 1/16th pixels, depending on the precision mode.
The implementation was based on svg2pdc.
More information: https://developer.rebble.io/tutorials/advanced/vector-animations/#drawing-a-pdc-image, https://developer.rebble.io/guides/app-resources/pdc-format/