Extension for 1 - 4 rounded corners

Discussion about writing code for Inkscape.
OnionJuice
Posts: 1
Joined: Fri Aug 31, 2012 10:12 pm

Extension for 1 - 4 rounded corners

Postby OnionJuice » Fri Aug 31, 2012 10:32 pm

Hi,

Just hacked together a handy (at least for me) extension which allows to seelctivly create rectangles with 1 - 4 ( yeah I know, 4 is quite pointless) rounded corners This comes in quite handy tryingto create tabs and speech bubbles.

It it more a proof of concept which definitely needs some more work on it, but it basically works.

I made it under Debian/Linux, don't know how/if it works under Windows (havent tried yet).

You need command-line php to make it work.

You can download it here: http://simon.familiekainz.at/projekte/linux/inkscape/rounded.zip

Usage:

* Create rounded rectangle
* Select rectange
* Extensions->Misc->Rounded
* Adjust settings
* Apply


Please give me some feedback/critics.

Regards.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Extension for 1 - 4 rounded corners

Postby brynn » Sat Sep 01, 2012 9:29 am

Image
Welcome to InkscapeForum!

Awesome! Always like to see new stuff for Inkscape :D

Can you explain with not too technical language, how this differs from the existing Rectangle shape tool?
I remember someone asking about setting a certain radius for the rounded corners. (sometime in the last 6 months to year, it seems to me) This will make them happy, if this new extension will do that. Of course I can't remember who it was. But perhaps they'll see this :)

PS -- I'm on Win7, 64-bit, and would be glad to test, if I can understand it well enough to use it

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: Extension for 1 - 4 rounded corners

Postby Maestral » Sat Sep 01, 2012 9:50 pm

I`ve tried it but it crashes inkscape (win7/x64/Ink 48.3.1)

Image

What Win has to say about it...

Code: Select all

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name:   inkscape.exe
  Application Version:   0.48.3.1
  Application Timestamp:   4fe5ae19
  Fault Module Name:   libglibmm-2.4-1.dll
  Fault Module Version:   0.0.0.0
  Fault Module Timestamp:   4dd5ae9a
  Exception Code:   40000015
  Exception Offset:   00031be1
  ...
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Extension for 1 - 4 rounded corners

Postby ~suv » Sun Sep 02, 2012 12:03 am

OnionJuice wrote:Just hacked together a handy (at least for me) extension which allows to seelctivly create rectangles with 1 - 4 ( yeah I know, 4 is quite pointless) rounded corners This comes in quite handy tryingto create tabs and speech bubbles.

It it more a proof of concept which definitely needs some more work on it, but it basically works.

I made it under Debian/Linux, don't know how/if it works under Windows (havent tried yet).

You need command-line php to make it work.
(…)
Please give me some feedback/critics.

Works ok on OS X 10.7.4 Lion (64bit), but fails on Mac OS X 10.5.8 (32bit, Intel).

On Mac OS X 10.5.8, Inkscape 0.48.x crashes (also with an unhandled exception in glibmm (what: Open failed)) after a warning message on the console about getopt() (among other warnings). Apparently the error messages (from the php script) somehow end up being stored at the top of the tmp SVG file generated by Inkscape (ink_ext_XXXXXX.svgZAYBX):

Code: Select all

Warning: getopt(): No support for long options in this build in /Users/my_name/.config/inkscape/extensions/rounded.php on line 7
Warning: getopt(): No support for long options in this build in /Users/my_name/.config/inkscape/extensions/rounded.php on line 9
and Inkscape fails to parse that invalid SVG file. Maybe it would be sufficient to make sure in the php script that error output is silenced, or at least not dumped into the SVG file. Didn't research the actual getopt() warning though - it might break the php script on certain systems (or with older PHP versions) anyway:

PHP version on Mac OS X 10.5.8 Leopard:

Code: Select all

$ php --version
PHP 5.2.15 (cli) (built: May 2011 18:56:00)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

PHP version on OS X 10.7.4 Lion:

Code: Select all

$ php --version
PHP 5.3.10 with Suhosin-Patch (cli) (built: Feb 20 2012 22:55:53)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

If the extension works, it's rather slow (due to spawning a separate Inkscape process with GUI window (verbs only work with GUI)). Maybe - considering that the underlying math for the union can't be incredibly complex - it might be worthwhile to do the math in the script itself and generate the resulting path there (python would be easier, since inkscape ships with several python modules offering some convenience functions for XML parsing and path writing).


Return to “Programming”