惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
V
V2EX
aimingoo的专栏
aimingoo的专栏
爱范儿
爱范儿
博客园 - 聂微东
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
月光博客
月光博客
云风的 BLOG
云风的 BLOG

Martin Owens activity

Martin Owens deleted project branch average-color-divide at Inkscape / inkscape Fix divide-by-zero crash when using calligraphy tool (d34276f8) · Commits · Inkscape / inkscape · GitLab Fix divide-by-zero crash when using calligraphy tool (!7923) · Merge requests · Inkscape / inkscape · GitLab Add selection file to bypass Windows command length limits (correction) (865df7a5) · Commits · Inkscape / inkscape · GitLab Draft: Fix AppImage crashing during save on older distros (!7922) · Merge requests · Inkscape / inkscape · GitLab e71fa7f8e0858aab87b7fc0814a30a8c88da9b43 to fe225a6b9e1042c7221d95173be22a02b3725337 · Martin Owens / inkscape · GitLab 403 Forbidden on Inkscape web server (#693) · Issues · Inkscape / inkscape-web · GitLab 403 Forbidden on Inkscape web server (#13509) · Issues · Inkscape / Inbox · GitLab Add selection file to bypass Windows command length limits (correction) (!7917) · 合并请求 · Inkscape / inkscape · GitLab Non-vertical axonometric axis implementation (!7912) · Merge requests · Inkscape / inkscape · GitLab Update split mode on tab switch (!7915) · Merge requests · Inkscape / inkscape · GitLab inset/offset as app functions so they can be used from CLI (!7914) · Merge requests · Inkscape / inkscape · GitLab Performace regresion in last month (#5879) · Issues · Inkscape / inkscape · GitLab [Regression] Right-aligned text has a new gap in 1.4.4 (#6130) · Issues · Inkscape / inkscape · GitLab [Regression] Right-aligned text has a new gap in 1.4.4 (#13498) · Issues · Inkscape / Inbox · GitLab c503804e014994d611de1b225bee8158c06448a8 to a4588d8ead1e7049b90c5a126962746ed286ab17 · Inkscape / inkscape-web · GitLab Validate the extensions of signature file uploads (a4588d8e) · 提交 · Inkscape / inkscape-web · GitLab Allow color conversions using static arrays instead of just vectors (e71fa7f8) · 提交 · Martin Owens / inkscape · GitLab Speed up ungroup on thousands of items (!7908) · Merge requests · Inkscape / inkscape · GitLab Incorrect handling of FontMatrix and transformation matrices with internal PDF import (#4845) · Issues · Inkscape / inkscape · GitLab Handling edge case of negative fonts in PDF (59040229) · 提交 · Inkscape / inkscape · GitLab Handling edge case of negative fonts in PDF (!7911) · 合并请求 · Inkscape / inkscape · GitLab Allow color conversions using static arrays instead of just vectors (33e65d1b) · Commits · Martin Owens / inkscape · GitLab Allow color conversions using static arrays instead of just vectors (9be5f867) · Commits · Martin Owens / inkscape · GitLab a9672ea1dff483b5b3aa8c6b5d88cd223001bef5 to 512a5e57602ac52e1d35782a7dcebae04262b2b8 · Martin Owens / inkscape · GitLab Add selection file to bypass Windows command length limits (!7905) · 合并请求 · Inkscape / inkscape · GitLab Revert Pango label changes (1.4.x) (!7907) · 合并请求 · Inkscape / inkscape · GitLab Crash on selecting a `<text>` object without a `<tspan>` inside (#5462) · Issues · Inkscape / inkscape · GitLab Fix breakage with Ubuntu 26.04 CI (!7904) · 合并请求 · Inkscape / inkscape · GitLab c673fdd5148253276826d4eda3951daaefb82607 to 356b31383ba324396a225686613236484305533d · Martin Owens / inkscape · GitLab
Add new simplifyInvisible path manipulator function (e152...
Martin Owens · 2026-04-29 · via Martin Owens activity
提交 e15296e3 编辑于 作者: Martin Owens's avatar Martin Owens 🕘
浏览文件
A new algo which finds nodes which are very close together and combines
them. This is similar to weldNodes, but it does not pre-process objects
into one path and treats curves very differently as the distance between
the nodes is very slight so no great change in the bezier point is
needed to maintain the shape.

TODO: Add a placeholder toolbar button UX. Replace me.

DEBUG: Debugging is switched on in this commit.
加载中
+13 −0
原始行号 差异行号 差异行
@@ -91,6 +91,19 @@
        </style>
      </object>
    </child>
    <child>
      <object class="GtkButton" id="simplify_btn">
        <property name="valign">center</property>
        <property name="focusable">True</property>
        <property name="focus-on-click">False</property>
        <property name="tooltip-text" translatable="yes">Join selected nodes which are very close together</property>
        <property name="has-frame">False</property>
        <property name="icon-name">node-simplify</property>
        <style>
            <class name="priority2"/>
        </style>
      </object>
    </child>
    <child>
      <object class="GtkButton" id="break_btn">
        <property name="valign">center</property>
+8 −0
原始行号 差异行号 差异行
@@ -357,6 +357,14 @@ void MultiPathManipulator::copySelectedPath(Geom::PathBuilder *builder)
    _done(RC_("Undo", "Copy nodes"));
}

void MultiPathManipulator::simplifyInvisible(double epsilon)
{
    if (_selection.empty())
        return;
    invokeForAll(&PathManipulator::simplifyInvisible, epsilon);
    _doneWithCleanup(RC_("Undo", "Simplify invisible nodes"), true);
}

void MultiPathManipulator::joinNodes()
{
    if (_selection.empty()) return;
+1 −0
原始行号 差异行号 差异行
@@ -63,6 +63,7 @@ public:
    void alertLPE();
    void duplicateNodes();
    void copySelectedPath(Geom::PathBuilder *builder);
    void simplifyInvisible(double epsilon);
    void joinNodes();
    void breakNodes();
    void deleteNodes();
+121 −0
原始行号 差异行号 差异行
@@ -421,6 +421,127 @@ void PathManipulator::copySelectedPath(Geom::PathBuilder *builder)
    builder->flush();
}

void PathManipulator::simplifyInvisible(double threshold)
{
    auto tr = _getTransform().inverse();
    auto is_small = [threshold, tr](NodeList::iterator const &from, NodeList::iterator const &end) {
        // Build a path for the segment between the two interators and measure it's length
        Geom::PathBuilder builder;
        builder.moveTo(from->position());
        int debug_count = 0;
        for (auto next_node = from; next_node && next_node != end; next_node.advance()) {
            build_segment(builder, &*next_node, &*next_node.next());
            debug_count++;
        }
        builder.flush();

        for (auto &path : builder.peek()) {
            auto len = Geom::length(Geom::paths_to_pw(path) * tr);
            std::cout << "Segments(" << debug_count << ") length: " << len << " <= " << threshold << "\n";
            return len <= threshold;
        }
        return true;
    };

    if (_selection.size() < 2)
        return;
    hideDragPoint();

    for (auto sp : _subpaths) {
        // clang-format off
// ========== DEBUG ============= //
        auto index = [sp](NodeList::iterator const &n) {
            int ret = 0;
            for (auto n2 = sp->begin(); n2 && n2 != n; n2++) {
                ret++;
            }
            return ret;
        };
        auto dout = [sp,index](NodeList::iterator const &n) {
            std::cout << "  " << n->front()->position() << " "
                      << "o---[" << n->position() << "(" << index(n) << ")"
                      << "]---o " << n->back()->position() << "\n";
        };
// =========== DEBUG ========== //
        // clang-format on

        NodeList::iterator begin = sp->begin();

        if (sp->closed()) {
            std::cout << "Closed shape\n";
            // Find a good starting point by skipping the first node IF it would
            // join with the end of the path as a tiny segment (and thus be removed)
            while (begin && begin->selected() && (begin.prev() && is_small(begin.prev(), begin))) {
                std::cout << " - Advancing closed shape for better fit\n";
                begin++;
            }
        } else {
            std::cout << "Open shape\n";
        }

        while (begin) {
            std::cout << " - Do work at (" << index(begin) << ")\n";

            NodeList::iterator start;
            NodeList::iterator end;
            Geom::OptRect area;

            for (auto node = begin; node != begin.prev() && node->selected() && node.next(); node.advance()) {
                bool valid = node.next()->selected() && is_small(node, node.next());

                if (valid && !start) {
                    std::cout << " + Next node is valid (" << index(node) << "); START\n";
                    // The use of OptRect here is needed because there isn't a "Point List" Geom object
                    // and initalising the Geom::Rect above would cause it to include 0,0
                    area = Geom::Rect(node->position(), node->position());
                    start = node;
                } else if (start) {
                    area->expandTo(node->position());
                    if (valid) {
                        std::cout << " - Next node is valid (" << index(node) << "); CONT\n";
                    } else {
                        std::cout << " + Next node is INVALID (" << index(node) << "); END\n";
                        end = node;
                        break;
                    }
                } else {
                    std::cout << " - Next node is INVALID (" << index(node) << "); SKIP\n";
                }
            }

            std::cout << "\n";

            if (start && end) {
                std::cout << " == JOIN (" << index(start) << " - " << index(end) << ")\n";
                auto new_pos = area->midpoint();

                start->setType(NODE_CUSP, false);
                start->setPosition(new_pos);
                std::cout << " Node (" << index(start) << ") moved to " << new_pos << "\n";

                // do not move handles if they aren't degenerate
                if (!end->front()->isDegenerate()) {
                    // This is the exit handle for the bezier, we move it very slightly
                    // by the same amount as the delta between the sel_end and the new_pos
                    start->front()->setPosition(end->front()->position() - (end->position() - new_pos));
                    std::cout << " Exit (" << index(end) << ") moved to "
                              << (end->front()->position() - (end->position() - new_pos)) << "\n";
                } else {
                    std::cout << " No setting curve output\n";
                }

                begin = end.next();
                for (auto to_delete = end; to_delete != start; to_delete = to_delete.prev()) {
                    std::cout << "Deleting node " << index(to_delete) << "\n";
                    sp->erase(to_delete);
                }
            } else {
                begin++;
            }
        }
    }
}

/** Replace contiguous selections of nodes in each subpath with one node. */
void PathManipulator::weldNodes(NodeList::iterator preserve_pos)
{
+1 −0
原始行号 差异行号 差异行
@@ -89,6 +89,7 @@ public:
    void insertNode(NodeList::iterator first, double t, bool take_selection);
    void duplicateNodes();
    void copySelectedPath(Geom::PathBuilder *builder);
    void simplifyInvisible(double threshold);
    void weldNodes(NodeList::iterator preserve_pos = NodeList::iterator());
    void weldSegments();
    void breakNodes() { breakNodes(true); }
加载中