fit rect to bound of imported svg

flame's Avatar

flame

27 Feb, 2015 01:39 AM

hæ—

I feel like I'm having a bit of a brain fart over this.

I'm trying to make a rect fit to the bounds of an imported sag, how would I accomplish this ?

  1. Support Staff 1 Posted by john on 27 Feb, 2015 10:24 AM

    john's Avatar

    Here is one way...

    - Set the rect position to the centroid of the svg
    - Set the rect width to a lookup on the svg with a key of "bounds.width"
    - Set the rect height to a lookup on the svg with a key of "bounds.height"

    The attached zip file contains a NodeBox document that does this along with an svg of a world map you can use to test it. To keep things tidy I colorized the rect to make the fill transparent with a black stroke width of 1, then combined the rect with the original svg to create a world map with a rectangular frame. Give it a few seconds to render.

    Hope that helps!

    John

  2. 2 Posted by flame on 27 Feb, 2015 09:43 PM

    flame's Avatar

    ah ! of course, brilliant.

    I was getting part of the way there by using a lookup, but didn't expose the properties of bound in terms of height and width.

    thankyou !

  3. Support Staff 3 Posted by Frederik De Ble... on 28 Feb, 2015 10:02 AM

    Frederik De Bleser's Avatar

    Use the “fit to” node to fit one node to another.

    https://www.nodebox.net/node/reference/corevector/fit_to

    Grtz,

    F

Reply to this discussion

Internal reply

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

Attaching KB article:

»

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

23 May, 2023 02:09 PM
12 May, 2023 10:17 PM
07 May, 2023 11:53 PM
07 May, 2023 04:43 PM
17 Apr, 2023 11:34 AM

 

15 Apr, 2023 01:31 AM
15 Apr, 2023 01:23 AM
14 Apr, 2023 02:54 AM
11 Apr, 2023 03:53 PM
08 Apr, 2023 09:59 PM
08 Apr, 2023 08:14 AM