Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
Loading...
Searching...
No Matches
TransformSyntaxPreserving.h File Reference

Transform transform= writeback that preserves the author's chosen function syntax. Forward transform edits (inspector fields and canvas drags) used to canonicalize every author form into matrix(a,b,c,d,e,f) via donner::toSVGTransformString. This module re-expresses an edited Transform2d in the author's original function list where the edit is representable as an update to that list (a rotation change on rotate(45) writes rotate(60), a move updates translate(x, y), and so on), falling back to matrix() only when the edit cannot be represented in the author's structure. More...

#include <optional>
#include <string_view>
#include "donner/base/RcString.h"
#include "donner/base/Transform.h"
Include dependency graph for TransformSyntaxPreserving.h:

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

std::optional< RcStringdonner::editor::reserializeTransformPreservingSyntax (std::string_view authorSource, const Transform2d &target)
 Attempt to re-serialize target into the author's function-list syntax parsed from authorSource.
RcString donner::editor::serializeTransformForWriteback (const std::optional< RcString > &authorSource, const Transform2d &target)
 Serialize target for a transform= writeback, preserving the author's syntax from authorSource where possible and otherwise emitting the canonical donner::toSVGTransformString form. An empty result means the attribute should be removed (the transform is the identity).

Detailed Description

Transform transform= writeback that preserves the author's chosen function syntax. Forward transform edits (inspector fields and canvas drags) used to canonicalize every author form into matrix(a,b,c,d,e,f) via donner::toSVGTransformString. This module re-expresses an edited Transform2d in the author's original function list where the edit is representable as an update to that list (a rotation change on rotate(45) writes rotate(60), a move updates translate(x, y), and so on), falling back to matrix() only when the edit cannot be represented in the author's structure.

Function Documentation

◆ reserializeTransformPreservingSyntax()

std::optional< RcString > donner::editor::reserializeTransformPreservingSyntax ( std::string_view authorSource,
const Transform2d & target )
nodiscard

Attempt to re-serialize target into the author's function-list syntax parsed from authorSource.

Returns the author-form string (e.g. rotate(60)) when the edit is expressible as a parameter update to the author's transform functions, or std::nullopt when it is not (a decomposed rotation change against a skew matrix, a move on a rotate-only element, etc.). The returned string always re-parses to target within a tight tolerance; callers that receive std::nullopt should emit toSVGTransformString(target).