PhotoshopForums.com Home
Navigate Contact FAQ Search Members
How to make a tiled image?
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation
 See a User Guidelines violation? Please contact us.
Author Message

Awesomeness

Joined: 01 Feb 2010
Posts: 5



PostPosted: Thu Sep 22, 2011 5:13 pm    Post subject: How to make a tiled image? Reply with quote

I am trying to make tiled images for a game. I'd like to be able to generate an image with a script that will be able to take a small image with different colors representing each (32px by 32px) tile to generate a "map" I can put into my game. This would save tons of copy/pasting.

So it could take a 10x10 px image with a bunch of pixels in colors, each representing a certain tile, and it would output a 320x320 px image with all the tiles in the right places.

How can I do this? Is it even possible? Confused
View user's profile Send private message

Paul R

Joined: 06 Apr 2010
Posts: 57



PostPosted: Fri Sep 23, 2011 1:45 pm    Post subject: Reply with quote

If you save your 10pixel x 10pixel as a Photoshop Raw, Interleaved no header
The following code should create the 320x320 map.

Code:

File.prototype.readByte = function() {
     return this.read(1).charCodeAt(0);
};
var rawFile = File.openDialog("Please select Raw Image");
rawFile.encoding = 'BINARY';
rawFile.open('r');
var FillColor = new SolidColor;
app.documents.add(new UnitValue(320,'px'),new UnitValue(320,'px'),72,"Colour Map");
var count = 0;
while(!rawFile.eof){
     FillColor.rgb.red = rawFile.readByte();
     FillColor.rgb.green = rawFile.readByte();
     FillColor.rgb.blue = rawFile.readByte();
   colourSquare(count,FillColor);
   count++;
}
rawFile.close();
function colourSquare(count,Colour){
var constant = 32;
var line = parseInt(count/10);
var LEFT = 0 + (((count %10))  * constant);
var TOP = line * constant;
var RIGHT = constant + ((count %10) * constant);
var BOTTOM =  (line * constant) + constant;
activeDocument.selection.select([[LEFT,TOP], [RIGHT,TOP], [RIGHT,BOTTOM], [LEFT, BOTTOM]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(Colour, ColorBlendMode.NORMAL, 100);
activeDocument.selection.deselect();
}
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Contact - User Guidelines >

Copyright © 2003-2016. PhotoshopForums.com, iFroggy Network. All Rights Reserved.
Powered by phpBB © phpBB Group. phpBB SEO. Privacy Policy.
We are in no way affiliated with Adobe. Photoshop, Adobe and related marks are registered trademarks of Adobe.
PhotoshopForums.com