Move_to Node

john's Avatar

john

13 Jul, 2021 04:11 AM

This happens often: I have a shape, not centered on the origin, and I want to move it to a particular location.

To do this very simple thing I have to:

  • find the centroid of the shape
  • calculate the relative position change. The easiest way to do this is:
    • open Cartan Node Library
    • copy my rel_change node
    • paste it back in my project
  • add a translate node and translate the shape using the output of rel_change

When this happened for the twelve hundredth time I finally decided just to make a new node to do this in one fell swoop. Saves time and also results in cleaner code.

move_to will appear in the next release of the Cartan Node Library. But if you need to move a shape now, you can copy it from the attached demo.

Enjoy!

John

  1. Support Staff 1 Posted by john on 03 Jul, 2022 11:08 PM

    john's Avatar

    Well, this is embarrassing.

    After ALL these years using Nodebox almost every day, and after using the align node in almost every network I make, I somehow never noticed that align already does everything my move_to node does and more!

    I always thought of align as a tool for centering things or left-justifying them or whatever. In my mind moving a single shape to a new location was a totally different function. I simply ignored the position port of the align node and always left it set to the origin.

    But of course it you put a different value there it will move the shape to that position. Even better you can center on that position, or align the top left or whatever. Nice.

    So there is simply no need for a move_to node. I will therefor deprecate it and remove it from version 3.1 of my library.

    It's strange how the human mind works. In retrospect it seems bizarre that I never noticed this before. My arbitrary mental categories created a blind spot.

    Of course it doesn't help that there is so little documentation about each node. I have sometimes been tempted to write a book with a short chapter on each node, exploring it in depth, showing how its used, and coming up with a whimsical demo for each one. But it would take me a year to write such a book and it would probably have an audience of a only a few dozen hangers on.

    So much to do, so little time.

    John

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • move_to_screenshot.png 387 KB
  • move_to_node.zip 3.6 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

30 Sep, 2022 11:36 PM
17 Sep, 2022 08:43 AM
13 Sep, 2022 09:41 AM
08 Sep, 2022 08:08 AM
07 Sep, 2022 08:48 AM

 

03 Sep, 2022 04:11 AM
25 Aug, 2022 05:07 AM
21 Aug, 2022 07:08 PM
05 Aug, 2022 05:24 AM
02 Aug, 2022 06:57 PM
01 Aug, 2022 02:02 PM