
| # | User | Message | Date |
| 149 | shadwolf | okay thank you for the link in my idea my SVG/REBOL graph render should be easy to use and render basical graphs using a psecial graph dialect but ofcourse it will be enhanced afterward... | 10-Nov-06 18:04 |
| 148 | shadwolf | sur i do ^^ | 10-Nov-06 18:02 |
| 147 | Normand | If any person is interested in developping graphs in Rebol they may find the following links of interest: www.combinatorica.com which have the source code in mathematica for calculating graphs and depicting them. There is also the C library at www.graphviz.org and the many little languages drivers. | 1-Jul-06 17:29 |
| 146 | Pekr | would following news help us to get AGG - SVG compatible gradients? It regards AGG 2.4, new branch of AGG, and I am sure we will get it ported to REBOL too ... "New utility class template is added, gradient_lut. It allows you to easily create a color LUT for gradients from a set of color stops as they are defined in SVG, section Gradients and Patterns." | 20-Jun-06 19:29 |
| 145 | Thřr | . | 4-Apr-06 19:01 |
| 144 | shadwolf | would be fun i think | 2-Feb-06 3:01 |
| 143 | shadwolf | graph [ line "apple" red 5 12 12 8 line "banana" green 1 2 3 4 6 ] | 2-Feb-06 3:01 |
| 142 | shadwolf | some thing like | 2-Feb-06 2:59 |
| 141 | shadwolf | you have that in php and in ruby or php for example why not rebol starting from the point that rebol dialectal ability is incredible it's a pitty to not take advantage of it and show ppl hat rebol can apport on this particular application and this gives a good way to compare rebol to the other scripting language | 2-Feb-06 2:58 |
| 140 | shadwolf | as svg or as png in a simple and easy way | 2-Feb-06 2:54 |
| 139 | shadwolf | on a project like an svg graph system save.png take really all it's sens imagine a way to make easyly graphs with your rebol GCI to display graph stats in your web pages for example | 2-Feb-06 2:53 |
| 138 | shadwolf | so for me it's new lol but more serriously until AGG was not available i think the use of save/png to-image was really not meaning | 2-Feb-06 2:51 |
| 137 | shadwolf | Anton i discover it recently ^^ | 2-Feb-06 2:50 |
| 136 | Anton | View 1.2.1 has save/png, it's not very new... | 2-Feb-06 2:19 |
| 135 | shadwolf | if some one is interressed to make it and need informations i'm ready to help ^^ | 2-Feb-06 2:16 |
| 134 | shadwolf | hum new rebol/view have save/png hability woooooooooooopy so there is nothing that prevent us to make a graph /AGG/SVG/PNG dialect ^^ | 2-Feb-06 2:15 |
| 133 | shadwolf | surfing around on internet i found another common application for SVG -> graphs representation. The idea is inspired by a ruby project http://www.germane-software.com/software/SVG/SVG::Graph/#N10034. To do this in rebol we need teh ability to save data in an image PNG. The way we can use a thing like this could be to use a simple rebol draw based dialect to write the graphs if we are in REBOL/view application the graph is isealy shown if we need to show the graph in webrowser we can have 2 external sources SVG and PNG. For importing graphs from another application the SVG is the best way. So our REBOL::SVG::GRAPH would be able to import graphi content from a SVG file, output SVG and PNG files, render graphs to REBOL/view draw pane, propose a simple way to implement graphs using a rebol dialect. | 24-Jan-06 20:13 |
| 132 | shadwolf | Joe hum inkscape is not able to show this svgz file that's strange ... I will try to investigate why this happend ... | 4-Jan-06 1:22 |
| 131 | Joe | shadwolf, a good example to use with your svg renderer is the word map with political borders (public domain license) http://www.mappinghacks.com/maps/world_borders.svgz | 3-Jan-06 11:31 |
| 130 | Ashley | When I find some spare time. ;) Next week or two hopefully. | 3-Jan-06 6:13 |
| 129 | JaimeVargas | Ashely when are you updating RebGUI? | 3-Jan-06 3:08 |
| 128 | Ashley | One other big advantage is that there is a lot of high-quality SVG in the public domain, and it's growing fast. | 3-Jan-06 2:58 |
| 127 | shadwolf | for me to be honnest the advantages of using SVG instead of images are a lot this is a quick list of my thoughts on what can be done with SVG format. - easier embeding of graphical content - resizing auto ith not grphics quality loss - cheap but sharp skining - graphical content of an User Interface very low because rebol is pretty able to work with compression of text content ( compress/decompress) A little sample to enlight this compressed SVG file with blender logo -> less than 500 octets (any size can be applyed with no graphic loss (aliasing, color loose, blur, pixelisation etc..) ) a fixed jped for same content will use around 50ko. This means less datas in memory to as graphic pixel tables are very heavy in VM memory - Dynamic graphical content. some thing like text scrolling or efffect like Flash ones but with a reduction of 1000 of the data and memory use SVG use a labeling system for each graphical content that compose the image we can provided a tiny system to handle easy animation and show/hide of graphical content using raw rebol commands -> this will make pretty easier the realisation of dynamic animations in rebol ViD content and as any REBOL/View face is DRaw/AGG capable the effects that we can create isn the futur with this idea will have no limits -> this means too to have a pretty fast and ell designed SVG engine (that's my actual path on research) | 2-Jan-06 23:48 |
| 126 | shadwolf | but this not means i'm not anymore interrested by the project or that the project is dead. I found like you pretty hudge hopes on the integration of High scalable grphics in rebol ^^ | 2-Jan-06 23:35 |
| 125 | shadwolf | ty ashley ^^ time i wasn't giving notice of my progress but mainly because Gradeint and transform problem where dependent on AGG an not on my script. | 2-Jan-06 23:33 |
| 124 | Ashley | Well done, keep up the good progress! ;) | 2-Jan-06 2:13 |
| 123 | shadwolf | In the futur i hope we will use a lot svg in dynamic drawing composition. | 1-Jan-06 6:03 |
| 122 | shadwolf | I still take as SVG workshop / reference software INKSCAPE pretty good LGPL sofware available for all OS. | 1-Jan-06 6:02 |
| 121 | shadwolf | well last thing i can say is that SVG rendering engine is very high on my task list ( task number one) i worked on the adding of some other new drawing primitive (image rect, circles). I will continue to work on the close support of all SVG datas that can have a meaning in AGG context. SVG rendering engine is a 2 weeks of work only!!! ... until i fall on the gradient and transforms problems so this ensure us advancing on this project will be very fast once we solve bugs in REBOL/View related to AGG (wich is in progress actually) | 1-Jan-06 6:00 |
| 120 | shadwolf | transform problem are on their way to be solve gradient too by cyphre and Carl those two things are the most blockant problems until they are not completly solved we can't expect to have a full working SVG rendering engine -> most of SVG imagines use transform effects and gradients this means that if we want to get a pretty good and reliable SVG engine we have to fixe those two issue. SVR rendering engine is a good and hudge test upon AGG integration to REBOL/View and it allows us to embetter it !!! Once we get a fully working engine with basic human understandable algorithm i will start the optimisation process using parse (but to be franck i don't know how parse will react in front svg row data or how will be the time to dev this parse based SVG engine ... in all cases I think the actual engine have teached me a lot arrounf the SVG to AGG adaptation process so i hope the translation to parse and parse/rules will not be too hard and too long) | 1-Jan-06 5:53 |
| 119 | shadwolf | For ppl interrested in SVG rendering engine. My tonight work and test on the engine is resumed in the AGG topic. To resume before matrix bug as causing bad scale and bad position. Now we have good position but still bad scale i post screen cap samples and we can see that the evolution is good betwin View 1.3.1 and 1.3.2 | 1-Jan-06 5:45 |
| 118 | shadwolf | personnaly I'm working with InkScape a very good SVG software... | 5-Aug-05 11:15 |
| 117 | shadwolf | Good list ;) | 5-Aug-05 11:15 |
| 116 | Robert | FYI: Ed Pegg writes "I did a survey of all available vector-based drawing programs, in anticipation of SVG in the next Firefox. I found 29 different vector drawing programs. Of these, 14 were free or open source. More than I expected. Did I miss any good ones?" http://developers.slashdot.org/article.pl?sid=05/08/02/0117224&from=rss | 5-Aug-05 6:24 |
| 115 | shadwolf | Features still on the work table are: - SVG Transformation translation (mostly matrix) - SVG Gradient translation (linear partern radiant) - SVG drawing primitives (some drawing primitives are not supported actually ) - SVG Animation translation (don't know if this is a usefull and suitable fonctionnality tellme what do you think about it) | 22-Jul-05 9:31 |
| 114 | shadwolf | and I'm close to have found a solution to one of my problems regarding to the transformation matrix | 11-Jul-05 21:58 |
| 113 | shadwolf | I'm hard working on the matrix support .. | 11-Jul-05 21:56 |
| 112 | Ashley | Release 15 of the OpenClipart library is out: http://www.openclipart.org/downloads/index.php ... over 4,000 high-quality *public domain* SVG images! | 11-Jul-05 14:41 |
| 111 | shadwolf | Chanlog:
* Cleaner Code (near 200 lines saved)
* support new draw primitives Ellipse, Path Arc, rect
* recursiv G block parsing have been improved Still not supported * transformation information (matrix,scale, rotate, skew) * gradient information (linear, radiant etc...) * circle, text, line, polyline, polygones | 5-Jul-05 3:29 |
| 110 | shadwolf | http://shadwolf.free.fr/svg-demo-shad05.r | 5-Jul-05 3:24 |
| 109 | shadwolf | here is the new version | 5-Jul-05 3:22 |
| 108 | shadwolf | I have improved the svg rendering engine | 5-Jul-05 3:22 |
| 107 | shadwolf | ************ | 5-Jul-05 3:21 |
| 106 | shadwolf | I improve some more the rendering now the file gnome-keyboard-dev.svg is fully and perfectly rendererd. I put a red pen-fill color for identify all primitives that needs fill:url related gradient | 3-Jul-05 3:06 |
| 105 | shadwolf | corrected ;) | 3-Jul-05 2:12 |
| 104 | shadwolf | I need to handle others drawing primitivs too | 3-Jul-05 2:07 |
| 103 | shadwolf | still lot of work on it gradients and transform handling can be very code consummer | 3-Jul-05 2:06 |
| 102 | shadwolf | my actual code is about 587 lines of code and it's not ended | 3-Jul-05 2:05 |
| 101 | shadwolf | this could be a good promotion point to insert SVG rendering into the rebplug for firefox once it's completed and optimised ;) | 3-Jul-05 2:05 |
| 100 | shadwolf | but what I need are high level information and formation on draw agg and this I know very little people that can respond in this point :) | 3-Jul-05 2:03 |
| 99 | shadwolf | so you have to remaining choice (3 in fact ) 1) using IE but then your not my pal any more, 2) installing Inkscape and relate it to svg file 3) help me finishing the SVG viewer using REBOL !!! ;)) | 3-Jul-05 2:02 |
| 98 | Graham | I got the Adobe plugin to work with firefox eventually. | 3-Jul-05 1:59 |
| 97 | shadwolf | maybe they saw a boggus open door in this plugin and disable it's support (this can be the case for a 1.0.4) | 3-Jul-05 1:59 |
| 96 | shadwolf | GRaham same for me adobe plugin works well with IE but not with firefox | 3-Jul-05 1:58 |
| 95 | shadwolf | so we can see in my code 2 approch for retrieving information one for top level second for g tags (groups can be recursiv) | 3-Jul-05 1:58 |
| 94 | Graham | Firefox is supposed to be able to support SVG ( a subset at least ) without plugins, but I couldn't get it to work. I had to download Adobe's plugin. | 3-Jul-05 1:57 |
| 93 | shadwolf | hahaha ;) | 3-Jul-05 1:57 |
| 92 | shadwolf | oups I make it only for groups ;) | 3-Jul-05 1:57 |
| 91 | shadwolf | now supports rect tag ;) | 3-Jul-05 1:56 |
| 90 | shadwolf | http://shadwolf.free.fr/svg-demo-shad04.r | 3-Jul-05 1:56 |
| 89 | Ashley | No argument here. ;) | 3-Jul-05 1:21 |
| 88 | shadwolf | but you know now my way to work I prefer easy and powerfull /flexible code than hudge monolitic code ;) | 3-Jul-05 1:20 |
| 87 | shadwolf | Handling SVG as REBOL object! tree makes it really really easier to set recursivity and code writing ( as all can be exploded into small fonctions I hope the resulting code once terminated won't be so deficult to read | 3-Jul-05 1:19 |
| 86 | shadwolf | I like the XML primitive draw explorer like a tree view of the compoun of your draw this is particularly good to write SVG renderer | 3-Jul-05 1:18 |
| 85 | shadwolf | I psent lot of time using it (more than 80 hours since this last weeks ) all SVG files that I could found exists | 3-Jul-05 1:17 |
| 84 | shadwolf | I like particularly the capability of generating light weight SVG files (plein text) the drawing tools are simple powerfull very well thinked and pretty good | 3-Jul-05 1:16 |
| 83 | shadwolf | All this to say that it doesn't fall from the sky ;) | 3-Jul-05 1:15 |
| 82 | shadwolf | Inkscape is the successor project of sodipodi (for example you can see reference to sodipodi into teh SVG output files ...) Sodipodi was abandonned by the dev team so some of them retakes it and continue the adventure with inkscape | 3-Jul-05 1:14 |
| 81 | Ashley | I've spent quite a bit of time looking at Inkscape (http://www.inkscape.org/) and it seems to be the only / best SVG game in town (their command-line driven SVG to PNG conversion seems to be particularly well regarded). Looking forward to their 0.42 release as it supports OS/X as well. The Clip Art site that they link to (http://www.openclipart.org/) is also a treasure trove of Public Domain files (which solves the GPL concerns I had with many of the dedicated KDE / Gnome icon sets). I'm also looking forward to their release 15 which seems to be just around the corner. Lots of good news in the SVG world, I wonder how long before mainstream browsers start supporting it? (without plugins). | 3-Jul-05 1:12 |
| 80 | Ashley | Good progress! If you change: "stroke-width" [line-width: to decimal! val] to "stroke-width" [line-width: to-unit val] then it'll run all your sample SVG icon files as well. Wish I knew the answers to your AGG questions, but like you I'm waiting on more documentation / examples. | 3-Jul-05 0:53 |
| 79 | shadwolf | what is not supported are radial / linear Gradient (content and border), transformations (local/global I'm still pending for informations on it) and all other shapes than path (like rect for example) | 2-Jul-05 21:18 |
| 78 | shadwolf | this script support recursive G block (objects /list) and path (object list) | 2-Jul-05 21:13 |
| 77 | shadwolf | try to load all the files that Ashley provides with his svg-demo | 2-Jul-05 21:13 |
| 76 | shadwolf | http://shadwolf.free.fr/svg-demo-shad04.r | 2-Jul-05 21:12 |
| 75 | shadwolf | Okay so here is the first version of my work on SVG to rebol objects tree structure | 2-Jul-05 21:12 |
| 74 | shadwolf | *********** | 2-Jul-05 21:10 |
| 73 | shadwolf | so in Rebol tree object the g block can be a bloc of sub object or an object ;) | 2-Jul-05 16:27 |
| 72 | shadwolf | hum xpdf.svg file shows me a problem with the use of xml-to-object ... if you have serveral g block at the same level all g block are compacted into the same reference | 2-Jul-05 16:26 |
| 71 | shadwolf | I don't know how to treat linearGradient too | 2-Jul-05 15:17 |
| 70 | shadwolf | I still not soleve my matrix problems so until now I don't implement it into the actual code | 2-Jul-05 15:15 |
| 69 | shadwolf | the recursivity treatement for g block are also easier to do | 2-Jul-05 15:14 |
| 68 | shadwolf | I'm still working full time on the S VG renderer. I'm close to be at the same level than the previous code but as I'm working with objects the code seems to be more fast ... | 2-Jul-05 15:13 |
| 67 | shadwolf | *************** | 2-Jul-05 15:12 |
| 66 | shadwolf | at this point code have not drastically change ... like 40% is the same code | 1-Jul-05 10:55 |
| 65 | shadwolf | I solve this issue regarding object retriving information I will enhance this pont to make it recursif retriever | 1-Jul-05 10:55 |
| 64 | shadwolf | and the windows where the draw block is shown | 1-Jul-05 0:02 |
| 63 | shadwolf | in this file we have xml-to-object function load-svg function (mostly empty there is where to put the data conversion and draw block construction) and the widget that start the program | 1-Jul-05 0:01 |
| 62 | shadwolf | http://shadwolf.free.fr/svg-demo-shad03.r | 30-Jun-05 22:32 |
| 61 | shadwolf | wrong adress | 30-Jun-05 22:32 |
| 60 | shadwolf | oups sorry | 30-Jun-05 22:32 |
| 59 | shadwolf | shadwolf.free.fr/svg-demo-shad04.r | 30-Jun-05 22:31 |
| 58 | shadwolf | I give you the code maybe this will be more clear | 30-Jun-05 22:30 |
| 57 | shadwolf | so to build the path we start xml/svg "/ " g or path if g we seek 3 thing transform field and path field or sub g field | 30-Jun-05 22:29 |
| 56 | shadwolf | or maybe build the path xml/svg/path then attribute to a temporary var the foreach ob xml/svg/path [ ob processing ] | 30-Jun-05 22:24 |
| 55 | shadwolf | I I want to interrogate the first shape description on the top level ( out of group blocks) I have to build a path like that xml/svg/path/1/d | 30-Jun-05 22:22 |
| 54 | shadwolf | for example my object is set into xml global variable | 30-Jun-05 22:20 |
| 53 | shadwolf | my point is to make a recursif capapble code | 30-Jun-05 22:20 |
| 52 | shadwolf | and fill the draw block with this data | 30-Jun-05 22:19 |
| 51 | shadwolf | then construc path to get data then translate this data to a draw equivalent exploitable datas | 30-Jun-05 22:19 |
| 50 | shadwolf | this means to interogate the content of the objet a gived level | 30-Jun-05 22:18 |
| 49 | shadwolf | I make a base code but now I have to find a good code to exploit the relevent datas from the object tree | 30-Jun-05 22:18 |
| 48 | shadwolf | this in the goal to improve drastically the performance and be more performant on some key issues like recursivity etc... | 29-Jun-05 20:37 |
| 47 | shadwolf | opkay so we are planning on the opportinity to use a REBOL tree object! structure to represente SVG datas :) | 29-Jun-05 20:36 |
| 46 | shadwolf | it says author hahah ;) | 29-Jun-05 20:35 |
| 45 | BrianW | shadwolf, I'm not the author - just a guy who made it available in the Rebol library :-) | 29-Jun-05 19:36 |
| 44 | shadwolf | okay good stuf in it Vincent and I are planning to use the xml-to-object.r script from Brian Wisti to enbetter and make a more sophisticate support for our actual work upon SVG parsing translation and rendering into a VID window | 29-Jun-05 17:14 |
| 43 | Ashley | Yes, to-unit is called from svg-size; and also from "path d", stroke-width, fill-width, etc ... probably anywhere in SVG where we "expect" an integer or decimal! ;) | 27-Jun-05 3:19 |
| 42 | shadwolf | ?? | 26-Jun-05 20:10 |
| 41 | shadwolf | in svg-size | 26-Jun-05 20:10 |
| 40 | shadwolf | where do I plug the to-unit function ? | 26-Jun-05 20:06 |
| 39 | shadwolf | so you avac primitive(fill:url) ->LinearGRadient (coords) -> LinearGradient (colors order) | 26-Jun-05 20:03 |
| 38 | shadwolf | linearGradient for example are splitted the first one contain the coordonates systeme and tranfromation informations the second one countains the colors involved and their order in the gradient | 26-Jun-05 20:02 |
| 37 | shadwolf | I read most of the documentation but then make the link to AGG data structure is rather difficult | 26-Jun-05 19:59 |
| 36 | shadwolf | see chapter 7.10 | 26-Jun-05 19:59 |
| 35 | shadwolf | http://www.w3.org/TR/SVG/coords.html | 26-Jun-05 19:58 |
| 34 | shadwolf | the page where I found the conversion rules | 26-Jun-05 19:58 |
| 33 | shadwolf | I copy past the conversion units into the script becaus I know that could be usefull but AS I was working on lineargradient and as it's a complicated part of the format SVG I had no time to make a conversion algorithm I glad to see that you make it :) | 26-Jun-05 19:53 |
| 32 | shadwolf | Ashley yes !!! You noticed right I found them deep hided in the SVG format documentation on W3C dedicated pages to SVG format .... | 26-Jun-05 19:52 |
| 31 | Ashley | Noticed you found some conversion numbers (where from?? ;) ), so here's a simple func to make use of them: to-unit: func [s [string!]] [ switch/default skip tail s -2 [ "pt" [1.25 * to decimal! copy/part s -2 + length? s] "pc" [15 * to decimal! copy/part s -2 + length? s] "mm" [3.543307 * to decimal! copy/part s -2 + length? s] "cm" [35.43307 * to decimal! copy/part s -2 + length? s] "in" [90 * to decimal! copy/part s -2 + length? s] "px" [to decimal! copy/part s -2 + length? s] ][ to decimal! s ] ] | 26-Jun-05 1:38 |
| 30 | shadwolf | http://shadwolf.free.fr/svg-demo02.zip | 24-Jun-05 23:00 |
| 29 | shadwolf | if you wants to write the "in" AGG/draw code that is based on my rebol linear gradient list there is the code and a sample file from InkScape | 24-Jun-05 23:00 |
| 28 | shadwolf | I think I handle web the creation of the rebol list of linear gradient | 24-Jun-05 22:59 |
| 27 | shadwolf | how to apply a matrix tranformation only over a grendient definition ? | 24-Jun-05 20:35 |
| 26 | shadwolf | and I have some asks | 24-Jun-05 20:34 |
| 25 | shadwolf | I'm working hard on the translation of the linearGradient informations from SVG files to AGG | 24-Jun-05 20:33 |
| 24 | shadwolf | drawing primitives have a xlink:href field that point to the appropiate main lineargradient (countainer) | 24-Jun-05 12:26 |
| 23 | shadwolf | yes DideC you are right the most problem will be to create tht tree structure to store all the LinearGradient définition and there childs then retrieve the approprieted informations | 24-Jun-05 12:25 |
| 22 | DideC | I suppose 'fill-pen is what you need. Can render gradient in many way. | 24-Jun-05 7:25 |
| 21 | shadwolf | for example the implementation of the LIneargradient I dont have any idea about how to translate it to AGG | 24-Jun-05 1:56 |
| 20 | shadwolf | yes it' quite a nightmare for a AGG newbie as I'm ... | 24-Jun-05 1:55 |
| 19 | Vincent | Thanks Ashley: there's still a lot of work to do - as SVG is quite flexible | 24-Jun-05 1:43 |
| 18 | shadwolf | matrix intervention of cyphre could be very educationnal and help me a lot to see what I'm messing in my code | 24-Jun-05 1:41 |
| 17 | shadwolf | groupe title rename done | 24-Jun-05 1:40 |
| 16 | shadwolf | okay I have imporved matrix support it seems to be good for scale-x: 1 scale-y: 1 if cyphre can see the code of the matrix gestion and makes some fix optimisation it could allow us to advance more with the rest of the SVG word format | 24-Jun-05 1:39 |
| 15 | Ashley | Thanks for taking this up and running with it guys, you're making great progress (far better than I could have). Feel free to take ownership of the code and refactor it as needed. Two minor improvements are: unless closed? [insert tail shape reduce ['move 0x0]] which is Gabriele's fix to the shape close problem, and: feel: make feel [ redraw: func [face act pos] [ if act = 'draw [insert clear face/effect/draw load-svg face/data face/size] ] ] which cleans the sample feel code up a bit. I'd also remove "VID" from the title of this group as DRAW AGG is tied to View. ;) | 24-Jun-05 1:02 |
| 14 | shadwolf | can be found on http://shadwolf.free.fr/svg-demo-shadwolf.r | 23-Jun-05 23:18 |
| 13 | shadwolf | support MLHVCSQT commands | 23-Jun-05 23:18 |
| 12 | shadwolf | New D field for "path" flag processing and translation made by Vincent | 23-Jun-05 23:15 |
| 11 | shadwolf | so my version of the script supports in the SVG <g> block with in this block header transform matrix and in block <G> path with or without in it tranform matrix. I have a little problem with this point. Then I add the support for path d field coded in the format of INKSCAPE SVG PLAIN TEXT (the SVG light weight version available under inkscape ) | 23-Jun-05 21:04 |
| 10 | shadwolf | I allways use as reference script for my work the blender.svg file provided in ashley's archive svg-demo.zip | 23-Jun-05 20:59 |
| 9 | shadwolf | my FTP tis back from death so here is my last script http://shadwolf.free.fr/svg-demo-shadwolf.r | 23-Jun-05 20:58 |
| 8 | shadwolf | corrected thank you vincent ;) | 23-Jun-05 18:21 |
| 7 | shadwolf | REBOL [
Title: "SVG Demo"
Owner: "Ashley G. Trüter"
Version: 0.0.1
Date: 21-Jun-2005
Purpose: "Loads and displays a resizeable SVG file."
History: {
0.0.1 Initial release
}
Notes: {
Tested on very simple SVG icons
Only a few basic styles / attributes / commands supported
Does not handle sizes in units other than pixels (e.g. pt, in, cm, mm, etc)
SVG path has an optional close command, "z" ... AGG shape equivalent auto-closes
load-svg function needs to be totally refactored / optimized ... *sample only*
}
] ; The following commands are available for path data: ; ; M = moveto ; L = lineto ; H = horizontal lineto ; V = vertical lineto ; C = curveto ; S = smooth curveto ; Q = quadratic Belzier curve ; T = smooth quadratic Belzier curveto ; A = elliptical Arc ; Z = closepath ;print: none ; comment out this line to enable debug messages load-svg: function [svg-file [file! string!] size [pair!]] [ id defs x y to-color to-byte draw-blk append-style svg-size scale-x scale-y ][ xml: either string? svg-file [parse-xml svg-file] [ unless %.svg = suffix? svg-file [to error! "File has an invalid suffix!"] parse-xml read svg-file ] unless xml/3/1/1 = "svg" [to error! "Could not find SVG header!"] ;unless find ["id" "xmlns"] xml/3/1/2/1 [to error! "Could not find ID header!"] ;unless xml/3/1/3/1/1 = "defs" [to error! "Could not find DEFS header!"] id: xml/3/1/2 defs: xml/3/1/3 ; ; --- Parse SVG id ; svg-size: either find ["32pt" "48pt" "72pt"] select id "width" [ switch select id "width" [ "72pt" [120x120] "48pt" [80x80] "32pt" [60x60] ] ][ as-pair to integer! any [select id "width" "100"] to integer! any [select id "height" "100"] ] x: to integer! any [select id "x" "0"] y: to integer! any [select id "y" "0"] scale-x: size/x / svg-size/x scale-y: size/y / svg-size/y ; ; --- Helper functions ; to-color: func [s [string!]] [ ; converts a string in the form "#FFFFFF" to a 4-byte tuple to tuple! load rejoin ["#{" next s "00}"] ] to-byte: func [s [string!]] [ ; converts a string with a value 0-1 to an inverted byte 255 - to integer! 255 * to decimal! s ] ; ; --- Parse SVG defs ; draw-blk: copy [] append-style: function [ command [string!] blk [block!] ][ x xy pen-color fill-color line-width mode size radius shape closed? matrix transf-command ][ xy: 0x0 size: 0x0 line-width: 1 matrice: make block! [] radius: none transf-command: none foreach [attr val] blk [ switch attr [ "transform" [print "tranform have been found" ;probe val halt val: parse val "()," transf-command: first val probe transf-command switch transf-command [ "matrix" [ foreach word val [ if not find word "matrix" [ insert tail matrice to-decimal word ] ] ] ] ] "style" [ foreach [attr val] parse val ":;" [ switch/default attr [ "font-size" [ ] "stroke" [ switch/default first val [ #"#" [pen-color: to-color val] #"n" [pen-color: none] ][ print ["Unknown stroke:" val] ] ] "stroke-width" [line-width: to decimal! val] "fill" [ fill-color: switch/default first val [ #"#" [to-color val] #"n" [none] ][ print ["Unknown fill value:" val] none ] ] "fill-rule" [ mode: switch/default val [ "evenodd" ['even-odd] ][ print ["Unknown fill-rule value:" val] none ] ] "stroke-opacity" [pen-color: any [pen-color 0.0.0.0] pen-color/4: to-byte val] "fill-opacity" [fill-color: any [fill-color 0.0.0.0] fill-color/4: to-byte val] "stroke-linejoin" [ insert tail draw-blk switch/default val [ "miter" [compose [line-join miter]] "round" [compose [line-join round]] "bevel" [compose [line-join bevel]] ][ print ["Unknown stroke-linejoin value:" val] none ] ] "stroke-linecap" [ insert tail draw-blk 'line-cap insert tail draw-blk to word! val ] ][ print ["Unknown style:" attr] ] ] ] "x" [xy/x: scale-x * val] "y" [xy/y: scale-y * val] "width" [size/x: scale-x * val] "height" [size/y: scale-y * val] "rx" [print "rx"] "ry" [radius: to decimal! val] "d" [ shape: copy [] x: none closed?: false if all [x not number? token] [ insert tail shape x * either token = 'V [scale-y][scale-x] x: none ] foreach token load val [ switch/default token [ M [insert tail shape 'move] C [insert tail shape 'curve] S [insert tail shape 'curv] L [insert tail shape 'line] Q [insert tail shape 'qcurve] T [insert tail shape 'qcurv] z [closed?: true] H [insert tail shape 'hline] V [insert tail shape 'vline] A [insert tail shape 'arc] ][ unless number? token [print ["Unknown path command:" token]] either x [insert tail shape as-pair x scale-y * token x: none] [x: scale-x * token] ] ] ] ] ] insert tail draw-blk compose [ pen (pen-color) fill-pen (fill-color) fill-rule (mode) line-width (line-width * min scale-x scale-y) ] switch command [ "rect" [ insert tail draw-blk compose [box (xy) (xy + size)] if radius [insert tail draw-blk radius] ] "path" [ unless closed? [print "Path closed"] either transf-command <> none [ switch transf-command [ "matrix" [insert tail draw-blk compose/only [ (to-word transf-command) (matrice) shape (shape) reset-matrix]] ] ][ insert tail draw-blk compose/only [shape (shape)] ] ] "g" [ print "Write here how to handle G insertion to Draw block" insert tail draw-blk probe compose/only [reset-matrix (to-word transf-command) (matrice)] ] ] ] probe defs foreach blk defs [ switch first blk [ "rect" [append-style first blk second blk] "path" [append-style first blk second blk] "g" [ print "key word" probe first blk print "matrix and style in G" probe second blk append-style first blk second blk ;print "what to draw in G" probe third blk foreach blk2 third blk [ probe blk2 switch first blk2[ "path" [append-style first blk2 second blk2] ] ] ] ] ] probe draw-blk draw-blk ] view make face [ offset: 100x100 size: 200x200 action: request-file/filter/only "*.svg" text: rejoin ["SVG Demo [" last split-path action "]"] data: read action color: white effect: compose/only [draw (load-svg data size)] edge: font: para: none feel: make feel [ detect: func [face event] [ if event/type = 'resize [ insert clear face/effect/draw load-svg face/data face/size show face ] if event/type = 'close [quit] ] ] options: [resize] ] | 23-Jun-05 18:21 |
| 6 | Vincent | Oops too fast: commands Q S T -> OK commands H &t V -> need to add (just before "foreach token load val [") : if all [x not number? token] [ insert tail shape x * either token = 'V [scale-y][scale-x] x: none ] command A -> not yet solved sign issues | 23-Jun-05 18:20 |
| 5 | shadwolf | REBOL [
Title: "SVG Demo"
Owner: "Ashley G. Trüter"
Version: 0.0.1
Date: 21-Jun-2005
Purpose: "Loads and displays a resizeable SVG file."
History: {
0.0.1 Initial release
}
Notes: {
Tested on very simple SVG icons
Only a few basic styles / attributes / commands supported
Does not handle sizes in units other than pixels (e.g. pt, in, cm, mm, etc)
SVG path has an optional close command, "z" ... AGG shape equivalent auto-closes
load-svg function needs to be totally refactored / optimized ... *sample only*
}
] ; The following commands are available for path data: ; ; M = moveto ; L = lineto ; H = horizontal lineto ; V = vertical lineto ; C = curveto ; S = smooth curveto ; Q = quadratic Belzier curve ; T = smooth quadratic Belzier curveto ; A = elliptical Arc ; Z = closepath ;print: none ; comment out this line to enable debug messages load-svg: function [svg-file [file! string!] size [pair!]] [ id defs x y to-color to-byte draw-blk append-style svg-size scale-x scale-y ][ xml: either string? svg-file [parse-xml svg-file] [ unless %.svg = suffix? svg-file [to error! "File has an invalid suffix!"] parse-xml read svg-file ] unless xml/3/1/1 = "svg" [to error! "Could not find SVG header!"] ;unless find ["id" "xmlns"] xml/3/1/2/1 [to error! "Could not find ID header!"] ;unless xml/3/1/3/1/1 = "defs" [to error! "Could not find DEFS header!"] id: xml/3/1/2 defs: xml/3/1/3 ; ; --- Parse SVG id ; svg-size: either find ["32pt" "48pt" "72pt"] select id "width" [ switch select id "width" [ "72pt" [120x120] "48pt" [80x80] "32pt" [60x60] ] ][ as-pair to integer! any [select id "width" "100"] to integer! any [select id "height" "100"] ] x: to integer! any [select id "x" "0"] y: to integer! any [select id "y" "0"] scale-x: size/x / svg-size/x scale-y: size/y / svg-size/y ; ; --- Helper functions ; to-color: func [s [string!]] [ ; converts a string in the form "#FFFFFF" to a 4-byte tuple to tuple! load rejoin ["#{" next s "00}"] ] to-byte: func [s [string!]] [ ; converts a string with a value 0-1 to an inverted byte 255 - to integer! 255 * to decimal! s ] ; ; --- Parse SVG defs ; draw-blk: copy [] append-style: function [ command [string!] blk [block!] ][ x xy pen-color fill-color line-width mode size radius shape closed? matrix transf-command ][ xy: 0x0 size: 0x0 line-width: 1 matrice: make block! [] radius: none transf-command: none foreach [attr val] blk [ switch attr [ "transform" [print "tranform have been found" ;probe val halt val: parse val "()," transf-command: first val probe transf-command switch transf-command [ "matrix" [ foreach word val [ if not find word "matrix" [ insert tail matrice to-decimal word ] ] ] ] ] "style" [ foreach [attr val] parse val ":;" [ switch/default attr [ "font-size" [ ] "stroke" [ switch/default first val [ #"#" [pen-color: to-color val] #"n" [pen-color: none] ][ print ["Unknown stroke:" val] ] ] "stroke-width" [line-width: to decimal! val] "fill" [ fill-color: switch/default first val [ #"#" [to-color val] #"n" [none] ][ print ["Unknown fill value:" val] none ] ] "fill-rule" [ mode: switch/default val [ "evenodd" ['even-odd] ][ print ["Unknown fill-rule value:" val] none ] ] "stroke-opacity" [pen-color: any [pen-color 0.0.0.0] pen-color/4: to-byte val] "fill-opacity" [fill-color: any [fill-color 0.0.0.0] fill-color/4: to-byte val] "stroke-linejoin" [ insert tail draw-blk switch/default val [ "miter" [compose [line-join miter]] "round" [compose [line-join round]] "bevel" [compose [line-join bevel]] ][ print ["Unknown stroke-linejoin value:" val] none ] ] "stroke-linecap" [ insert tail draw-blk 'line-cap insert tail draw-blk to word! val ] ][ print ["Unknown style:" attr] ] ] ] "x" [xy/x: scale-x * val] "y" [xy/y: scale-y * val] "width" [size/x: scale-x * val] "height" [size/y: scale-y * val] "rx" [print "rx"] "ry" [radius: to decimal! val] "d" [ shape: copy [] x: none closed?: false foreach token load val [ switch/default token [ M [insert tail shape 'move] C [insert tail shape 'curve] S [insert tail shape 'curv] L [insert tail shape 'line] Q [insert tail shape 'qcurve] T [insert tail shape 'qcurv] z [closed?: true] H [insert tail shape 'hline] V [insert tail shape 'vline] A [insert tail shape 'arc] ][ unless number? token [print ["Unknown path command:" token]] either x [insert tail shape as-pair x scale-y * token x: none] [x: scale-x * token] ] ] ] ] ] insert tail draw-blk compose [ pen (pen-color) fill-pen (fill-color) fill-rule (mode) line-width (line-width * min scale-x scale-y) ] switch command [ "rect" [ insert tail draw-blk compose [box (xy) (xy + size)] if radius [insert tail draw-blk radius] ] "path" [ unless closed? [print "Path closed"] either transf-command <> none [ switch transf-command [ "matrix" [insert tail draw-blk compose/only [ (to-word transf-command) (matrice) shape (shape) reset-matrix]] ] ][ insert tail draw-blk compose/only [shape (shape)] ] ] "g" [ print "Write here how to handle G insertion to Draw block" insert tail draw-blk probe compose/only [reset-matrix (to-word transf-command) (matrice)] ] ] ] probe defs foreach blk defs [ switch first blk [ "rect" [append-style first blk second blk] "path" [append-style first blk second blk] "g" [ print "key word" probe first blk print "matrix and style in G" probe second blk append-style first blk second blk ;print "what to draw in G" probe third blk foreach blk2 third blk [ probe blk2 switch first blk2[ "path" [append-style first blk2 second blk2] ] ] ] ] ] probe draw-blk draw-blk ] view make face [ offset: 100x100 size: 200x200 action: request-file/filter/only "*.svg" text: rejoin ["SVG Demo [" last split-path action "]"] data: read action color: white effect: compose/only [draw (load-svg data size)] edge: font: para: none feel: make feel [ detect: func [face event] [ if event/type = 'resize [ insert clear face/effect/draw load-svg face/data face/size show face ] if event/type = 'close [quit] ] ] options: [resize] ] | 23-Jun-05 17:49 |
| 4 | shadwolf | Vincent add some path rendering commands S Q T H A V | 23-Jun-05 17:49 |
| 3 | shadwolf | AS reference take the file blender.svg from svg-demo.zip package maide by ashley | 23-Jun-05 17:30 |
| 2 | shadwolf | REBOL [
Title: "SVG Demo"
Owner: "Ashley G. Trüter"
Version: 0.0.1
Date: 21-Jun-2005
Purpose: "Loads and displays a resizeable SVG file."
History: {
0.0.1 Initial release
}
Notes: {
Tested on very simple SVG icons
Only a few basic styles / attributes / commands supported
Does not handle sizes in units other than pixels (e.g. pt, in, cm, mm, etc)
SVG path has an optional close command, "z" ... AGG shape equivalent auto-closes
load-svg function needs to be totally refactored / optimized ... *sample only*
}
] ; The following commands are available for path data: ; ; M = moveto ; L = lineto ; H = horizontal lineto ; V = vertical lineto ; C = curveto ; S = smooth curveto ; Q = quadratic Belzier curve ; T = smooth quadratic Belzier curveto ; A = elliptical Arc ; Z = closepath ;print: none ; comment out this line to enable debug messages load-svg: function [svg-file [file! string!] size [pair!]] [ id defs x y to-color to-byte draw-blk append-style svg-size scale-x scale-y ][ xml: either string? svg-file [parse-xml svg-file] [ unless %.svg = suffix? svg-file [to error! "File has an invalid suffix!"] parse-xml read svg-file ] unless xml/3/1/1 = "svg" [to error! "Could not find SVG header!"] ;unless find ["id" "xmlns"] xml/3/1/2/1 [to error! "Could not find ID header!"] ;unless xml/3/1/3/1/1 = "defs" [to error! "Could not find DEFS header!"] id: xml/3/1/2 defs: xml/3/1/3 ; ; --- Parse SVG id ; svg-size: either find ["32pt" "48pt" "72pt"] select id "width" [ switch select id "width" [ "72pt" [120x120] "48pt" [80x80] "32pt" [60x60] ] ][ as-pair to integer! any [select id "width" "100"] to integer! any [select id "height" "100"] ] x: to integer! any [select id "x" "0"] y: to integer! any [select id "y" "0"] scale-x: size/x / svg-size/x scale-y: size/y / svg-size/y ; ; --- Helper functions ; to-color: func [s [string!]] [ ; converts a string in the form "#FFFFFF" to a 4-byte tuple to tuple! load rejoin ["#{" next s "00}"] ] to-byte: func [s [string!]] [ ; converts a string with a value 0-1 to an inverted byte 255 - to integer! 255 * to decimal! s ] ; ; --- Parse SVG defs ; draw-blk: copy [] append-style: function [ command [string!] blk [block!] ][ x xy pen-color fill-color line-width mode size radius shape closed? matrix transf-command ][ xy: 0x0 size: 0x0 line-width: 1 matrice: make block! [] radius: none transf-command: none foreach [attr val] blk [ switch attr [ "transform" [print "tranform have been found" ;probe val halt val: parse val "()," transf-command: first val probe transf-command switch transf-command [ "matrix" [ foreach word val [ if not find word "matrix" [ insert tail matrice to-decimal word ] ] ] ] ] "style" [ foreach [attr val] parse val ":;" [ switch/default attr [ "font-size" [ ] "stroke" [ switch/default first val [ #"#" [pen-color: to-color val] #"n" [pen-color: none] ][ print ["Unknown stroke:" val] ] ] "stroke-width" [line-width: to decimal! val] "fill" [ fill-color: switch/default first val [ #"#" [to-color val] #"n" [none] ][ print ["Unknown fill value:" val] none ] ] "fill-rule" [ mode: switch/default val [ "evenodd" ['even-odd] ][ print ["Unknown fill-rule value:" val] none ] ] "stroke-opacity" [pen-color: any [pen-color 0.0.0.0] pen-color/4: to-byte val] "fill-opacity" [fill-color: any [fill-color 0.0.0.0] fill-color/4: to-byte val] "stroke-linejoin" [ insert tail draw-blk switch/default val [ "miter" [compose [line-join miter]] "round" [compose [line-join round]] "bevel" [compose [line-join bevel]] ][ print ["Unknown stroke-linejoin value:" val] none ] ] "stroke-linecap" [ insert tail draw-blk 'line-cap insert tail draw-blk to word! val ] ][ print ["Unknown style:" attr] ] ] ] "x" [xy/x: scale-x * val] "y" [xy/y: scale-y * val] "width" [size/x: scale-x * val] "height" [size/y: scale-y * val] "rx" [print "rx"] "ry" [radius: to decimal! val] "d" [ shape: copy [] x: none closed?: false foreach token load val [ switch/default token [ M [insert tail shape 'move] C [insert tail shape 'curve] L [insert tail shape 'line] z [closed?: true] ][ unless number? token [print ["Unknown path command:" token]] either x [insert tail shape as-pair x scale-y * token x: none] [x: scale-x * token] ] ] ] ] ] insert tail draw-blk compose [ pen (pen-color) fill-pen (fill-color) fill-rule (mode) line-width (line-width * min scale-x scale-y) ] switch command [ "rect" [ insert tail draw-blk compose [box (xy) (xy + size)] if radius [insert tail draw-blk radius] ] "path" [ unless closed? [print "Path closed"] either transf-command <> none [ switch transf-command [ "matrix" [insert tail draw-blk compose/only [ (to-word transf-command) (matrice) shape (shape) reset-matrix]] ] ][ insert tail draw-blk compose/only [shape (shape)] ] ] "g" [ print "Write here how to handle G insertion to Draw block" insert tail draw-blk probe compose/only [reset-matrix (to-word transf-command) (matrice)] ] ] ] probe defs foreach blk defs [ switch first blk [ "rect" [append-style first blk second blk] "path" [append-style first blk second blk] "g" [ print "key word" probe first blk print "matrix and style in G" probe second blk append-style first blk second blk ;print "what to draw in G" probe third blk foreach blk2 third blk [ probe blk2 switch first blk2[ "path" [append-style first blk2 second blk2] ] ] ] ] ] probe draw-blk draw-blk ] view make face [ offset: 100x100 size: 200x200 action: request-file/filter/only "*.svg" text: rejoin ["SVG Demo [" last split-path action "]"] data: read action color: white effect: compose/only [draw (load-svg data size)] edge: font: para: none feel: make feel [ detect: func [face event] [ if event/type = 'resize [ insert clear face/effect/draw load-svg face/data face/size show face ] if event/type = 'close [quit] ] ] options: [resize] ] | 23-Jun-05 17:29 |
| 1 | shadwolf | My actual source code that render path and <g> bloack transformation matrix | 23-Jun-05 17:29 |