diff --git a/share/grafx2/scripts/samples_2.4/picture/FontConvert.lua b/share/grafx2/scripts/samples_2.4/picture/FontConvert.lua new file mode 100644 index 00000000..b1162978 --- /dev/null +++ b/share/grafx2/scripts/samples_2.4/picture/FontConvert.lua @@ -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 +-- +--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() diff --git a/share/grafx2/scripts/samples_2.4/picture/ThomsonConstraints.lua b/share/grafx2/scripts/samples_2.4/picture/ThomsonConstraints.lua new file mode 100644 index 00000000..cedabbb1 --- /dev/null +++ b/share/grafx2/scripts/samples_2.4/picture/ThomsonConstraints.lua @@ -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 diff --git a/share/grafx2/scripts/samples_2.4/picture/Tiler.lua b/share/grafx2/scripts/samples_2.4/picture/Tiler.lua index 760dd42e..65393833 100644 --- a/share/grafx2/scripts/samples_2.4/picture/Tiler.lua +++ b/share/grafx2/scripts/samples_2.4/picture/Tiler.lua @@ -2,7 +2,7 @@ --Extract unique tiles from the spare page --to the main one. Main page is erased. -- --- Copyright 2011 Adrien Destugues +-- Copyright 2011 Adrien Destugues -- -- This program is free software; you can redistribute it and/or -- modify it under the terms of the GNU General Public License