PureSVG - now with LoadSVG() !

Share your advanced PureBasic knowledge/code with the community.
KGB_X
User
User
Posts: 63
Joined: Tue Apr 22, 2008 6:06 pm
Location: No(r)way

Re: PureSVG (updated 27/Jan/10)

Post by KGB_X »

#Black and #White is not assigned with an value.

Using the pie chart demo it's terrible slow.

Anyhow i'm going to do some tests for how i wanted to use SVG. I want to read SVG stored from openstreetmap as i don't want an "web"browser in my software.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Re: PureSVG (updated 27/Jan/10)

Post by Progi1984 »

Just a small trick for openstreetmap embedded in your application :
http://www.purebasic.fr/english/viewtop ... nstreetmap
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: PureSVG (updated 27/Jan/10)

Post by Seymour Clufley »

KGB_X wrote:#Black and #White is not assigned with an value.
Sorry, I thought those constants came with PB.
Using the pie chart demo it's terrible slow.
How long does it take, roughly? I'm concentrating on stability just now, but speed is obviously important and will be worked on later.
I want to read SVG stored from openstreetmap
Ah, in that case PureSVG isn't what you need. It can't load SVGs. I may write a procedure for that in the future, but it would be necessary for PureSVG to handle the whole SVG spec for such a procedure to be reliable.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
KGB_X
User
User
Posts: 63
Joined: Tue Apr 22, 2008 6:06 pm
Location: No(r)way

Re: PureSVG (updated 27/Jan/10)

Post by KGB_X »

Seymour Clufley wrote:
KGB_X wrote:#Black and #White is not assigned with an value.
Sorry, I thought those constants came with PB.
I used the Linux version. Anyhow not a big issue.
Seymour Clufley wrote:
Using the pie chart demo it's terrible slow.
How long does it take, roughly? I'm concentrating on stability just now, but speed is obviously important and will be worked on later.
It's a very nice start so i don't complain.
Seymour Clufley wrote:
I want to read SVG stored from openstreetmap
Ah, in that case PureSVG isn't what you need. It can't load SVGs. I may write a procedure for that in the future, but it would be necessary for PureSVG to handle the whole SVG spec for such a procedure to be reliable.
[/quote]

I can probably add this and even if your code doesn't support everything it's a start.
KGB_X
User
User
Posts: 63
Joined: Tue Apr 22, 2008 6:06 pm
Location: No(r)way

Re: PureSVG (updated 27/Jan/10)

Post by KGB_X »

Progi1984 wrote:Just a small trick for openstreetmap embedded in your application :
http://www.purebasic.fr/english/viewtop ... nstreetmap
yes but this requires the user to be online if i'm not wrong.

I have not been able to run this example as : *LibCurl_NewMemory = AllocateMemory(MemorySize(*LibCurl_SharedMem)) always crash.
"The spesified '*MemoryID' is null"
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Re: PureSVG (updated 27/Jan/10)

Post by Progi1984 »

KGB_X wrote:
Progi1984 wrote:Just a small trick for openstreetmap embedded in your application :
http://www.purebasic.fr/english/viewtop ... nstreetmap
yes but this requires the user to be online if i'm not wrong.
But you can activate the cache with SQLite.
KGB_X wrote:I have not been able to run this example as : *LibCurl_NewMemory = AllocateMemory(MemorySize(*LibCurl_SharedMem)) always crash.
"The spesified '*MemoryID' is null"
Update your fonction like here : http://www.purebasic.fr/english/viewtop ... 81#p297281
KGB_X
User
User
Posts: 63
Joined: Tue Apr 22, 2008 6:06 pm
Location: No(r)way

Re: PureSVG (updated 27/Jan/10)

Post by KGB_X »

Progi1984 wrote:
KGB_X wrote:
Progi1984 wrote:Just a small trick for openstreetmap embedded in your application :
http://www.purebasic.fr/english/viewtop ... nstreetmap
Progi1984 wrote: yes but this requires the user to be online if i'm not wrong.
But you can activate the cache with SQLite.
KGB_X wrote:I have not been able to run this example as : *LibCurl_NewMemory = AllocateMemory(MemorySize(*LibCurl_SharedMem)) always crash.
"The spesified '*MemoryID' is null"
Update your fonction like here : http://www.purebasic.fr/english/viewtop ... 81#p297281
Ok then the user has to "visit" that area to use this cache. I was thinking of downloading different areas in advance.
I'll see if i can use it like this.

It's probably easy to overlay a sprite on this.

I checked the "RW_LibCurl_InitData()" and its identical but i get the same error.
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: PureSVG (updated 31/Jan/10)

