Author Topic: sprite tools  (Read 42660 times)

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
sprite tools
« on: June 21, 2014, 03:37:04 am »
1st tool
if you go here https://falkooxc.pythonanywhere.com/sprites2png
and select a zipfile that contains a set of sprites like armors or units(can be >200 files per armor) [files have to be directly in the zipfile not in a subfolder]
then you select how many columns you want
and on the click on getpng you will get a png for download that contains all sprites in an ordered list
so instead of
Code: [Select]
  - type: MYNEWUNIT.PCK
    width: 32
    height: 40
    files:
      0: Resources/mymod/MYNEWUNIT/
you do
Code: [Select]
  - type: MYNEWUNIT.PCK
    subX: 32
    subY: 40
    width: 512 #needs the real image width 512 is example
    height: 720 #needs the real image height 720 is example
    files:
      0: Resources/mymod/MYNEWUNIT.png
that way you make your mod easier to manage (pirates mod has >10000 files !) and reduce filesize by >80% (if the sprites are very similar)

2nd tool
here https://falkooxc.pythonanywhere.com/palconvert you can upload a image and convert its colors
at the moment you can only convert images that have "tftd - battlescape"-colors into ufo-battlescape colors
i attached a file where one can compare the difference this tool makes
to enable conversion of tftd-geoscape or ufopedia images one needs to change the conversion-image that i also attached here
Spoilerhow does that work:
go into your favorite image program
open the converpal.png
the first pixel is the color that appears if i find no match or (at the moment)  it appears for all pixel if i select a non "tftd-barttlescap-depth0" source
the rest of the first line is the target-palette colors 1-255
then you have multiple lines the first pixel color defines the source palette
ff00ff=depth0
ff30ff=depth1
ff50ff=depth2
ff70ff=depth3
ff90ff=ufopedia
ffb0ff=geoscape

in the last lines you will find the source palette with their corresponding first color
or you can select userdefined and the palette/colors of the uploaded image will be used
if you do that you also need to uload a Palette-Convert-File and a Target-Palette-File (under more)

tool 3 :
https://falkooxc.pythonanywhere.com/makegif

gives you the option to make new 4-tile aliens/tanks with a lot less pain than normal
take a look at the docusprites picture for "how it works" (alternative there is another descriptive image here
i take the a big tftd 4tile unit
for all ufo/tftd 4-tile units i have templates where one can edit the single frames of each animation as a complete unit
the splitting in a spritesheet png image is done via web
with the second tool https://falkooxc.pythonanywhere.com/palconvert you can fix tftd palettes (in most cases its better if you fix the colors of the template before editing/splitting)
in this docu image i wanted to show how to easy switch colors here "yellowish to green" because big ass muton soldiers need a green bigass terror unit not "walking stones"

or you can change existing spritesheets here i made a non-brown/orange version of ethereal (took like 30 seconds )

if you run into errors post the images and choices you uploaded in this thread
« Last Edit: August 03, 2014, 08:04:05 pm by Falko »

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #1 on: June 21, 2014, 03:27:54 pm »
if anyone tried to convert sprites and run into crashes
i made a small error in the example ruleset you need subX,subY, AND weight, height.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11783
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: sprite tools
« Reply #2 on: June 21, 2014, 05:39:04 pm »
Works like a charm. :)

I think there'll be a lot of mod updates soon... :)

Offline clownagent

  • Colonel
  • ****
  • Posts: 380
    • View Profile
Re: sprite tools
« Reply #3 on: June 22, 2014, 06:26:58 pm »
I tried it with some handobs or armors, but the -png I got always showed the green jump armour from Solarius Scorch,  :P

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11783
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: sprite tools
« Reply #4 on: June 22, 2014, 07:43:19 pm »
I tried it with some handobs or armors, but the -png I got always showed the green jump armour from Solarius Scorch,  :P

Lol.

Apparently I was the first - and only! - to use this program. :P

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #5 on: June 22, 2014, 10:49:48 pm »
could not reproduce :(
i changed some stuff in the code that could have an influence but since i could not get other/old "files" as output i could not test it .. can you try again?

Offline clownagent

  • Colonel
  • ****
  • Posts: 380
    • View Profile
Re: sprite tools
« Reply #6 on: June 22, 2014, 11:54:25 pm »
Now I got an internal server error when I try the conversion:

"The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #7 on: June 23, 2014, 12:00:30 am »
could you attach the zipfile you use here?

Offline clownagent

  • Colonel
  • ****
  • Posts: 380
    • View Profile
Re: sprite tools
« Reply #8 on: June 23, 2014, 12:07:13 am »
Ok, now it works.  ;D

My mistake was in the zip-folder was a subfolder with the gifs, instead of just the gifs.
Sorry for not checking your description in detail at the beginning.

Great tool!
« Last Edit: June 23, 2014, 12:08:57 am by clownagent »

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #9 on: June 23, 2014, 12:12:36 am »
great that it work now
i made the relevant part in the startpost bold now

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #10 on: June 23, 2014, 04:32:42 pm »
new tool online description in startpost (2nd tool)
try it :)
if you run into errors post the images and choices you uploaded in this thread
« Last Edit: June 23, 2014, 04:35:15 pm by Falko »

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: sprite tools
« Reply #11 on: June 26, 2014, 10:45:28 pm »
is this written in python?
(does an offline version exists?)

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #12 on: June 26, 2014, 10:46:33 pm »
its written in python and i have it working offline here

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: sprite tools
« Reply #13 on: June 26, 2014, 11:00:03 pm »
are you using this? https://www.cairographics.org/pycairo/
I'm trying to learn python. still very noob though.

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #14 on: June 26, 2014, 11:15:11 pm »
no i use offline python3+Pillow and on the web python2+PIL these are "basic" image editing libraries
cairo has more drawing functions you can make vector based images and so on thats not needed here

Spoilerhere a bit code that does the function of tool 1:
Code: [Select]
from PIL import Image
import glob,math

def combinesprites(pathglob,nrcols,outfn):
    """path2files,numberofcolumns,outputfilname"""
    ifns=[fn for fn in glob.glob(pathglob) if fn.lower().endswith(".gif") or fn.lower().endswith(".png")]
    ifns.sort()
    if ifns:
        ifiles=[]
        pre=Image.open(ifns[0])
        out=Image.open(ifns[0])
        for x in range(pre.size[0]):
            for y in range(pre.size[1]):               
                out.putpixel((x,y),0)
        for fn in ifns:
            ifiles.append(Image.open(fn))
            ifiles[-1].palette=pre.palette
        out=out.resize((pre.size[0]*nrcols,pre.size[1]*int(math.ceil(len(ifns)/nrcols))))
        addx=0
        addy=0
        for i,im in enumerate(ifiles):
            for x in range(pre.size[0]):
                for y in range(pre.size[1]):
                    out.putpixel((addx+x,addy+y),im.getpixel((x,y)))
            if addx+pre.size[0] < out.size[0]:
                addx+=pre.size[0]
            else:
                addx=0
                addy+=pre.size[1]
        out.save(outfn,optimize=False,transparency=0)

if __name__ == "__main__":
    combinesprites("odata/tftd/tank01/*.gif",16,"out.png")