Fun Widget: SVG Draw

Fun Widget: SVG Draw

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Fun Widget: SVG Draw

Post by CarRepairer »

  1. Get the widget https://github.com/wagonrepairer/spring ... vgdraw.lua
  2. Put SVG images in luaui/images/svgdraw (Here's an example file - unzip it).
  3. Convert objects to paths. (Using Inkscape, Path > Object to Path )
  4. NO longer needed - Convert curves to line segments. (Using Inkscape, Extensions > Modify Paths > Flatten Beziers)
  5. In the game, type

    Code: Select all

    /luaui svgdraw
    A list of your image names will show in the console, numbered from 1 to 9.
  6. Position the mouse cursor and hit the key on your number pad corresponding to the image you wish to draw.
  7. Fun.
Image

Provided as a service I will describe how to convert a raster image (bmp, png, etc) to SVG using Inkscape. Once you do so you can proceed to the steps above.
  1. Drag and drop your image into a new SVG file.
  2. Path > Trace Bitmap
  3. Uncheck Smooth, check Remove background.
  4. Under Options, uncheck smooth corners.
  5. Click on Update.
  6. Delete the original raster image.
Edit: Updated to version 0.004.
Works without chili util header now.
Works directly on units now.
Using bezier flattening by hokomoko.
Attachments
screen00012.jpg
(546.48 KiB) Downloaded 8 times
official gnu.zip
(34.29 KiB) Downloaded 100 times
Last edited by CarRepairer on 20 May 2016, 00:21, edited 6 times in total.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Fun Widget: SVG Draw

Post by smoth »

is the svg drawn? or does it use the spring lines? it looks like the gnu is on top of the units on the right side
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Fun Widget: SVG Draw

Post by FLOZi »

smoth wrote:is the svg drawn? or does it use the spring lines? it looks like the gnu is on top of the units on the right side
Spring lines hence the bezier to line segment conversion.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Fun Widget: SVG Draw

Post by Silentwings »

I get Inkscape saying 'No object in selection to convert to path, even though I have my whole image selected" ... any ideas?
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Fun Widget: SVG Draw

Post by CarRepairer »

Silentwings wrote:I get Inkscape saying 'No object in selection to convert to path, even though I have my whole image selected" ... any ideas?
Then skip that step, it's not needed for your svg.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Fun Widget: SVG Draw

Post by CarRepairer »

Not just for fun, but for other stuff too! (SVG attached as zip).

Image
Attachments
target.zip
(3.41 KiB) Downloaded 38 times
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Fun Widget: SVG Draw

Post by PicassoCT »

Default Picture Library?
Attachments
AnotherDelivery.zip
(252.36 KiB) Downloaded 46 times
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Fun Widget: SVG Draw

Post by CarRepairer »

Got a bezier flattening function from hokomoko. This saves you a step in the setup and potentially hundreds of megabytes by keeping your SVGs smaller. Updated widget, placed on github and updated first post.
Post Reply

Return to “Lua Scripts”