Page 1 of 1

SVG

PostPosted: Thu Feb 16, 2006 9:38 pm
by Joshua Worth
I think there should be Scalable Vector Graphics in game editor, that would make a lot of possobilities. e.g. Huge levels that dont take up much space AT ALL.

Re: SVG

PostPosted: Wed Apr 15, 2015 2:46 pm
by themightymekon
Hi Joshua Worth,

I wonder why nobody has answered you? Or have they?

As you will be now aware if you are still in the forum, that the game image is all bitmap oriented. What I propose is a QUASI SVG function. i.e. First extract the object descriptions from SVG File which is XML. Then get the name of the object from that, by a bit of scripting, e.g. "CIRCLE"

Then the script feed those details extract from the file, into a circle function. The function draws the bitmap on the game, or, it erases pixels from the game screen in a circle.

We would need people to submit functions, one for each of the KEYWORDS found in the XML. Those shapes need not be made all at once, and things like blur, and gradient, are probably not worth including. I think it best to make a very simple thing first, which is solid [i.e. code you cant break]. Then maybe that function will show the way for the form of the others? A lot can be done with simple line and pixel graphics in painting!

I am currently taking a look at the circle function, and I have planned an algorithm for n sided polygon.

If anyone can make helpful suggestions, on how to erase say a line or pixel, when you want it no longer, in your game screen, I will be grateful. Also I want to know, how to set a pixel to a colour, and how to read the colour of a pixel located at x, y ? That is what is blocking progress at present.


###########################################

"Vector graphics drawing software is used for creating and editing vector graphics. It provides graphic designers with the ability to create precise, scalable and layered images. Both 3-D graphics and CAD (computer-aided design) technology rely heavily on vector graphics."

I just looked at Inkscape which is the professional favourite free editor. I had the idea that it is right to draw in the editor, purpose-built for SVG drawing. Inkscape exports 3 styles of svg file. The third is encoded compressed so we can not see what it draws by reading into it in a text editor.
The other two are plain text XML types, which we can read. I found an older type in the supplied clipart in WINK, a famous free screencasting recorder. It is here along with Wax; a great free video fx studio :
http://www.debugmode.com/wink/

Type one>
=========
<svg
addresses [urls], canvas size, id of svg
<g
<path
transform, style
</g>
</svg>

Type two>
=========
<svg
addresses [urls], canvas size, id ,sodopody version
<defs
id="defs1347" />
<sodipodi:namedview
id, canvas size,
<metadata
addresses [urls]
</metadata>
<g
Layer id
<path
object type "arc"
transform
</g>
</svg>


Type three>
=========
<?xml version
<!DOCTYPE svg PUBLIC
url
<svg
<linearGradient
id
</linearGradient>
<polygon points="13.413 76.5, 13.413 16, 17.085 17.252, 16.775 74.956", style
<g id=... />
</svg>
~~~~~~~~~~~~~

They are all in xml forms [extended metadata language ?]. I drew a simple shape. Saving it in two forms from Inkscape, I looked at the code. I show them above, with a lot of the detail removed. It shows that it wont be too hard to identify the structure. Then a script could be written which would strip the unwanted text [from my viewpoint] to leave just the simple descriptions of the shapes. The whole image could have its data stored in a C Script 'structure', so that the sizes/locations etc. of existing drawings, can be stored there, in a temporary format, used by the GE Script.
The data could be overwritten if it is allowed to use the game as a drawing surface, i.e. that the file is editable whilst in play. I suggest that Inkscape be used as a good external editor, which would need a convertor function, to format the 'structure' into the XML correctly.


Now, Inkscape can do many fancy things like blurs and gradients, which one could ignore initially, to make a test piece. That script would read a xml into ram, strip out and save the shapes, and the numbers defining them. As long as we have functions in GE Script to draw the shapes onto a canvas filled with colour, we have a way of representing the images we draw in Inkscape and saveto file, drawing into a GE canvas. Stretch your imaginations!

SVG

Postby Joshua Worth ยป 16 Feb 2006, 21:38
REMINDS US

>>Huge levels that dont take up much space AT ALL.

Yes but there are many major advantages, notwithstanding the benefit that many people will have practised Inkscape for years...The SVG is infinitely resizeable, without the edges of shapes becoming blurred. Also they are accurately drawn in Inkscape, and can be layered, in a similar way in GE. This should be no harder work than to open a sprite in a bitmap editor, make changes, and to re-save and re-open in place of the original.

I am working on a simple polygon draw idea. I borrowed my formula model, from a mathematics book, but have altered it to suit canvas drawing using lines. I think if you can test a pixel colour, that you can follow the drawn outline in a function, to draw lines to the centre of the polygon, for a colour fill polygon. Holes in a polygon may be drawn in a layer above ? I am guessing.

Food for thought!

Re: SVG

PostPosted: Sat Jun 13, 2015 11:22 am
by themightymekon
Hi Joshua,

I like your way of thinking about it which is probably correct. I would like you to eventually post a finished example; it is then possible to get other coders interested to send their inputs, and as a work group we make a useful addition to GE.

I understand your postulate. I came at it from the text in files end, since I was doing other stuff, which prompted my postulate, when I analysed the contents of the files made by the commonly used tools. I don't want to rebuild Inkscape, and I don't think we could make a reasonable attempt at that. All I am saying is that if you provide a vehicle to extract graphic objects from existing graphic files, [made by anyone], which are stored as XML TEXT, that is a fast way to grow images, by adding them into a GE game, for use as actors in that game. I am assuming from Skydereign's comments, that this would be a canvas actor.

You can write a function to draw a sized polygon, of any thickness border, filled with any colour, or blank, with the ability to rotate it to any angle. Then you don't need to call a separate function to rotate, since the first drawing, is at the angle you want. As for deletion, I believe you may want to redraw the whole object in the invisible colour, on a duplicate canvas actor, which you put in front of the old duplicate, and which masks it out to invisible while it is there. Then if later on you want to add special fx like gradient, glow, shadow etc.; this will allow you to experiment on the duplicate canvas, leaving the duplicate original untouched. That will be a fast way to undo the changes, or a basis to make further copies, with different fx on them. Much less work for the CPU than to construct each drawing from first principles is my feeling.

I am independently working as I learn GE, to make such a SVG function, for an n-sided polygon which is based on a maths formula crib sheet. If you are interested in that too, let me know. I can send you a copy of the sheet I worked on.

When we both come up with something [or any other group member] we can upload a working example. That will clarify what we are trying to make, and may get some people interested in helping.

The more the merrier!
themightymekon
:mrgreen: