Add some useful scripts :
- ThomsonConstraints is yet another constraint checker - FontConvert extracts chars from a font as binary data git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@2060 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
65eb4a54eb
commit
be1cffc1fb
26
share/grafx2/scripts/samples_2.4/picture/FontConvert.lua
Normal file
26
share/grafx2/scripts/samples_2.4/picture/FontConvert.lua
Normal file
@ -0,0 +1,26 @@
|
||||
--Font Extractor by Adrien Destugues
|
||||
--Cut the picture in characters and save them
|
||||
--to a binary file
|
||||
--
|
||||
--Copyright 2013, Adrien Destugues <pulkomandy@pulkomandy.tk>
|
||||
--
|
||||
--this file is distributed under the terms of the MIT licence
|
||||
|
||||
w,h = getpicturesize();
|
||||
|
||||
f = io.open("file.bin","w")
|
||||
|
||||
for y = 0, h-1, 8 do
|
||||
for x = 0, w-1, 8 do
|
||||
for y2 = 0, 7, 1 do
|
||||
word = 0;
|
||||
for x2 = 0,7,1 do
|
||||
word = word * 2 + getpicturepixel(x+x2,y+y2);
|
||||
-- read one word from the current line
|
||||
end
|
||||
f:write(string.char(word));
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
f:close()
|
||||
@ -0,0 +1,34 @@
|
||||
-- Thomson Constraints checker
|
||||
-- Check wether picture is compatible with Thomson computers video modes
|
||||
-- (8x1 cells with 2 colors out of 16 in each cell)
|
||||
|
||||
w,h=getpicturesize()
|
||||
xcell = 8
|
||||
|
||||
selectlayer(1)
|
||||
clearpicture(0)
|
||||
selectlayer(0)
|
||||
-- foreach grid cell
|
||||
for y=0,h-1,1 do
|
||||
for x1=0,w-1,xcell do
|
||||
-- initialize our two colors for the cell, c1 is the color of the first
|
||||
-- pixel, and we will look for c2 in the following pixels
|
||||
c1 = getpicturepixel(x1,y)
|
||||
c2 = -1
|
||||
for x2=0,xcell-1,1 do
|
||||
c = getpicturepixel(x1+x2, y)
|
||||
-- is it a new color ?
|
||||
if c ~= c1 and c ~= c2 then
|
||||
if c2 == -1 then
|
||||
-- C2 is free, we can use it for this new color
|
||||
c2 = c
|
||||
else
|
||||
-- out of colors !
|
||||
selectlayer(1)
|
||||
putpicturepixel(x1+x2,y,17);
|
||||
selectlayer(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -2,7 +2,7 @@
|
||||
--Extract unique tiles from the spare page
|
||||
--to the main one. Main page is erased.
|
||||
--
|
||||
-- Copyright 2011 Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
|
||||
-- Copyright 2011 Adrien Destugues <pulkomandy@pulkomandy.tk>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or
|
||||
-- modify it under the terms of the GNU General Public License
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user