Post by Seymour Clufley »

Another new version!

There are lots of new functions, mainly for retrieving element attributes and for editing all elements together as a "group".

I've also added the ability to store PB images inside the SVG. Until recently I didn't know this was possible. The image is converted with Base64 and this data stands in place of the "src=filename" tag. It's pretty cool as it reduces file dependency. You can do it with HTML pages as well. I don't know if it will be possible with other media types - video, audio, etc. - perhaps the size of these files would make it a bit ridiculous.

And some bug fixes:
  • Minus coordinates are now handled correctly
  • Constants added for Linux
  • I think SVG_SetVisiblePortion() now works
Some remaining bugs:
  • Bezier curves are not correctly bound-checked
  • Resizing a path that contains elliptical arcs will result in distortion
Incidentally, I'm surprised no-one has commented on the SVGGadget code by PeterB. It works very well!

Seymour.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: PureSVG (updated 31/Jan/10)

Post by Seymour Clufley »

This is a big update with lots of new features.

New stuff:
  • masks
  • the textpath element
  • PB's Plot() command has been replicated, for convenience
  • functions for handling comments
  • loading/catching (see below)
  • exporting/importing commands (see below)

I am very pleased to announce the debut of this procedure:

LoadSVG()

It's not yet complete and there are likely to be bugs. So far it seems to correctly load any SVG previously made with PureSVG, except for patterns and metadata.

PureSVG does not accommodate element attributes such as translate and transform. However, the idea is that you could "import" any valid SVG element string and PureSVG would interpret it correctly. So, for example, if the element has a transform instruction, the transforming is done immediately and the instruction is discarded. A string you import may contain attributes I haven't yet taken care of, and if this happens please post about it so I can fix it.

Alongside LoadSVG() are some other new commands:
  • CatchSVG()
  • LoadSVGFromString()
In the course of writing LoadSVG() I wrote some sub-routines which can be used independently for "importing" SVG components. This enables you to assemble an SVG from different sources. The commands are:
  • SVG_ElementFromString() (see note about element attributes, above)
  • SVG_GradientFromString()
  • SVG_PathDataFromString()
  • SVG_PolylineDataFromString()
  • SVG_StyleFromString()
Exporting can be done with "mirror" commands of the above, such as SVG_ElementToString().

Elsewhere, an important bug with element opacity has been fixed. I had wrongly concluded that Opera and Firefox ignore opacity - in fact they need it denoted as a decimal rather than a percentage (which only Chrome understands).

I've been working on PureSVG for a month now and other projects need attention, so this will take a back seat. However since both PureBasic and SVG are (hopefully) going to be around for a long time and a native SVG library is unlikely, it'd be nice if PureSVG became a comprehensive bridge between PB and SVG, supporting as much of the specification as can be made "programmable".

The remaining large omissions are filters and animation. I'll probably add filters next. At present filters are only supported by Opera and Firefox, but I think they can be implemented more quickly than animation.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
KGB_X
User
User
Posts: 63
Joined: Tue Apr 22, 2008 6:06 pm
Location: No(r)way

Re: PureSVG - now with LoadSVG() !

Post by KGB_X »

nice. i don't have time to test it this weekend but i get back when i have...
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

Re: PureSVG - now with LoadSVG() !

Post by Crusiatus Black »

This looks very promising, although the download link seems to be down. The is not available on that location,
does anyone here have a valid link for me or perhaps the include to attach?

I have always liked SVG, and have not found much support for PureBasic for it, so I'm thrilled now I do :p

Anyhow, Thanks for sharing Seymour!
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: PureSVG - now with LoadSVG() !

Post by Seymour Clufley »

A new, more reliable version is now being kindly hosted by Idle. The link is in the OP.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureSVG - now with LoadSVG() !

Post by c4s »

Sorry, I didn't test it yet but people of the german forum say that the source isn't possible to use because of missing functions and stuff. Any ideas or comments?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: PureSVG - now with LoadSVG() !

Post by Seymour Clufley »

Please check the version on Idle's site, which is the latest version.

If it asks for a procedure called "R", this is it:

Code: Select all

Macro R(t)
MessageRequester("Report",t,0)
EndMacro
It's just a shortcut for reporting a message.

If anything else is missing, please let me know and I'll upload a new version.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
tmjuk
New User
New User
Posts: 3
Joined: Sat Jun 05, 2010 1:42 am

Re: PureSVG - now with LoadSVG() !

Post by tmjuk »

Hi

its not only procedure "R"
Structure not found:PointF
or
Structure not found:RectF

the version is "v6a"

Thanks
Torsten
Post Reply