Reorganized source code and directory tree.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1375 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud
2010-03-05 02:53:19 +00:00
parent 2012e8f6b5
commit 3ca5322379
166 changed files with 65 additions and 57 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Binary file not shown.

BIN
share/grafx2/gfx2.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
share/grafx2/gfx2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

359
share/grafx2/gfx2def.ini Normal file
View File

@@ -0,0 +1,359 @@
###### GrafX2 initialization file ###### Fichier d'initialisation de GrafX2 ##
# # # #
# You may modify this file with any # Vous pouvez modifier ce fichier avec #
# standard ASCII text editor. # n'importe quel éditeur de texte #
# # ASCII standard. #
# # #
# Comments are preceded by ';' or # Les commentaires sont précédés par #
# '#'. # ';' ou '#'. #
# # #
# Options are not case sensitive and # Les options ne sont pas sensibles à #
# spaces are ignored. # la casse et les espaces sont ignorés.#
# # #
# You must not change the order of # Vous ne devez pas changer l'ordre #
# the sections and their options. # des sections et de leurs options. #
# You must not delete or put into # Vous ne devez pas effacer ou mettre #
# comment any section nor option. # en commentaire une section ou option.#
# # #
# Each option is preceded by a # Chaque option est précédée par un #
# comment which explains its meaning. # commentaire qui explique sa fonction.#
# # #
##############################################################################
[MOUSE] # [SOURIS]
; The sensitivity of the mouse can | La sensibilité de la souris peut
; take values from 1 to 4. The | prendre des valeurs de 1 à 4. Plus
; smaller values, the faster. | les valeurs sont petites, plus c'est
; This only takes effect in | rapide. Ce paramétrage n'est utilisé
; fullscreen modes. | que dans les modes "plein écran".
; |
X_sensitivity = 1 ; (default 1)
Y_sensitivity = 1 ; (default 1)
; Unused setting, only kept for compatibility.
X_correction_factor = 0 ; (default 0)
Y_correction_factor = 0 ; (default 0)
; Aspect of the main cursor (cross) | Aspect du curseur principal (croix)
; 1: Solid | 1: Solide
; 2: Transparent | 2: Transparent
; 3: Thin (solid) | 3: Fin (solide)
Cursor_aspect = 1 ; (default 1)
[MENU] # [MENU]
; Colors of the menus (the black | Couleurs des menus (la couleur noire
; and the white colors cannot be | et la couleur blanche ne peuvent pas
; modified). | être modifiées).
; Values are in {Red,Green,Blue} | Les valeurs sont dans l'ordre {Rouge,
; order and are between 0 and 63. | Vert,Bleu} et vont de 0 à 63.
Light_color = 42,42,42 ; (default 42,42,42)
Dark_color = 27,27,27 ; (default 27,27,27)
;
; Light_color = 24,25,30 ; \_ Nightmare
; Dark_color = 13,14,19 ; /
;
; Light_color = 10,45,28 ; \_ Forest
; Dark_color = 5,27,12 ; /
;
; Light_color = 48,41,26 ; \_ Gold
; Dark_color = 26,22,15 ; /
;
; Light_color = 10,40,55 ; \_ Oceanic
; Dark_color = 10,20,32 ; /
; Aspect ratio and size of the | Proportion des menus et de la barre
; menus and the tool-bar. | d'outils.
; Possible values: | Valeurs possibles:
; 0: Do not adapt (pixels are not | 0: Ne pas adapter (les pixels ne sont
; stretched) | pas étirés)
; 1: Adapt the menus and the tool- | 1: Adapter les menus et la barre
; bar according to the resolution| d'outils suivant la résolution
; 2: Slightly adapt the ratio of | 2: Adapter légèrement les proportions
; the menus and tool-bar | des menus et de la barre d'outils
; -1:Do not adapt (like 0) | -1:Ne pas adapter (comme 0)
; -2:Stretch by x2 maximum | -2:Etire au double de taille si possible
; -3:Stretch by x3 maximum | -3:Etire au triple de taille si possible
; -4:Stretch by x4 maximum | -3:Etire au quadruple de taille si
; | possible.
Menu_ratio = -2 ; (default -2)
[FILE_SELECTOR] # [SELECTEUR_DE_FICHIERS]
; Show hidden files and | Afficher les fichiers et répertoires
; directories (values are 'yes' or | cachés (les valeurs sont 'yes' ou
; 'no'). | 'no').
Show_hidden_files = no ; (default 'no')
Show_hidden_directories = no ; (default 'no')
; Delay before displaying a preview | Délai avant d'afficher une preview
; in file-selectors (in 18.2th of | dans les sélecteurs de fichiers (en
; second). Possible values range | 18.2èmes de seconde) Les valeurs
; from 1 to 256. | possibles vont de 1 à 256.
Preview_delay = 8 ; (default 8)
; Maximize the preview of the | Maximiser la preview des images pour
; pictures so that it is as big as | qu'elle soit aussi grande que
; possible. If you're not in the | possible.
; same resolution as the picture's | Si vous n'êtes pas dans la même réso-
; one, it can try to correct the | lution que celle de l'image, cela peut
; aspect ratio, but if the picture | essayer de corriger les proportions,
; does not fill the whole screen, | mais si l'image ne prend pas tout
; it can be worse. | l'écran, cela peut être pire.
Maximize_preview = no ; (default 'no')
; This option is used to place the | Cette option est utilisée pour placer
; selection bar on a filename by | la barre de sélection sur un nom de
; typing its first letters. | fichier en tapant ses 1ères lettres.
; For example, if you want to find | Par exemple, si vous voulez trouver le
; the "PICTURE.PKM" in a directory | fichier "PICTURE.PKM" dans un réper-
; that also contains "PALETTE.PAL", | toire contenant également le fichier
; you'll just have to type P and I. | "PALETTE.PAL", vous n'aurez qu'à taper
; The different values of "FFF" | P puis I.
; indicate if you want to find the | Les different valeurs de "FFF"
; name in both files and directories| indiquent si vous voulez trouvez le nom
; or just in only one of these: | dans les fichiers ET les répertoires ou
; 0: files and directories | simplement dans l'un OU l'autre.
; 1: files only | 0: fichiers et répertoires
; 2: directories only | 1: fichiers seulement
; | 2: répertoires seulement
Find_file_fast = 0 ; (default 0)
[LOADING] # [CHARGEMENT]
; Automatically set the resolution | Passer automatiquement dans la bonne
; when loading a picture. | résolution lors du chargement d'une
; You should set this value to | image.
; 'yes' after disabling the video | Vous devriez définir cette option à
; modes that are not supported by | 'yes' après avoir inhibé les modes
; your video card or monitor. | vidéo qui ne sont pas supportés par
; | votre matériel.
Auto_set_resolution = no ; (default 'no')
; If the variable above is set to | Si la variable ci-dessus est à 'yes',
; 'yes', this one tells if you want | celle-ci indique si vous voulez
; to set the resolution according | définir la résolution suivant:
; to: | 1: les dimensions de "l'écran
; 1: the internal "original screen" | d'origine" internes à l'image
; dimensions of the picture | 2: les véritables dimensions de
; 2: the actual dimensions of the | l'image
; picture |
Set_resolution_according_to = 1 ; (default 1)
; If you load a picture with a | Si vous chargez une image ayant une
; palette of less than 256 colors, | palette de moins de 256 couleurs,
; this option defines if you want | cette option indique si vous souhaitez
; to clear the palette or to keep | effacer la palette ou bien conserver
; the colors of the previous | les couleurs de l'image précédente qui
; picture that are over the number | se situent au-delà du nombre de la
; of colors of the new picture. | nouvelle image.
; For example, if you load a | Par exemple, si vous chargez une image
; 32-color picture, the colors 32 | de 32 couleurs, les couleurs 32 à 255
; to 255 will be set to black if | seront passées en noir si cette option
; this option is set to 'yes', or | est à 'yes', ou bien elles resteront
; they will be kept unchanged if | inchangées si elle est à 'no'.
; this option is set to 'no'. |
Clear_palette = yes ; (default 'yes')
[MISCELLANEOUS] # [DIVERS]
; Draw the limits of the picture. | Afficher les limites de l'image
Draw_limits = yes ; (default 'yes')
; Adjust the brush grabbing in | Ajuster la capture de brosse en mode
; "grid" mode. | "grille".
Adjust_brush_pick = yes ; (default 'yes')
; Coordinates: | Coordonnées:
; 1: Relative | 1: Relatives
; 2: Absolute | 2: Absolues
Coordinates = 1 ; (default 1)
; Create a backup file when saving. | Créer un fichier backup lors des
; | sauvegardes.
Backup = no ; (default 'no')
; Number of pages stored in memory | Nombre de pages stockées en mémoire
; for "undoing". | destinées à annuler les dernières
; Values are between 1 and 99. | modifications. Valeurs entre 1 et 99.
Undo_pages = 10 ; (default 10)
; Speed of the scroll-bars (in VBLs | Vitesse des barre de défilement (en
; waited) while clicking with the | VBLs attendus) lorsque l'un des
; left or right button of the mouse.| boutons de la souris est enfoncé.
; Values can be between 1 and 255. | Les valeurs sont comprises entre 1 et
; The bigger values, the slower. | 255. Plus elles sont grandes, plus
; | c'est lent.
Gauges_scrolling_speed_Left = 10 ; (default 10)
Gauges_scrolling_speed_Right = 3 ; (default 3)
; Automatically save the configu- | Enregistre automatiquement la configu-
; ration when exiting the program. | ration lorsqu'on quitte le programme.
Auto_save = yes ; (default 'yes')
; Maximum number of vertices used | Nombre maximum de vertex utilisés dans
; in filled polygons and polyforms, | les polygônes et polyformes pleins, et
; and lasso. Possible values range | le lasso. Les valeurs possibles vont
; from 2 to 16384. | de 2 à 16384.
; Each vertex takes 4 bytes. | Chaque vertex prend 4 octets.
Vertices_per_polygon = 1024 ; (default 1024)
; Automatically zoom into the | Zoomer automatiquement la zone pointée
; pointed area when you press the | par la souris lorsque vous appuyez sur
; short-key of the Magnifier button | la touche de raccourci de la loupe.
; while being above the picture. |
Fast_zoom = yes ; (default 'yes')
; Separate the colors in the tool- | Séparer les couleurs dans la barre
; bar by a black squaring. | d'outils par un quadrillage noir.
Separate_colors = no ; (default 'no')
; Initial value of the feedback for | Valeur initiale du "feedback" pour les
; the drawing modes (cf. docs). | modes de dessin (cf. docs).
FX_feedback = yes ; (default 'yes')
; When you reduce the palette or | Si vous réduisez la palette ou "zappez"
; "zap" some colors out of it, it is| quelques couleurs, il est possible
; possible that there are not enough| qu'il ne reste pas assez de couleurs
; colors left to draw the menus. | pour afficher les menus. Mettre cette
; Switching the following variable | variable à 'yes' ramènera automatiquent
; on will bring back the colors of | les couleurs du menu s'il reste moins
; the menu if there are less than 4 | de 4 couleurs après une "réduction" ou
; colors left after "reducing" or | un "zapping".
; "zapping". |
Safety_colors = yes ; (default 'yes')
; Display a message at startup | Afficher un message au démarrage
; telling the version number of the | indiquant le numéro de version du
; program. | programme.
Opening_message = yes ; (default 'yes')
; Take the Stencil into account when| Prendre le Stencil en compte lorsqu'on
; clearing the image. | efface l'image.
Clear_with_stencil = yes ; (default 'yes')
; Directly set the discontinuous | Passer automatiquement en mode de
; freehand drawing mode after brush | dessin discontinu après la prise d'une
; grabbing. | brosse.
Auto_discontinuous = no ; (default 'no')
; Save the screen dimensions in GIF | Sauver les dimensions de l'écran dans
; files. If you want to read these | les fichiers GIF. Si vous voulez lire
; files with Photoshop or Alchemy, | ces fichiers avec Photoshop ou Alchemy,
; and maybe some other programs, you| et peut-être d'autres programmes, vous
; must set this option to 'no'. | devez mettre cette option à 'no'.
Save_screen_size_in_GIF = no ; (default 'no')
; Automaticaly count the number of | Compter automatiquement le nombre de
; different colors used when opening| couleurs différentes utilisées lors de
; the palette editor window. (Set it| d'ouverture de la fenêtre d'édition de
; to 'no' if you have a slow PC or | la palette. (Mettez-le à 'no' si vous
; if you edit huge pictures) | avez un PC lent ou bien si vous éditez
; | d'énormes images).
Auto_nb_colors_used = yes ; (default 'yes')
; Default video mode at startup | Mode vidéo par défaut au
; (see the list by running the | démarrage (voir la liste en lançant
; program with argument "/?". | le programme avec l'option "/?".
Default_video_mode = window ; (default 'window')
; Window dimensions. The program | Dimensions de la fenêtre en mode
; remembers the last window size. | fenêtré.
Default_window_size = 640,480 ; (default '640,480')
; This setting allows you merge successive mouse movements into a single
; mouse movement. You should only use it if you are using a mouse which
; reports at 200Hz or more, and you experience lag when using discontinuous
; hand-drawing with large brushes (this tool tries to paste the brush and
; update the screen on each new mouse position) In this case, set this to 2
; or more, to ignore some intermediate mouse reports when a more recent one
; is present.
; Note that with a value superior to 1, you lose precision with continuous
; hand-drawing, as intermediate mouse positions are skipped.
Merge_movement = 0 ; (default 0)
; Number of columns in the palette of the menu bar. Can be any number from
; 1 to 256. If there is not enough room, the program will display less
; columns. But your preference will be kept, and as soon as there is more
; space in the screen, more columns will be shown.
;
Palette_Cells_X = 8; (Default 8)
; Number of lines in the palette of the menu. Can be any number from
; 1 to 16. The menu can always display the number of lines you request.
;
Palette_Cells_Y = 8; (Default 8)
; Bookmarked directories. Leave the directory blank for unused ones.
;
Bookmark_label =
Bookmark_directory =
Bookmark_label =
Bookmark_directory =
Bookmark_label =
Bookmark_directory =
Bookmark_label =
Bookmark_directory =
; In the classic layout, the palette in the menu has colors from left to
; right. If you prefer the colors ordered top to bottom, set this option
; to YES.
;
Palette_vertical = NO; (Default NO)
; The program remembers the last window position, if the
; OS isn't able to do it by itself. (ie: Windows)
Window_position = 9999,9999; (Default 9999,9999 which means: NA)
; This is the time (in milliseconds) between two clicks for Grafx2 to
; recognize a double-click. Double-click is used mostly in the palette
; area of the menu: double-click a color to open the palette.
Double_click_speed = 500; (Default 500)
; When you press two digit keys in rapid succession (ex: 3 8), Grafx2
; sets transparency to 38% (instead of 30% then 80%). This setting
; allows you to set the maximum delay between two keypresses for
; GrafX2 to recognize them as a combo.
Double_key_speed = 500; (Default 500)
; Name of the skinfile you want to | Nom du fichier skin que vous voulez
; use. | utiliser.
; Default : (empty to let the program choose)
Skin_file =
; Name of the font file (8x8) you | Nom du fichier police de caractère
; want to use. | 8x8 utilisée dans les menus.
; Default : (empty to let the program choose)
Font_file =
; This determines the color value for the grid. Each pixel of
; the grid will be displayed by XOR-ing the original color with
; the value of this setting.
; For example, if you always paint 16-color images, you can set it
; to 16 so the color of the grid are 16 for 0, 17 for 1, etc.
; Then you can set colors 16-31 as lighter/darker variants
; of your original palette, resulting in a pretty grid !
;
; Valid values are 1 to 255.
Grid_XOR_color = 255; (Default 255)
; This records the last pixel ratio used, to restore it on start.
; Valid values are from 0 to 7 for: Simple, Wide, Tall, Double,
; Triple, Wide2, Tall2, Quadruple.
;
Pixel_ratio = 0; (Default 0)
; This records the visibility of toolbars, to restore them on start.
; It's a bitfield, where 1=Status, 2=Layers, 4=Tools
;
Menubars_visible = 255; (Default 255)
; end of configuration

View File

@@ -0,0 +1,30 @@
-- Apply a kind of AA filter on picture
-- Get the picture size
w, h = getpicturesize();
-- Here is the filtering matrix
matrix = {
{ 0, -1, 0 },
{ -1, 5, -1 },
{ 0, -1, 0 }};
-- Loop trough all the pixels
-- To make this script simpler we don't handle the picture borders
-- (the matrix would get pixels outside the picture space)
-- for var = start_value, end_value, step do ...
for y = 1, h - 2, 1 do
for x = 1, w - 2, 1 do
filtered =
matrix[1][1] * getbackuppixel(x - 1, y - 1) +
matrix[1][2] * getbackuppixel(x , y - 1) +
matrix[1][3] * getbackuppixel(x + 1, y - 1) +
matrix[2][1] * getbackuppixel(x - 1, y ) +
matrix[2][2] * getbackuppixel(x , y ) +
matrix[2][3] * getbackuppixel(x + 1, y ) +
matrix[3][1] * getbackuppixel(x - 1, y + 1) +
matrix[3][2] * getbackuppixel(x , y + 1) +
matrix[3][3] * getbackuppixel(x + 1, y + 1);
putpicturepixel(x,y,filtered);
end
end

View File

@@ -0,0 +1,7 @@
w, h = getbrushsize()
for x = 0, w - 1, 1 do
for y = 0, h - 1, 1 do
putbrushpixel(x, y, (x+y)%256);
end
end

View File

@@ -0,0 +1,31 @@
-- Test LUA inputbox
-- this script only resizes the brush
w, h = getbrushsize()
--[[
messagebox(
"Forecolor: " .. getforecolor() .. "\n" ..
"Backcolor: " .. getbackcolor() .. "\n" ..
"Transparent color: " .. gettranscolor() .. "\n" ..
"Brush dimensions: " .. w .. "x" .. h
)
]]
ok, w, h = inputbox("Modify brush",
"Width", w, -900.0,900.0, 3,
"Height", h, -900.0,900.0, 4,
"X Flip", 0, 0, 1, 0,
"Y Flip", 0, 0, 1, 0
);
if ok == true then
setbrushsize(w,h)
for y = 0, h-1, 1 do
for x = 0, w-1, 1 do
putbrushpixel(x,y,1);
end
end
end

View File

@@ -0,0 +1,42 @@
--BRUSH Scene: Amigaball 1.0
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
w, h = getbrushsize()
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
-- Fractionalize image dimensions
ox = x / w;
oy = y / h;
-- Ball
Xr = ox-0.5; Yr = oy-0.5;
W = (1 - 2*math.sqrt(Xr*Xr + Yr*Yr));
-- 'FishEye' distortion / Fake 3D
F = (math.cos((ox-0.5)*math.pi)*math.cos((oy-0.5)*math.pi))*0.65;
ox = ox - (ox-0.5)*F;
oy = oy - (oy-0.5)*F;
-- Checkers
V = ((math.floor(0.25+ox*10)+math.floor(1+oy*10)) % 2) * 255 * W;
-- Specularities
SPEC1 = math.max(0,(1-5*math.sqrt((ox-0.45)*(ox-0.45)+(oy-0.45)*(oy-0.45)))*112);
SPEC2 = math.max(0,(1-15*math.sqrt((ox-0.49)*(ox-0.49)+(oy-0.48)*(oy-0.48)))*255);
r = W * 255 + SPEC1 + SPEC2
g = V + SPEC1 + SPEC2
b = V + SPEC1 + SPEC2
putbrushpixel(x, y, matchcolor(r,g,b));
end
end

View File

@@ -0,0 +1,31 @@
--BRUSH Scene: Sphere of pencolor v1.0
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
w, h = getbrushsize()
rp,gp,bp = getcolor(getforecolor())
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
-- Fractionalize image dimensions
ox = x / w;
oy = y / h;
-- Sphere
X = 0.5; Y = 0.5; Rd = 0.5
a = math.sqrt(math.max(0,Rd*Rd - ((X-ox)*(X-ox)+(Y-oy)*(Y-oy)))) * 1/Rd
r = rp * a
g = gp * a
b = bp * a
putbrushpixel(x, y, matchcolor(r,g,b));
end
end

View File

@@ -0,0 +1,94 @@
--BRUSH: Find AA-colors from pencolors
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
cellw = 8
cellh = 4
colors = 256
setbrushsize(cellw * 3, cellh * 3)
--
function makePalList(cols)
pal = {}
for n = 0, cols-1, 1 do
r,g,b = getcolor(n)
pal[n+1] = {r,g,b}
end
return pal
end
--
--
function getBestPalMatchHYBRID(rgb,pal,briweight)
local diff,diffC,diffB,best,bestcol,cols,n,c,r,g,b,p,obri,pbri
cols = #pal
bestcol = 0
best = 9e99
r = rgb[1]
g = rgb[2]
b = rgb[3]
obri = math.pow(r*9,2)+math.pow(g*16,2)+math.pow(b*8,2)
for n=0, cols-1, 1 do
p = pal[n+1]
pbri = math.pow(p[1]*9,2)+math.pow(p[2]*16,2)+math.pow(p[3]*8,2)
diffB = math.abs(obri - pbri)
diffC = (math.pow(r-p[1],2)+math.pow(g-p[2],2)+math.pow(b-p[3],2)) * 400
--diff = diffB + diffC
diff = briweight * (diffB - diffC) + diffC
if diff <= best then bestcol = n; best = diff; end
end
return bestcol
end
--
--
function drawRectangle(x1,y1,w,h,c)
for y = y1, y1+h, 1 do
for x = x1, x1+w, 1 do
putbrushpixel(x,y,c);
end
end
end
--
palList = makePalList(colors)
cf = getforecolor()
cb = getbackcolor()
rf,gf,bf = getcolor(cf)
rb,gb,bb = getcolor(cb)
ra = (rf + rb) / 2
ga = (gf + gb) / 2
ba = (bf + bb) / 2
rgb1 = {ra,ga,ba}
c1 = getBestPalMatchHYBRID(rgb1,palList,0.0)
c2 = getBestPalMatchHYBRID(rgb1,palList,0.75)
c3 = getBestPalMatchHYBRID(rgb1,palList,0.99)
q = {{cf,c1,cb},
{cf,c2,cb},
{cf,c3,cb}}
for y = 0, #q-1, 1 do
for x = 0, #q[1]-1, 1 do
drawRectangle(x*cellw,y*cellh,cellw,cellh,q[y+1][x+1])
end
end

View File

@@ -0,0 +1,24 @@
--BRUSH Distortion: FishEye
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
w, h = getbrushsize()
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
ox = x / w;
oy = y / h;
v = (math.cos((ox-0.5)*math.pi)*math.cos((oy-0.5)*math.pi))*0.85;
ox = (1 + ox - (ox-0.5)*v) % 1;
oy = (1 + oy - (oy-0.5)*v) % 1;
c = getbrushbackuppixel(math.floor(ox*w),math.floor(oy*h));
putbrushpixel(x, y, c);
end
end

View File

@@ -0,0 +1,18 @@
--BRUSH Remap: Grayscale (average)
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
w, h = getbrushsize()
for x = 0, w - 1, 1 do
for y = 0, h - 1, 1 do
r, g, b = getcolor(getbrushpixel(x,y))
a = (r+g+b)/3
putbrushpixel(x, y, matchcolor(a,a,a));
end
end

View File

@@ -0,0 +1,29 @@
--BRUSH Remap: Grayscale (desaturate)
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
percent = 100
--
function desaturate(percent,r,g,b) -- V1.0 by Richard Fhager
p = percent / 100
a = (math.min(math.max(r,g,b),255) + math.max(math.min(r,g,b),0)) * 0.5 * p
r = math.min(math.max(r + (a-r*p),0),255) -- Capping may not be needed if mathcolor/setcolor is updated
g = math.min(math.max(g + (a-g*p),0),255)
b = math.min(math.max(b + (a-b*p),0),255)
return r,g,b
end
--
w, h = getbrushsize()
for x = 0, w - 1, 1 do
for y = 0, h - 1, 1 do
putbrushpixel(x, y, matchcolor(desaturate(percent,getcolor(getbrushpixel(x,y)))));
end
end

View File

@@ -0,0 +1,28 @@
--BRUSH: Halfsize with smoothscaling
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
w, h = getbrushsize()
setbrushsize(math.floor(w/2),math.floor(h/2))
for x = 0, w - 1, 2 do
for y = 0, h - 1, 2 do
r1,g1,b1 = getcolor(getbrushbackuppixel(x,y));
r2,g2,b2 = getcolor(getbrushbackuppixel(x+1,y));
r3,g3,b3 = getcolor(getbrushbackuppixel(x,y+1));
r4,g4,b4 = getcolor(getbrushbackuppixel(x+1,y+1));
r = (r1 + r2 + r3 + r4 ) / 4;
g = (g1 + g2 + g3 + g4 ) / 4;
b = (b1 + b2 + b3 + b4 ) / 4;
c = matchcolor(r,g,b);
putbrushpixel(x/2, y/2, c);
end
end

View File

@@ -0,0 +1,54 @@
--BRUSH Scene: Mandelbrot fractal v0.5
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
colors = 64
x0 = -1.7
x1 = 0.7
ym = 0
iter = 64
ok, x0, x1, ym, iter = inputbox("Fractal data",
"X0", x0, -2, 2,4,
"X1", x1, -2, 2,4,
"midY", ym, -2, 2,4,
"Iter", iter, 1, 2048,0
);
-- -0.831116819,-0.831116815,0.2292112435,192
function mandel(x,y,l,r,o,i) -- pos. as fraction of 1, left coord, right coord, y coord, iterations
local w,s,a,p,q,n,v,w
s=math.abs(r-l);
a = l + s*x;
p = a;
b = o - s*(y-0.5);
q = b;
n = 1;
v = 0;
w = 0;
while (v+w<4 and n<i) do n=n+1; v=p*p; w=q*q; q=2*p*q+b; p=v-w+a; end;
return n
end
w, h = getbrushsize()
for x = 0, w - 1, 1 do
for y = 0, h - 1, 1 do
q = mandel(x/w,y/h,x0,x1,ym,iter) % colors;
putbrushpixel(x, y, q);
end
end

View File

@@ -0,0 +1,35 @@
--BRUSH Distortion: Waves v1.0
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
--frq = 2
--amp = 0.3
-- Adjust power of frequency & amplitude
frq_adj = 2
amp_adj = 0.02
ok,frq,amp = inputbox("Settings",
"Frequency 1-10", 3, 1,10,0,
"Amplitude 1-10", 3, 1,10,0
);
w, h = getbrushsize()
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
ox = x / w;
oy = y / h;
ox = (1 + ox + math.sin(oy*math.pi*frq*frq_adj)*amp*amp_adj) % 1;
c = getbrushbackuppixel(math.floor(ox*w),y);
putbrushpixel(x, y, c);
end
end

View File

@@ -0,0 +1,33 @@
--PALETTE Adjust: Desaturate v1.1
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
-- Note: Negative values will work as INCREASED saturation, but I'm not sure if this function is 100% correct
--percent = 25
OK,percent = inputbox("Desaturate Palette","Percent %", 25, 0,100,0);
--
function desaturate(percent,r,g,b) -- V1.0 by Richard Fhager
p = percent / 100
a = (math.min(math.max(r,g,b),255) + math.max(math.min(r,g,b),0)) * 0.5 * p
r = r + (a-r*p)
g = g + (a-g*p)
b = b + (a-b*p)
return r,g,b
end
--
if OK == true then
for c = 0, 255, 1 do
setcolor(c, desaturate(percent,getcolor(c)))
end
end

View File

@@ -0,0 +1,164 @@
--PALETTE: Expand Colors v1.0
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- Email: dawnbringer@hem.utfors.se
-- MSN: annassar@hotmail.com
--
--
-- Continously fill the greatest void in the area of the color-cube enclosed by (or along ramps of) initial colors
-- This algorithm will create lines of allowed colors (all ranges) in 3d colorspace and the pick
-- new colors from the most void areas (on any line). Almost like a Median-cut in reverse.
--
-- Rather than filling the colorcube symmetrically it adds intermediate colors to the existing ones.
--
-- Running this script on the C64 16-color palette might be educational
--
--
-- Source cols#, Expand to #,
-- Ex: 15-31 means that palette colors 0-15 is expanded to 16 new colors placed at slots 16-31
--
-- Spread mode: OFF - New colors will conform to the contrast & saturation of original colors
-- (new colors will stay on the ramps possible from the original colors)
--
-- ON - New colors will expand their variance by each new addition (mostly notable when adding many new colors)
-- Will add range lines/ramps to all new colors from old ones, but keep within max/min values of the
-- original colors. 15-bit mode will dampen the spread towards extreme colors (if starting with low contrast)
--
-- 15-bit colors: Higher color-resolution, 32768 possible colors rather than the 4096 of 12bit. Slower but perhaps better.
--
SHADES = 16 -- Going 24bit will probably be too slow and steal too much memory, so start with 12bit (4096 colors) for now
ini = 0
exp = 255
OK,ini,exp,linemode,fbit = inputbox("Expand Colors (0-255):",
"Source Cols #: 1-254", 15, 1,254,0,
"Expand to #: 2-255", 31, 2,255,0,
"Spread mode", 0, 0,1,0,
"15-bit colors (slow)", 0, 0,1,0
);
if (fbit == 1) then SHADES = 32; end
function initColorCube(sha)
ary = {}
for z = 0, sha-1, 1 do
ary[z+1] = {}
for y = 0, sha-1, 1 do
ary[z+1][y+1] = {}
for x = 0, sha-1, 1 do
ary[z+1][y+1][x+1] = {false,0}
end
end
end
return ary
end
-- Gravity model (think of colors as stars of equal mass/brightness in a 3d space)
function addColor2Cube(cube,sha,r,g,b)
star = 1000000
fade = 1000
cube[r+1][g+1][b+1] = {false,star}
for z = 0, sha-1, 1 do
for y = 0, sha-1, 1 do
for x = 0, sha-1, 1 do
d = fade / ( (x-b)^2 + (y-g)^2 + (z-r)^2 )
cube[z+1][y+1][x+1][2] = cube[z+1][y+1][x+1][2] + d
end;end;end
end
-- Create new allowed colorlines in colorspace (ramps from which colors can be picked)
function enableRangeColorsInCube(cube,sha,r1,g1,b1,r2,g2,b2)
local div,r,g,b
div = 256 / sha
rs = (r2 - r1) / sha / div
gs = (g2 - g1) / sha / div
bs = (b2 - b1) / sha / div
for n = 0, sha-1, 1 do
r = math.floor(r1/div + rs * n)
g = math.floor(g1/div + gs * n)
b = math.floor(b1/div + bs * n)
cube[r+1][g+1][b+1][1] = true
end
end
function findVoid(cube,sha)
weakest = 999999999999
weak_i = {-1,-1,-1}
for z = 0, sha-1, 1 do
for y = 0, sha-1, 1 do
for x = 0, sha-1, 1 do
c = cube[z+1][y+1][x+1]
if c[1] == true then
w = c[2]
if w <= weakest then weakest = w; weak_i = {z,y,x}; end
end
end;end;end
return weak_i[1],weak_i[2],weak_i[3]
end
--
if OK == true then
cube = initColorCube(SHADES)
-- Define allowed colorspace
for y = 0, ini-1, 1 do
r1,g1,b1 = getcolor(y)
for x = y+1, ini, 1 do
r2,g2,b2 = getcolor(x)
enableRangeColorsInCube(cube,SHADES,r1,g1,b1,r2,g2,b2)
end
end
div = 256 / SHADES
-- Fill cube with initial colors
for n = 0, ini, 1 do
r,g,b = getcolor(n)
addColor2Cube(cube,SHADES,math.floor(r/div),math.floor(g/div),math.floor(b/div))
end
for n = ini+1, exp, 1 do
r,g,b = findVoid(cube,SHADES)
if (r == -1) then messagebox("Report:","No more colors can be found, exit at "..n); break; end
mult = 255 / (SHADES - 1)
setcolor(n, r*mult,g*mult,b*mult)
if linemode == 1 then
-- Add lines from new color to all old
for x = 0, n-1, 1 do
r2,g2,b2 = getcolor(x)
enableRangeColorsInCube(cube,SHADES,r*mult,g*mult,b*mult,r2,g2,b2) -- uses 24bit values rgb
end
end
addColor2Cube(cube,SHADES,r,g,b) -- rgb is in 'shade' format here
end
end

View File

@@ -0,0 +1,98 @@
--PALETTE: Fill ColorCube voids v1.0
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- Email: dawnbringer@hem.utfors.se
-- MSN: annassar@hotmail.com
--
--
-- Create a palette by continously filling the greatest void in the RGB color-cube
--
SHADES = 16 -- Going 24bit will probably be too slow and steal too much memory, so we're 12bit (4096 colors) for now
ini = 0
exp = 255
OK,ini,exp = inputbox("Fill Palette Color voids",
"From/Keep #: 0-254", 0, 0,254,0,
"Replace to #: 1-255", 31, 1,255,0
);
function initColorCube(sha)
ary = {}
for z = 0, sha-1, 1 do
ary[z+1] = {}
for y = 0, sha-1, 1 do
ary[z+1][y+1] = {}
end
end
return ary
end
function addColor2Cube(cube,sha,r,g,b) -- Gravity model
star = 1000000
fade = 1000
cube[r+1][g+1][b+1] = star
for z = 0, sha-1, 1 do
for y = 0, sha-1, 1 do
for x = 0, sha-1, 1 do
d = fade / ( (x-b)^2 + (y-g)^2 + (z-r)^2 )
if cube[z+1][y+1][x+1] ~= nil then
cube[z+1][y+1][x+1] = cube[z+1][y+1][x+1] + d
else
cube[z+1][y+1][x+1] = d
end
end;end;end
end
function findVoid(cube,sha)
weakest = 999999999999
weak_i = {-1,-1,-1}
for z = 0, sha-1, 1 do
for y = 0, sha-1, 1 do
for x = 0, sha-1, 1 do
w = cube[z+1][y+1][x+1]
if w <= weakest then weakest = w; weak_i = {z,y,x}; end
end;end;end
return weak_i[1],weak_i[2],weak_i[3]
end
--
if OK == true then
cube = initColorCube(SHADES)
-- Fill cube with initial colors
for n = 0, ini-1, 1 do
r,g,b = getcolor(n)
div = SHADES
addColor2Cube(cube,SHADES,math.floor(r/div),math.floor(g/div),math.floor(b/div))
end
if ini == 0 then -- With no inital color, some inital data must be added to the colorcube.
addColor2Cube(cube,SHADES,0,0,0)
setcolor(0, 0,0,0)
ini = ini + 1
end
for n = ini, exp, 1 do
r,g,b = findVoid(cube,SHADES)
mult = 255 / (SHADES - 1)
setcolor(n, r*mult,g*mult,b*mult)
addColor2Cube(cube,SHADES,r,g,b)
end
end

View File

@@ -0,0 +1,20 @@
--PALETTE Modify: Inverted RGB
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
for c = 0, 255, 1 do
r,g,b = getcolor(c)
r2 = (g+b)/2
g2 = (r+b)/2
b2 = (r+g)/2
setcolor(c, r2,g2,b2)
end

View File

@@ -0,0 +1,32 @@
--PALETTE Set: 3 Bit (8 Primaries)
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- Generate palette of all colors possible with a given number of shades for each channel
-- 2 shades = 1 bit / channel = 3 bit palette = 2^3 colors = 8 colors
-- 4 shades = 2 bit / channel = 6 bit palette = 2^6 colors = 64 colors
-- Channel shades (shades = 2 ^ bit-depth)
shades = 2
mult = 255 / (shades-1)
colors = {}
col = 0
for r = 0, shades-1, 1 do
for g = 0, shades-1, 1 do
for b = 0, shades-1, 1 do
col = col + 1
colors[col] = { r*mult, g*mult, b*mult }
end
end
end
for c = 1, #colors, 1 do
setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
end

View File

@@ -0,0 +1,32 @@
--PALETTE Set: Full 6 Bit (64 colors)
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- Generate palette of all colors possible with a given number of shades for each channel
-- 2 shades = 1 bit / channel = 3 bit palette = 2^3 colors = 8 colors
-- 4 shades = 2 bit / channel = 6 bit palette = 2^6 colors = 64 colors
-- Channel shades (shades = 2 ^ bit-depth)
shades = 4
mult = 255 / (shades-1)
colors = {}
col = 0
for r = 0, shades-1, 1 do
for g = 0, shades-1, 1 do
for b = 0, shades-1, 1 do
col = col + 1
colors[col] = { r*mult, g*mult, b*mult }
end
end
end
for c = 1, #colors, 1 do
setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
end

View File

@@ -0,0 +1,43 @@
--PALETTE Set: C64 Palette (16 colors)
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
OK,clean = inputbox("C64 Palette:", "Remove old palette", 0, 0,1,0
);
colors = {{0, 0, 0}, -- 0 Black
{62, 49,162}, -- 1 D.Blue
{87, 66, 0}, -- 2 Brown
{140, 62, 52}, -- 3 D.Red
{84, 84, 84}, -- 4 D.Grey
{141, 72,179}, -- 5 Purple
{144, 95, 37}, -- 6 Orange
{124,112,218}, -- 7 B.Blue
{128,128,128}, -- 8 Grey
{104,169, 65}, -- 9 Green
{187,119,109}, -- 10 B.Red
{122,191,199}, -- 11 Cyan
{171,171,171}, -- 12 B.Grey
{208,220,113}, -- 13 Yellow
{172,234,136}, -- 14 B.Green
{255,255,255} -- 15 White
}
if OK == true then
for c = 1, #colors, 1 do
setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
end
if clean == 1 then
for c = #colors+1, 255, 1 do
setcolor(c-1,0,0,0)
end
end
end

View File

@@ -0,0 +1,55 @@
--PALETTE Adjust: Shift Hue v0.9
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
--Shift_degrees = 45
--ok, w, h, xflip, yflip = inputbox("Modify brush",
-- "Width", w, 1,100,0,
-- "Height", h, 1,100,0,
-- "X-Flip", 0, 0, 1,0,
-- "Y-Flip", 0, 0, 1,0
--);
OK,Shift_degrees = inputbox("Shift Hue v0.9","Degrees", 45, 0,360,3);
--
function shiftHUE(r,g,b,deg) -- V1.3 R.Fhager 2007, adopted from Evalion
local c,h,mi,mx,d,s,p,i,f,q,t
c = {g,b,r}
mi = math.min(r,g,b)
mx = math.max(r,g,b); v = mx;
d = mx - mi;
s = 0; if mx ~= 0 then s = d/mx; end
p = 1; if g ~= mx then p = 2; if b ~= mx then p = 0; end; end
if s~=0 then
h=(deg/60+(6+p*2+(c[1+p]-c[1+(p+1)%3])/d))%6;
i=math.floor(h);
f=h-i;
p=v*(1-s);
q=v*(1-s*f);
t=v*(1-s*(1-f));
c={v,q,p,p,t,v}
r = c[1+i]
g = c[1+(i+4)%6]
b = c[1+(i+2)%6]
end
return r,g,b
end
--
if OK == true then
for c = 0, 255, 1 do
r,g,b = getcolor(c)
setcolor(c, shiftHUE(r,g,b,Shift_degrees))
end
end

View File

@@ -0,0 +1,79 @@
--PICTURE (part of): 2 Isometric v0.1b
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- Email: dawnbringer@hem.utfors.se
-- MSN: annassar@hotmail.com
--
-- Color 0 is assumed to be the background
--
iso = {{0, 0, 1, 1, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{2, 2, 1, 1, 1, 1, 3, 3},
{2, 2, 2, 2, 3, 3, 3, 3},
{2, 2, 2, 2, 3, 3, 3, 3},
{2, 2, 2, 2, 3, 3, 3, 3},
{0, 0, 2, 2, 3, 3, 0, 0}}
isowidth = 8
isoheight = 7
xoff = 0.5
yoff = 0
xstep = 4
ystep = 2
zstep = 4
-- Part of screen from top-left (4 = 1/4)
xsize = 5
ysize = 4
w, h = getpicturesize()
xo = math.floor(w * xoff)
-- just don't render more than can be fittted right now
w = math.floor(w / xsize)
h = math.floor(h / ysize)
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
isox = x * xstep - y * xstep
isoy = y * ystep + x * ystep
cb = getbackuppixel(x,y)
--
if cb ~= 0 then
r,g,b = getbackupcolor(cb);
c1 = matchcolor(r,g,b);
c2 = matchcolor(r+64, g+64, b+64);
c3 = matchcolor(r-64, g-64, b-64);
cols = {0,c1,c2,c3}
for iy = 1, isoheight, 1 do
for ix = 1, isowidth, 1 do
i = iso[iy][ix]
c = cols[i+1]
if i ~= 0 then putpicturepixel(xo + isox+ix-1, isoy+iy-1, c); end
end
end
end
--
end
end

View File

@@ -0,0 +1,61 @@
--PICTURE: Rainbow - Dark to Bright
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- Email: dawnbringer@hem.utfors.se
-- MSN: annassar@hotmail.com
--
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
--
--
function shiftHUE(r,g,b,deg) -- V1.3 R.Fhager 2007, adopted from Evalion
local c,h,mi,mx,d,s,p,i,f,q,t
c = {g,b,r}
mi = math.min(r,g,b)
mx = math.max(r,g,b); v = mx;
d = mx - mi;
s = 0; if mx ~= 0 then s = d/mx; end
p = 1; if g ~= mx then p = 2; if b ~= mx then p = 0; end; end
if s~=0 then
h=(deg/60+(6+p*2+(c[1+p]-c[1+(p+1)%3])/d))%6;
i=math.floor(h);
f=h-i;
p=v*(1-s);
q=v*(1-s*f);
t=v*(1-s*(1-f));
c={v,q,p,p,t,v}
r = c[1+i]
g = c[1+(i+4)%6]
b = c[1+(i+2)%6]
end
return r,g,b
end
--
w, h = getpicturesize()
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
-- Fractionalize image dimensions
ox = x / w;
oy = y / h;
r = 255 * math.sin(oy * 2)
g = (oy-0.5)*512 * oy
b = (oy-0.5)*512 * oy
r, g, b = shiftHUE(r,g,b,ox * 360);
c = matchcolor(math.max(0,math.min(255,r)),math.max(0,math.min(255,g)),math.max(0,math.min(255,b)))
putpicturepixel(x, y, c);
end
end

View File

@@ -0,0 +1,48 @@
--PICTURE: Pattern - Sierpinsky carpet v1.0
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- Email: dawnbringer@hem.utfors.se
-- MSN: annassar@hotmail.com
--
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
--
frac = {{1,1,1},{1,0,1},{1,1,1}}
iter = 6
--
function pattern(x,y,p,n,i) -- Fractal Pattern V1.0 by Richard Fhager (mod allows for wrapping)
py = #p
px = #p[1]
while ((p[1+math.abs(math.floor(y*py))%py][1+math.abs(math.floor(x*px))%px]) == 1 and n<i) do
x=x*px-math.floor(x*px);
y=y*py-math.floor(y*py);
n = n+1
end
return 1 - n/i;
end
--
w, h = getpicturesize()
rp,gp,bp = getcolor(getforecolor())
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
ox = x / w;
oy = y / h;
f = pattern(ox,oy,frac,0,iter);
c = matchcolor(rp*f,gp*f,bp*f)
putpicturepixel(x, y, c);
end
end

View File

@@ -0,0 +1,46 @@
--PICTURE: Pattern - Sierpinsky triangle v1.0
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- Email: dawnbringer@hem.utfors.se
-- MSN: annassar@hotmail.com
--
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
--
frac = {{1,1},{1,0}}
iter = 15
--
function pattern(x,y,p,n,i) -- Fractal Pattern V1.0 by Richard Fhager (mod allows for wrapping)
py = #p
px = #p[1]
while ((p[1+math.abs(math.floor(y*py))%py][1+math.abs(math.floor(x*px))%px]) == 1 and n<i) do
x=x*px-math.floor(x*px);
y=y*py-math.floor(y*py);
n = n+1
end
return 1 - n/i;
end
--
w, h = getpicturesize()
rp,gp,bp = getcolor(getforecolor())
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
ox = x / w;
oy = y / h;
f = pattern(ox,oy,frac,0,iter);
c = matchcolor(rp*f,gp*f,bp*f)
putpicturepixel(x, y, c);
end
end

View File

@@ -0,0 +1,10 @@
-- 12bit colour space from palette
--
w,h=getpicturesize();
for y1=0,3,1 do
for x1=0,3,1 do
for y2=0,15,1 do
for x2=0,15,1 do
putpicturepixel(x1*16+x2,y1*16+y2,matchcolor((y2*255)/15,
((y1*4+x1)*255)/15,(x2*255)/15))
end;end;end;end

View File

@@ -0,0 +1,10 @@
-- 15bit colour space from palette
--
w,h=getpicturesize();
for y1=0,3,1 do
for x1=0,7,1 do
for y2=0,31,1 do
for x2=0,31,1 do
putpicturepixel(x1*32+x2,y1*32+y2,matchcolor((y2*255)/31,
((y1*8+x1)*255)/31,(x2*255)/31))
end;end;end;end

View File

@@ -0,0 +1,10 @@
-- 18bit colour space from palette
--
w,h=getpicturesize();
for y1=0,7,1 do
for x1=0,7,1 do
for y2=0,63,1 do
for x2=0,63,1 do
putpicturepixel(x1*64+x2,y1*64+y2,matchcolor((y2*255)/64,
((y1*8+x1)*255)/64,(x2*255)/64))
end;end;end;end

View File

@@ -0,0 +1,11 @@
-- ?
w,h=getpicturesize();
for y1=0,h-1,8 do
for x1=0,w-1,8 do
for y2=0,3,1 do
for x2=0,7,1 do
c1=getpicturepixel(x1+x2,y1+y2)
c2=getpicturepixel(x1+7-x2,y1+7-y2)
putpicturepixel(x1+x2,y1+y2,c2)
putpicturepixel(x1+7-x2,y1+7-y2,c1)
end;end;end;end

View File

@@ -0,0 +1,10 @@
-- Draw 8x8 grid
w,h=getpicturesize();
for y=0,h-1,1 do
for x=0,w-1,8 do
putpicturepixel(x,y,1);
end;end
for y=0,h-1,8 do
for x=0,w-1,1 do
putpicturepixel(x,y,1);
end;end

View File

@@ -0,0 +1,11 @@
-- Draw red 8x8 grid
w,h=getpicturesize();
c=matchcolor(0xFF,0x00,0x00)
for y=0,h-1,1 do
for x=0,w-1,8 do
putpicturepixel(x,y,c);
end;end
for y=0,h-1,8 do
for x=0,w-1,1 do
putpicturepixel(x,y,c);
end;end

View File

@@ -0,0 +1,10 @@
-- Draw isometric grid
w,h=getpicturesize();
for y=0,h-1,8 do
for x=0,w-1,1 do
putpicturepixel(x,y+(x/2)%8,1);
end;end
for y=0,h-1,8 do
for x=0,w-1,1 do
putpicturepixel(x+3,y+7-((x/2)%8),1);
end;end

View File

@@ -0,0 +1,6 @@
-- x1 palette to picture
w,h=getpicturesize();
for y1=0,7,1 do
for x1=0,31,1 do
putpicturepixel(x1,y1,y1+x1*8)
end;end

View File

@@ -0,0 +1,8 @@
-- x8 palette to picture
setpicturesize(256,64);
for y1=0,7,1 do
for x1=0,31,1 do
for y2=0,7,1 do
for x2=0,7,1 do
putpicturepixel(x1*8+x2,y1*8+y2,y1+x1*8)
end;end;end;end

View File

@@ -0,0 +1,45 @@
--SCENE: Remap pic to RGB, diag.dith
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
-- Set Palette (to a predefined one)
colors = {{ 0, 0, 0},
{255, 0, 0},
{ 0,255, 0},
{ 0, 0,255}
}
chm = {1,0,0}
for c = 1, #colors, 1 do
setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
end
for c = #colors, 255, 1 do
setcolor(c,0,0,0)
end
w, h = getpicturesize()
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
r,g,b = getbackupcolor(getbackuppixel(x,y));
rn = r * chm[1+(y+0+x)%3]
gn = g * chm[1+(y+1+x)%3]
bn = b * chm[1+(y+2+x)%3]
n = matchcolor(rn,gn,bn);
putpicturepixel(x, y, n);
end
end

View File

@@ -0,0 +1,62 @@
--SCENE: Remap pic 2 RGB, 1lineED-dith. (Same line simple error-diffusion dither)
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
power = 0.615
c1 = 0.8 -- Error weight (white is green)
c2 = 0.2 -- RGB weight (white is r+g+b)
-- Set Palette (to a predefined one)
colors = {{ 0, 0, 0},
{255, 0, 0},
{ 0,255, 0},
{ 0, 0,255}
}
chm = {1,0,0}
for c = 1, #colors, 1 do
setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
end
for c = #colors, 255, 1 do
setcolor(c,0,0,0)
end
w, h = getpicturesize()
for y = 0, h - 1, 1 do
re = 0
ge = 0
be = 0
for x = (y%2), w - 1, 1 do
r,g,b = getbackupcolor(getbackuppixel(x,y));
rn = re * c1 + r * chm[1+(y+0+x)%3] * c2
gn = ge * c1 + g * chm[1+(y+1+x)%3] * c2
bn = be * c1 + b * chm[1+(y+2+x)%3] * c2
n = matchcolor(rn,gn,bn);
putpicturepixel(x, y, n);
rn,gn,bn = getcolor(getpicturepixel(x,y));
re = (re + (r - rn)) * power
ge = (ge + (g - gn)) * power
be = (be + (b - bn)) * power
end
end

View File

@@ -0,0 +1,72 @@
--SCENE: Remap pic to 3bit, LineEDdith. (Same line simple error-diffusion dither)
--by Richard Fhager
--http://hem.fyristorg.com/dawnbringer/
--
-- Just a demonstration.
--
power = 0.6
-- Channel shades (shades = 2 ^ bit-depth)
shades = 2
mult = 255 / (shades-1)
colors = {}
col = 0
for r = 0, shades-1, 1 do
for g = 0, shades-1, 1 do
for b = 0, shades-1, 1 do
col = col + 1
colors[col] = { r*mult, g*mult, b*mult }
end
end
end
for c = 1, #colors, 1 do
setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
end
for c = #colors, 255, 1 do
setcolor(c,0,0,0)
end
w, h = getpicturesize()
for y = 0, h - 1, 1 do
re = 0
ge = 0
be = 0
for x = (y%2), w - 1, 1 do
r,g,b = getbackupcolor(getbackuppixel(x,y));
rn = re + r
gn = ge + g
bn = be + b
n = matchcolor(rn,gn,bn);
putpicturepixel(x, y, n);
rn,gn,bn = getcolor(getpicturepixel(x,y));
re = (re + (r - rn)) * power
ge = (ge + (g - gn)) * power
be = (be + (b - bn)) * power
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB