Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package;
- import openfl.Assets;
- import openfl.display.Sprite;
- import openfl.Lib;
- import openfl.display.BitmapData;
- import openfl.display.PNGEncoderOptions;
- import openfl.geom.Rectangle;
- import openfl.utils.ByteArray;
- import sys.io.File;
- import sys.io.FileOutput;
- import sys.FileSystem;
- class Main extends Sprite
- {
- var NTSCBitmap:BitmapData = Assets.getBitmapData("img/atari.png");
- var intToHex:Array<String> = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
- static inline var step:Int = 16;
- public function new()
- {
- super();
- if (!FileSystem.exists("output")) FileSystem.createDirectory("output");
- else {
- FileSystem.deleteDirectory("output");
- FileSystem.createDirectory("output");
- }
- var lumpstr:String = "";
- var noise:BitmapData = Assets.getBitmapData("img/noise.png");
- for (a in 0...16) {
- for (b in 0...16) {
- var hex = NTSCBitmap.getPixel(a * 37, b * 27);
- var bitmap_gen:BitmapData = new BitmapData(64, 64, false, hex);
- bitmap_gen.draw(noise);
- var swatchname = intToHex[a] + intToHex[b];
- var pathname = "output/" + swatchname + ".png";
- var png_out:FileOutput = File.write(pathname);
- var bytes:ByteArray = bitmap_gen.encode(new Rectangle(0, 0, 64, 64), new PNGEncoderOptions());
- png_out.writeBytes(bytes, 0, bytes.length);
- png_out.close();
- lumpstr += 'texture $swatchname' + '64A, 64, 64\r\n';
- lumpstr += '{\r\n';
- lumpstr += '\tpatch $swatchname, 0, 0\r\n';
- lumpstr += '}\r\n';
- lumpstr += 'texture $swatchname' +'64B, 64, 64\r\n';
- lumpstr += '{\r\n';
- lumpstr += '\tpatch $swatchname, 0, 0\r\n';
- lumpstr += '\tpatch DIVBLK64, 0, 0\r\n';
- lumpstr += '}\r\n';
- lumpstr += 'texture $swatchname' + '64C, 64, 64\r\n';
- lumpstr += '{\r\n';
- lumpstr += '\tpatch $swatchname, 0, 0\r\n';
- lumpstr += '\tpatch DIVWHT64, 0, 0\r\n';
- lumpstr += '}\r\n';
- }
- }
- var lumpout:FileOutput = File.write("output/TEXTURES.geometry");
- lumpout.writeString(lumpstr);
- lumpout.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement