 ____      __
|  __'____|  |__  florian & alain's blender
|  _|  _  |  _  | 2009 januar-november
'_' '___._'_____'

usage: fab function function_parameters

!!! Nouveau: between
!!! Donc ne pas mettre de between dans landscape, il sera rajout aprs

!!! Le emboss dans mk_Txtr2.asm=MkTxtr2G est
!!!   ldrB      r14,[r3],#1             ; r14=pixie up.
!!!   ldrB      r6,[r4],#1              ; r6=pixie down.
!!!   and       r14,r14,#&3f
!!!   and       r6,r6,#&1f
!!!   sub       r6,r6,r14,lsr #1        ; r6=delta.
!!!   addS      r6,r6,#middle           ; Add the middle constant.


list of functions
~~~~~~~~~~~~~~~~~
bmp2rgb in.bmp red.g green.g blue.g     // in.bmp peut tre 1bpp, 4bpp, 8bpp ou 24bpp
rgb2bmp red.g green.g blue.g out.bmp    // si le nb total de couleurs est <256 crer une image 8bpp ou moins
rgb2grey red.g green.g blue.g grey.g    // grey:=(red+green+blue)/3
addborders left right bottom top color in.g out.g
removeborders left right bottom top in.g out.g
negative in.g out.g     // BEWARE, pixel:=65535-pixel, maybe rsbI 255 is what you want
rotate90 in.g out.g     // anticlockwise
rotate180 in.g out.g
rotate270 in.g out.g
hmirror in.g out.g      // image upside down
vmirror in.g out.g
add in1.g in2.g out.g   // arithmetical & logical operators between two images
sub in1.g in2.g out.g
mul in1.g in2.g out.g
div in1.g in2.g out.g   // in1.g divided by in2.g*/
and in1.g in2.g out.g
or in1.g in2.g out.g
xor in1.g in2.g out.g
addI value in.g out.g   // arithmetical & logical operators between image and value
subI in.g value out.g
rsbI value in.g out.g   // rsb=reverse substract
mulI factor in.g out.g
divI in.g divisor out.g
andI value in.g out.g
orI value in.g out.g
xorI value in.g out.g

// if you set ClearColor to 0, then you'll have circles inside circles
fillwithOs OutRMin OutRMax InRMmin InRMmax Border ClearColor CircleColor in.g out.g
edge size emptycol edgecol in.g out.g         // creates an edge around non empty pixels

disc x y r color in.g out.g                   // well
rectangle top bottom left right color in.g out.g
rectangle2 top left length height color in.g out.g

explode nbpoints in.g out.g                   // moves randomly nbpoints points
pal2rgb in.pal in.g red.g green.g blue.g      // assign pixels to a color palette
setmincol mincol in.g out.g                   // if col<colmin then col=colmin
setmaxcol maxcol in.g out.g                   // if col>colmax then col=colmax
between colmin colmax in.g out.g              // if col<colmin then col=colmin, etc
range colmin colmax in.g out.g                // = equalise?
floyd nb_colors in.g out.g (reduce colors using Floyd-Steinberg algorithm)
subsample xratio yratio in.g out.g

mknoise colormin colormax width height out.g  // creates an image filled with noise
mkstrippedtube diameter nbsteps nbstripes col0 col1 out.g

grey2bitplanes nbbitplanes in.g out.xxx       // bitplanes in ST mixed format
??? Faire aussi rgb2bitplanes ???

!!!!landscape nbiterations 0 0 in.g out.g


// Pour le filtre si la valeur sort de [0;255] on la met  0 ou 255
                                               //                     (a b c)     
filter a b c d e f g h i n offset in.g out.g   // convolution filter  (d e f) :n + offset 
                                               //                     (g h i)     

rem smooth1:  fab filter 0 1 0 1 1 1 0 1 0 5 0  in.g out.g
rem smooth2:  fab filter 1 2 1 2 4 2 1 2 1 16 0 in.g out.g
rem unsmooth: fab filter -1 1 -1 1 1 1 -1 1 -1 1 0 in.g out.g
rem relief1:  fab filter -2 -1 0 -1 0 1 0 1 2 1 128 in.g out.g
rem relief2:  fab filter -1 1 -1 1 0 1 -1 1 -1 1 128 in.g out.g
rem relief3:  fab filter 0 -1 0 -1 2 0 0 0 0 1 128 in.g out.g
rem strange1:  fab filter 1 0 1 0 -1 0 1 0 1 3 0 in.g out.g
rem strange2:  fab filter 0 1 0 1 -1 1 0 1 0 3 0 in.g out.g
rem sharpness:  fab filter 0 -n 0 -n 4n+1 -n 0 -n 0 1 0 in.g out.g
rem sharpness2: fab filter -n -n -n -n 8n+1 -n -n -n -n 1 0 in.g out.g
rem edge=laplace: fab filter -1 -1 -1 -1 8 -1 -1 -1 -1 1 0 in.g out.g
rem laplace2: fab filter 0 -1 0 -1 4 -1 0 -1 0 1 0 in.g out.g
rem edge2: fab filter -1 -1 -1 0 0 0 1 1 1 1 0 in.g out.g
rem edge3: fab filter -5 0 0 0 0 0 0 0 5 1 0 in.g out.g
rem emboss: fab filter 0 0 0 0 -1 0 0 0 1 1 0 in.g out.g
rem emboss2: fab filter 2 0 0 0 -1 0 0 0 -1 1 0 in.g out.g
rem repoussage: fab filter -2 -1 0 -1 1 1 0 1 2 1 0 in.g out.g

NOT YET IMPLEMENTED
~~~~~~~~~~~~~~~~~~~
darkest
lightest

mask in1.g in2.g out.g
modulo in1.g in2.g out.g
moduloI in.g divisor out.g
resize [w=... | h=... | x...] in.g out.g
resample [w=... | h=... | x...] in.g out.g (bilinear/biquadratic/bicubic... resampling)
stretch (0;126;127 deviendra 0;~253;255)
tile (peut tre mul avec addborders+or)
nearest nb_colors in.g out.g (reduce colors using nearest neighbour)
couleur_majoritaire
gradient
circular_gradient
mkpalette nbcolors red.g green.g blue.g out.pal
floyd palette.pal red.g green.g blue.g out.g // <65536 couleurs
      x 7
    3 5 1
    * There are many ways to find the nearest palette color with varying levels of efficiency
      and quality. A trivial algorithm is to search the color with minimum straight line
      distance in the color cube from the given color.
    * We can alternate between left-to-right and right-to-left (also reflect the diffusion
      matrix), this avoids some kind of artifacts.


>>> fonctions avec wrap <<<
fractal_landscape (ou bien fractal expansion) (+wrap)
ntsc (fred)
voronoi

* Pour les valeurs les demander en hexa $01 ou &01... avec un char qui ne
  peut pas tre dans un nom de fichier?
  On peut viter d'avoir recours  une valeur en crant (random) une image .g
  avec la dite valeur, mais c'est pas trs propre...
* Pour certaines fonctions (and, or, add...) lorsqu'une des images est plus grande
  que l'autre, faire l'opration sur la partie commune (de taille min(w0;w1)*min(h0;h1)
  et qui part du bottom left).
* utiliser une cl usb en guise de ramdisk?
* on pourrait tout faire avec des .g en 16 bits (ainsi rgb2grey serait emul)
* faire les fonctions en wrap par dfaut. Si l'utilisateur n'en veut pas il utilisera un
  addborders+removeborders