Algographe
La machine qui dessine en codant
Ce site internet a été créé pour être consulté sur un ordinateur
avec les versions récentes des navigateurs chrome ou firefox.
© EPPDCSI 2017
La machine qui dessine en codant
La machine qui dessine en codant
Avant de dessiner avec du code,
vous devez apprendre quelques bases
Voici le code pour créer un carré
Touchez la variable pour changer la forme
Ajoutez un triangle
Touchez les paramètres pour changer leur valeur
On utilise le paramètre « rotate ».
En informatique, la récursion est un code qui s'appelle lui même.
Choisissez un niveau de difficulté
Background: couleur de fond
startshape: dessine la forme "START"
saturation: saturation de la couleur
brightness: brillance de la couleur
hue: couleur (sur une roue de 0 à 360)
rotate: rotation
size: taille
rule : permet de définir une forme
CIRCLE: défini un cercle
tile: défini une tuile qui recouvre le dessin
Background: couleur de fond
startshape: dessine la forme "START"
saturation: saturation de la couleur
brightness: brillance de la couleur
hue: couleur (sur une roue de 0 à 360)
rotate: rotation
size: taille
rule : permet de définir une forme
CIRCLE: défini un cercle
tile: défini une tuile qui recouvre le dessin
Background: couleur de fond
startshape: dessine la forme "START"
saturation: saturation de la couleur
brightness: brillance de la couleur
hue: couleur (sur une roue de 0 à 360)
rotate: rotation
size: taille
rule : permet de définir une forme
CIRCLE: défini un cercle
tile: défini une tuile qui recouvre le dessin
Background: couleur de fond
startshape: dessine la forme "START"
saturation: saturation de la couleur
brightness: brillance de la couleur
hue: couleur (sur une roue de 0 à 360)
rotate: rotation
size: taille
rule : permet de définir une forme
CIRCLE: défini un cercle
tile: défini une tuile qui recouvre le dessin
Erreur de syntaxe
Touchez le code pour le modifier
Background: couleur de fond
startshape: dessine la forme "START"
saturation: saturation de la couleur
brightness: brillance de la couleur
hue: couleur (sur une roue de 0 à 360)
rotate: rotation
size: taille
rule : permet de définir une forme
CIRCLE: défini un cercle
tile: défini une tuile qui recouvre le dessin
Background: couleur de fond
startshape: dessine la forme "START"
saturation: saturation de la couleur
brightness: brillance de la couleur
hue: couleur (sur une roue de 0 à 360)
rotate: rotation
size: taille
rule : permet de définir une forme
CIRCLE: défini un cercle
tile: défini une tuile qui recouvre le dessin
Background: couleur de fond
startshape: dessine la forme "START"
saturation: saturation de la couleur
brightness: brillance de la couleur
hue: couleur (sur une roue de 0 à 360)
rotate: rotation
size: taille
rule : permet de définir une forme
CIRCLE: défini un cercle
tile: défini une tuile qui recouvre le dessin
Context Free Art en bref
I - Instructions de base
startshape
Indique quelle forme est utilisée comme point de départ d'une image générée. S'il y a plusieurs instructions startshape alors seule la première est prise en compte.
Exemple
startshape maForme
shape maForme{
SQUARE[]
}
import
Importe le contenu du fichier spécifié après l'instruction import. Les guillemets sont optionnels pour les noms de fichiers sauf si l'on doit spécifier un répertoire, si le nom contient un espace ou ne finit pas en '.cdfg'. Le contenu peut aussi être inséré dans un espace de nom (namespace) différent.
Exemple
import@font alfreebet.cfdg
import "lib/alien eyes.cfdg"
Couleur de fond
Change la couleur de fond qui par défaut est blanche opaque. S'il y a plusieurs fonds spécifiés, seul le premier est pris en compte.
Exemple
CF::Background = [a -1] # fond transparent
Taille du fond
Fixe les dimensions de la toile plutôt qu'elle ne varie dynamiquement avec le dessin.
Exemple
CF::Size = [s 30]
CF::Size = [s 20 30] # fond rectangulaire
Aspect mosaïque
Active le rendu en mosaïque et défini la taille du pavage. S'il y a plusieurs types de pavage spécifiés, seul le premier est pris en compte. Le pavage peut-être carré, rectangulaire, incliné ou tourné tant que l'axe du pavage est parfaitement vertical ou horizontal.
Exemple
CF::Tile = [s 30]
CF::Tile = [s 20 30] # pavage rectangulaire
CF::Tile = [s 30 x 15 y 10]
Le décalage en x et y déplace le contenu par rapport au pavage. Cela permet à l'utilisateur de centrer une partie du dessin par rapport à un pavé.
II - Formes
Une forme peut être définie à partir d'autres formes, dans l'exemple ci-dessous, un cercle dans un carré. Il existe des formes de bases prédéfinies: SQUARE, CIRCLE, TRIANGLE ou FILL à partir desquelles on dessine des formes plus complexes. Dans une forme, ce sont les formes de bases qui sont évaluées en premier, les autres sont placées dans une liste pour être dessinées après.
Exemple
shape maForme{
SQUARE []
CIRCLE [b 1]
}
Comportements aléatoires
Une forme peut être définie par des règles (instruction rule). S'il y a plusieurs règles, la règle exécutée est choisie aléatoirement.
Exemple
shape maForme
rule { SQUARE[] }
rule { CIRCLE[] }
L'instruction rule peut-être suivie d'un nombre qui définit la probabilité relative pour que la règle correspondante soir exécutée. Ainsi, dans l'exemple ci-dessous, un cercle a 90,8% de chance d'être dessiné lors de l'exécution de la forme maForme.
Exemple
shape maForme
rule {SQUARE[] } # 1/11.01=9.1%
rule 10 {CIRCLE[] } # 10/11.01=90.8%
rule 0.01 {} # 0.01/11.01=0.09%
Dans l'exemple suivant, on a attribué directement des pourcentages aux règles sauf à la première dont la probabilité de ce produire sera 100% moins les pourcentages des autres règles.
shape maForme
rule {SQUARE[] } # 9.9% restant
rule 90% {CIRCLE[] } # 90%
rule 0.1% {} # 0.1%
III - Ajustement des formes
L'état d'une forme (position, couleur, etc) se définit par rapport à la forme précédemment dessinée. Ainsi, dans l'exemple suivant
shape maForme{
SQUARE []
CIRCLE [x 1]
}
un carré noir au centre de la toile est dessiné. Puis un cercle lui aussi noir décalé le long de l'axe x (horizontalement par défaut) de 100% (x 1) de la taille du carré précédent. La forme ci-dessous
shape maForme {
SQUARE []
CIRCLE [x 0.5 b 0.5]
}
correspond au dessin d'un carré noir suivi d'un cercle décalé horizontalement de 50% de la taille du carré (x 0.5) et 50% moins brillant (b 0.5) ce qui correspond à du gris.
Les dessins, sont repérés par 3 axes: x (par défaut horizontal), y (par défaut vertical) et z (qui détermine quelle forme est par-dessus l'autre).
Les variables d'ajustements de formes (x, size, etc) sont indiquées ci-dessous :
x val : Décalage val le long de l'axe x
x va1 val2 : Décalage val1 et val2 le long des axes x et y
x va1 val2 val3 : Décalage val1, val2, val3 le long des axes x, y et z
y val : Décalage val le long de l'axe y
z val : Décalage val le long de l'axe z
size val ou s val : Mise à l'échelle selon les axes x et y de la valeur val
size val1 val2 ou s val1 val2 : Mise à l'échelle selon les axes x et y des valeurs val1 et val2
size val1 val2 val3 ou s val1 val2 val3 : Mise à l'échelle selon les axes x, y, z des valeurs val1, val2, val3
rotate val ou r val : Rotation de val degrés
flip val ou f val : Réflexion par rapport à une ligne passant par l'origine du repère à val degrés
skew val 1 val2 : Cisaillement de val1 et val2 degrés par rapport aux axes x et y
time val1 val2 : Décalage de val1 et val2 du temps de naissance et de mort
timescale val1 : Changement d'échelle temporelle de val1
Il existe également une subtilité dans la notation par crochet. Ainsi dans
SQUARE [mes ajustements], les ajustements sont exécutés dans l'ordre x, y, rotate, size, skew et flip et ce qui est dupliqué est supprimé. Alors que dans SQUARE [[mes ajustements]] les ajustements sont appliqués dans l'ordre dans lequel vous les écrivez.
IV - Ajustement des couleurs
hue val ou h val
Ajoute val à la teinte (hue), val allant de 0 à 360.
saturation val ou sat val
val prend une valeur entre 0 et 1. Si val<0, change la saturation de la couleur de val% vers 0. Si val>0, change la saturation de val% vers 1.
brightness val ou b val
val prend une valeur entre 0 et 1. Si val<0, change la brillance de la couleur de val% vers 0. Si val>0, change la brillance de val% vers 1.
alpha val a val
val prend une valeur entre 0 et 1. Si val<0, la forme devient plus transparente. Si val>0, la forme devient moins transparente.
Ainsi
shape maForme{
SQUARE []
CIRCLE [x 0.5 hue 240 sat 0.5 b 0.5 a -0.5]
}
dessine un carré et un cercle décalé de 50% (x 0.5) par rapport au carré, de couleur bleuté (hue 240 sat 0.5 b 0.5) et à moitié transparent (a -0.5)
V - Chemins
Il est possible de créer de nouvelles formes de base avec l'instruction path.
Exemple
startshape carre
path carre{
MOVETO( 0.5, 0.5) #position initiale
LINETO(-0.5, 0.5) #trace une droite
LINETO(-0.5, -0.5) #trace une droite
LINETO( 0.5, -0.5) #trace une droite
CLOSEPOLY() #retourne en position (0.5,0.5) et referme le tracé
}
dessine un carré noir. Les commandes pour définir de nouvelles formes sont les suivantes
MOVETO(xnum, ynum ): se positioner en un point du dessin
LINETO(xnum, ynum ): tracer une droite depuis un point jusqu'à un autre en (xnum, ynum )
ARCTO(xnum, ynum, xradius, yradius, angle ): tracé d'arc de cercle
ARCTO(xnum, ynum, radius ): tracé d'arc de cercle
CURVETO(xnum, ynum, CF::Continuous): tracé d'arc de cercle
CURVETO(xnum, ynum, xctrl1, yctrl1 ) : tracé d'arc de cercle
CURVETO(xnum, ynum, xctrl2, yctrl2, CF::Continuous) : tracé d'arc de cercle
CURVETO(xnum, ynum, xctrl1, yctrl1, xctrl2, yctrl2 ) : tracé d'arc de cercle
CLOSEPOLY() / CLOSEPOLY(CF::Align): fermeture d'une courbe en partant du dernier point au point initial.
Toutes ces instructions en xxxTO ont leur équivalent en xxxREL ou la position du dernier point est alors relative à celle du premier point.
En ce qui concerne
STROKE [adjustments ]
STROKE(stroke flags) [adjustments ]
CF::IsoWidth, CF::ButtCap, etc.
FILL [adjustments ]
FILL(fill flags) [adjustments ]
CF::EvenOdd
VI - Expressions
Opérateurs mathématiques
( ) parenthèses
^ puissance
-, ! négation, booléen not
*, / multiplication et division
+, - addition et soustraction
-- retourne le résultat de la soustraction s'il est positif et 0 sinon
+-, ±, .., … intervalles aléatoires
<, >, <=, ≤, >=, ≥, <>, ≠ comparaison
&&, ||, ^^ booléen
Fonctions mathématiques
sin, cos, tan, cot, en degrés
asin, acos, atan, acot, retourne des degrés
sinh, cosh, tanh, asinh, acosh, atanh
log, log10, sqrt, exp, abs, floor,
atan2(y, x), mod(x, y), divides(x, y), div(x, y),
infinity, factorial, sg,
rand_static(), rand_static(x), rand_static(x, y),
rand(), rand(x), rand(x, y),
randint(), randint(x), randint(x, y),
min(exp0, exp1, exp2, …),
max(exp0, exp1, exp2, …),
ftime, frame
VII - Boucles
Forme 1
loop val [adjustements]
{
Instructions
}
Répète val fois les instructions instructions en ajustant à chaque fois (adjustements) des paramètres de formes et de couleurs.
Exemple
shape maForme{
loop 10 [x 0.1 hue 20]
{
CIRCLE[sat 0.5 b 0.5]
}
}
Dessine des cercles décalés et de couleurs différentes qui se superposent.
Forme 2
loop var=val [adjustements]
{
Instructions
}
Répète val fois les instructions instructions en ajustant à chaque fois des paramètres de formes et de couleurs. La valeur est ici attribuée à une variable var dont on peut se servir dans instructions.
Exemple
shape maForme{
loop i=10 [x 0.1 hue 20]
{
CIRCLE[sat i b 0.5]
}
}
Cet exemple dessine des cercles de couleurs décalés qui se superposent en modifiant la saturation selon l'index i.
Forme 3
loop val [adjustements]
{
Instruction1
}
finally
{
Instruction2
}
ou
loop var=val [adjustements]
{
instructions1
}
finally
{
instructions2
}
Répète instructions1 et finalement 1 fois instructions2
"val" peut s'écrire sous plusieurs formes. Cela peut être un nombre et la boucle se répète autant de fois que ce nombre. Cela peut être sous la forme "valeur de départ, valeur d'arrivée" ou encore sous la forme "valeur de départ, valeur d'arrivée, pas". Dans ce dernier cas la boucle compte depuis la valeur de départ à la valeur d'arrivée de pas en pas. Par exemple "i=2,10,2" prend les valeurs i=2, 4, 6, 8, 10. S'il n'y a qu'une seule instruction, on n'est pas obligé de mettre des accolades. Ainsi
shape maForme{
loop 10 [x 0.1 hue 20]
CIRCLE[sat 0.5 b 0.5]
}
fonctionne aussi et répète 10 fois l'instruction CIRCLE en ajustant chaque fois sa position et sa couleur.
VIII - Conditions
Forme 1
if (condition) then
{
instruction1
}
else
{
instruction2
}
Si condition est respectée alors les instruction1 sont exécutées sinon ce sont les instruction2 . S'il n'y a pas de "sinon" on peut aussi écrire
if (condition) then
{
instruction1
}
On peut aussi écrire
if (cond, true_exp, false_exp)
Evalue cond et retourne true_exp si cond ≠ 0 et false_exp si cond=0.
Forme 1
Une autre manière d'écrire des conditions est
switch (expression) {
case const-case-expression1: case-body1
case const-case-expression2: case-body2
case const-case-expression3: case-body3
case const-case-expression4: case-body4
…
else: else-body
}
switch évalue expression et compare le résultat au const-case-expression. Si l'un de ces cas correspond à ce qui a été évalué pour expression, il exécute l'instruction case-body correspondante. S'il n'en trouve aucun, il exécute les instructions après else
Forme 3
select(n, expr0, expr1, expr2, expr3,…)
Evalue n et retourne expr0 si n<1, expr1 si 1<n<2, expr2 si 2<n<3, etc. Les expr peuvent être des expressions numériques, des ajustements de forme, des spécifications de forme, etc. Ils doivent tous être du même type.
Forme 4
let(var1=expr1; var2=expr2; … ; expression)
Evalue les expr et les associe au var. Alors expression est évalué dans le contexte des variables liées et retourne sa valeur. Une fois var1 calculé, il peut être utilisé, par exemple, dans expr2.
IX - Transform
transform prend une liste d'ajustements qu'il applique à une forme définie dans le corps de la fonction transform
Exemple
startshape box
path box {
MOVETO( 0.5, 0.5)
LINETO(-0.5, 0.5)
LINETO(-0.5, -0.5)
LINETO( 0.5, -0.5)
CLOSEPOLY()
transform [s 0.5 x 0.1] {
MOVETO(0.25, sqrt(3)/4)
loop 5 [r -60]
LINETO(0.5, 0)
CLOSEPOLY()
}
}
X - Définition des variables
Une variable s'écrit comme
maVariable = maValeur
où maValeur peut être un nombre
shape maForme{
maVariable = 0.5
SQUARE[sat 0.5 b maVariable]
}
une forme
shape maForme{
maVariable = SQUARE
maVariable[sat 0.5 b 0.5]
}
un ajustement
shape maForme{
maVariable = [[sat 0.5 b 0.5]]
SQUARE[transform maVariable]
}
Notez dans ce dernier cas, l'utilisation de l'instruction transform. La valeur d'une variable ne peut pas être changée une fois qu'elle a été définie.
XI - Expression
Variables aléatoires
x .. y ou x … y retourne un nombre aléatoire entre [x,y)
x +- y or x ± y retourne un nombre aléatoire entre [x-y,x+y)
Symboles unicode
≤, ≥, ≠, ∞ (infini), π (3.1415926535)
Fonctions entières
div(x, y) retourne la division entière de x par y
divides(x, y) retourne 1 si x est divisible par y et 0 sinon
factorial(n) vaux 1x2x3…xn
floor(x) arrondit x à l'entier le plus petit
isNatural(x) retourne 1 si x est un entier naturel
sg(x) retourne 0 si x=0 ou 1 sinon
Fonctions binaires
bitnot(x) inverse binaire de x
bitand(x, y) fonction logique AND
bitor(x, y) fonction logique OR
bitxor(x, y) fonction logique XOR
bitleft(x, y) décalage vers la gauche de x de y bits
bitright(x, y) décalage vers la droite de x de y bits
Fonctions diverses
infinity() est l'infini ∞
infinity(x) renvoie ∞ si x ≥0 ou -∞ si x<0
max(x0, x1, x2, …) retourne le plus grand élément de la liste
min(x0, x1, x2, …) retourne le plus petit élément de la liste
Fonctions aléatoires
rand_static() retourne un nombre statique (lorsque le fichier est compilé) aléatoire dans l'intervalle [0,1) avec une distribution uniforme
rand_static(x) retourne un nombre statique (lorsque le fichier est compilé) aléatoire dans l'intervalle [0,x) si x>0 ou [x,0) si x < 0, avec une distribution uniforme
rand()/rand(x)/rand(x,y) retourne un nombre aléatoire dans les mêmes intervalles que les rand_static
rand::normal(mean, stddev): retourne un nombre aléatoire selon une distribution normale (ou gausienne)
rand::lognormal(mean, stddev): retourne un nombre aléatoire selon une distribution aléatoire log-normale
rand:: exponential(rate): retourne un nombre aléatoire selon une distribution de probabilité exponentielle.
rand::gamma(alpha_shape, beta_scale): retourne un nombre aléatoire selon la distribution aléatoire gamma.
rand::weibull(alpha_shape, beta_scale): retourne un nombre aléatoire selon la distribution aléatoire weibull.
rand::extremeV(location, scale): retourne un nombre aléatoire selon la distribution aléatoire de la valeur extrême.
rand::chisquared(degree_freedom): retourne un nombre aléatoire selon la distribution aléatoire en chi carré.
rand::cauchy(location, scale): retourne un nombre aléatoire selon la distribution aléatoire de Cauchy.
rand::fisherF(m_degree_freedom, n_degree_freedom): retourne un nombre aléatoire selon la distribution de Fishers F-.
rand::studentT(degree_freedom): retourne un nombre aléatoire selon la T-distribution de Student.
randint()/randint(x)/randint(x, y):: retourne un entier aléatoire dans le même intervalle que les rand_static.
randint::bernoulli(probability): retourne un booléen aléatoire avec une probabilité spécifiée d'être vraie.
randint::binomial(trials, probability): retourne un entier positif selon une distribution binomiale.
randint::negbinomial(trial_failures, probability): retourne un entier positif selon une distribution binomiale négative.
randint::geometric(probability): retourne un entier positif qui représente le nombre d'essai oui/non nécessaire pour obtenir un unique succès.
randint::poisson(mean): retourne un entier positif selon une distribution de Poisson.
randint::discrete(weight_0, weight_1, … , weight_n): retourne un nombre aléatoire dans l'intervalle [0,n] ou chaque valeur i se trouve avec une probabilité selon le poids weight_i.
Context Free Art in brief
I - Basic instructions
startshape
Indicates which shape is used as the starting point of a generated image. If there are several startshape instructions then only the first one is taken into account.
Example
startshape myShape
shape myShape{
SQUARE[]
}
import
Imports the content of the specified file after the import instruction. The quotation marks are optional for file names unless you need to specify a directory, or the name contains a space or does not end in '.cdfg'. The content can also be inserted into a different namespace.
Examples
import@font alfreebet.cfdg
import "lib/alien eyes.cfdg"
Background colour
Changes the background colour, which by default is solid white. If several backgrounds are specified, then only the first one is taken into account.
Example
CF::Background = [a -1] # transparent background
Background size
Sets the canvas dimensions rather than letting them vary dynamically with the drawing.
Examples
CF::Size = [s 30]
CF::Size = [s 20 30] # rectangular background
Mosaic style
Activates the mosaic tiling and sets the tiling size. If several tiled backgrounds have been specified, then only the first one is taken into account. The tiling can be square, rectangular, tilted or rotated as long as the tiling axis is exactly vertical or horizontal.
Examples
CF::Tile = [s 30]
CF::Tile = [s 20 30] # rectangular tiling
CF::Tile = [s 30 x 15 y 10]
The offset x and y values move the content relative to the tiling. This allows users to centre part of the drawing relative to a tile.
II - Shapes
A shape can be defined from other shapes, for example, a circle in a square, as shown below. There are predefined basic shapes: SQUARE, CIRCLE, TRIANGLE and FILL from which more complex shapes are drawn. Within one shape, the basic shapes are evaluated first, and the others are placed in a list to be drawn after.
Example
shape myShape{
SQUARE []
CIRCLE [b 1]
}
Randomness
A shape can be defined by rules (rule instruction). If there are multiple rules, the rule executed is chosen randomly.
Example
shape myShape
rule { SQUARE[] }
rule { CIRCLE[] }
The rule instruction can be followed by a number that defines the relative probability of the corresponding rule being executed. Thus, in the example below, a circle has a 90.8% chance of being drawn when the myShape shape is executed.
Example
shape myShape
rule {SQUARE[] } # 1/11.01=9.1%
rule 10 {CIRCLE[] } # 10/11.01=90.8%
rule 0.01 {} # 0.01/11.01=0.09%
In the following example, percentages have been attributed directly to the rules except for the first one. The probability of its occurrence will be 100% minus the percentages of the other rules.
shape myShape
rule {SQUARE[] } # 9.9% remainder
rule 90% {CIRCLE[] } # 90%
rule 0.1% {} # 0.1%
III - Adjusting shapes
The status of a shape (position, colour, etc.) is defined in relation to the previously drawn shape. So, in the following example
shape myShape{
SQUARE []
CIRCLE [x 1]
}
a black square is drawn in the centre of the canvas. Then a circle, also black, is shifted along the x axis (horizontally by default) by 100% (x 1) of the size of the previous square. The shape below
shape myShape {
SQUARE []
CIRCLE [x 0.5 b 0.5]
}
corresponds to the drawing of a black square followed by a circle, which is horizontally offset by 50% of the size of the square (x 0.5), and 50% darker (b 0.5), which comes out grey.
The drawings are identified by 3 axes: x (horizontal by default), y (vertical by default) and z (which determines which shape is above the other).
The shape adjustment variables (x, size, etc.) are shown in the table below.
x val : val offset along the x axis
x val1 val2 : val1 and val2 offset along the x and y axes
x va1 val2 val3 : val1, val2, val3 offset along the x, y and z axes
y val : val offset along the y axis
z val : val offset along the z axis
size val or s val : Scaling along the x and y axes of the val value
size val1 val2 or s val1 val2 : Scaling along the x and y axes of values val1 and val2
size val1 val2 val3 or s val1 val2 val3 : Scaling along the x, y, z axes of values val1, val2, val3
rotate val or r val : Rotation of val degrees
flip val or f val : Reflection in relation to a line passing through the origin of the reference point at val degrees
skew val 1 val2 : Shear of val1 and val2 degrees in relation to the x and y axes
time val1 val2 : val1 and val2 offset of birth and death time
timescale val1 : Changing the time scale of val1
There is also a subtle difference in the bracket notation. So in
SQUARE [my adjustments], the adjustments are executed in the order x, y, rotate, size, skew and flip and any duplications are deleted. While in SQUARE [[my adjustments]] the adjustments are applied in the order in which you write them.
IV - Colour adjustment
hue val or h val
Adds val to the hue, ranging from 0 to 360.
saturation val or sat val
val takes a value between 0 and 1. If val<0, change the colour saturation of val% to 0. If val>0, change the saturation of val% to 1.
brightness val or b val
val takes a value between 0 and 1. If val<0, change the brightness of the colour from val% to 0. If val>0, change the brightness of val% to 1.
alpha val to val
val takes a value between 0 and 1. If val<0, the shape becomes more transparent. If val>0, the shape becomes less transparent.
So
shape myShape{
SQUARE []
CIRCLE [x 0.5 hue 240 sat 0.5 b 0.5 a -0.5]
}
draws a square and a circle offset by 50% (x 0.5) from the square, of a bluish colour (hue 240 sat 0.5 b 0.5) and semi-transparent (a -0.5)
V - Paths
You can create new basic shapes with the path instruction.
Example
startshape square
path square{
MOVETO(0.5, 0.5) #initial position
LINETO(-0.5, 0.5) #draws a straight line
LINETO(-0.5, -0.5) #draws a straight line
LINETO(0.5, -0.5) #draws a straight line
CLOSEPOLY() #returns to position (0.5,0.5) and completes the shape
}
draws a black square. The commands for defining new shapes are as follows
MOVETO(xnum, ynum ): moves to a point in the drawing
LINETO(xnum, ynum): draws a straight line from one point to another with (xnum, ynum)
ARCTO(xnum, ynum, xradius, yradius, angle ): draws a circle arc
ARCTO(xnum, ynum, radius ): draws a circle arc
CURVETO(xnum, ynum, CF::Continuous): draws a circle arc
CURVETO(xnum, ynum, xctrl1, yctrl1 ): draws a circle arc
CURVETO(xnum, ynum, xctrl2, yctrl2, CF::Continuous): draws a circle arc
CURVETO(xnum, ynum, xctrl1, yctrl1, xctrl2, yctrl2 ): draws a circle arc
CLOSEPOLY() / CLOSEPOLY(CF::Align): completes a curved shape by connecting the last point to the first point.
All these instructions in the form xxxTO have an equivalent as xxxREL, where the position of the last point is relative to the first point.
For
STROKE [adjustments ]
STROKE(stroke flags) [adjustments ]
CF::IsoWidth, CF::ButtCap, etc.
FILL [adjustments ]
FILL(fill flags) [adjustments ]
CF::EvenOdd
VI - Expressions
Mathematical operators
( ) brackets
^ power
-,! negation, boolean not
*, / multiplication and division
+, - addition and subtraction
- returns the result of the subtraction if it is positive and otherwise 0
+-, ±, .., ... random intervals
<, >, <=, ≤, >=, ≥, <>, ≠ comparison
&&, ||, ^^ boolean
Mathematical functions
sin, cos, tan, cot, degrees
asin, acos, atan, acot, returns degrees
sinh, cosh, tanh, asinh, acosh, atanh
log, log10, sqrt, exp, abs, floor,
atan2(y, x), mod(x, y), divides(x, y), div(x, y),
infinity, factorial, sg,
rand_static(), rand_static(x), rand_static(x, y),
rand(), rand(x), rand(x, y),
randint(), randint(x), randint(x, y),
min(exp0, exp1, exp2, …),
max(exp0, exp1, exp2, …),
ftime, frame
VII - Loops
Shape 1
loop val [adjustments]
{
Instructions
}
Repeats the instructions instructions val times by adjusting the shape and colour settings each time (adjustments).
Example:
shape myShape{
loop 10 [x 0.1 hue 20]
{
CIRCLE[sat 0.5 b 0.5]
}
}
Draw offset circles of different colours that are overlapping.
Shape 2
loop var=val [adjustments]
{
Instructions
}
Repeats the instructions instructions val times by adjusting the shape and colour settings each time. Here the value is assigned to a variable var which can be used in instructions.
Example:
shape myShape{
loop i=10 [x 0.1 hue 20]
{
CIRCLE[sat i b 0.5]
}
}
This example draws offset circles of different colours that overlap, by changing the saturation according to the index i.
Shape 3
loop val [adjustments]
{
Instruction1
}
finally
{
Instruction2
}
or
loop var=val [adjustments]
{
instructions1
}
finally
{
instructions2
}
Repeat instructions1 and finally instructions2 once
"val" can be written in several ways. It can be a number and the loop is repeated as many times as this number. It can be in the form of "start value, end value" or in the form "start value, end value, step". In this case, the loop counts from the start value to the end value, from step to step. For example "i = 2,10,2" takes the values i = 2, 4, 6, 8, 10. If there is only one instruction, you do not have to add curly brackets. So
shape myShape{
loop 10 [x 0.1 hue 20]
CIRCLE[sat 0.5 b 0.5]
}
also works and repeats the CIRCLE instruction 10 times, adjusting its position and colour each time.
VIII - Conditions
Shape 1
if (condition) then
{
instruction1
}
else
{
instruction2
}
If condition applies then the instructions1 are executed, if not instructions2 are executed. If there is no "else" we can also write
if (condition) then
{
instruction1
}
We can also write
if (cond, true_exp, false_exp)
Evaluate cond and return true_exp if cond ≠ 0 and false_exp if cond = 0.
Shape 1
Another way of writing conditions is
switch (expression) {
case const-case-expression1: case-body1
case const-case-expression2: case-body2
case const-case-expression3: case-body3
case const-case-expression4: case-body4
etc.
else: else-body
}
switch evaluates expression and compares the result to const-case-expression. If one of these cases matches what has been evaluated for expression, it executes the corresponding case-body instruction. If it doesn't find one, it executes the instructions after else
Shape 3
select (n, expr0, expr1, expr2, expr3, etc.)
Evaluates n and returns expr0 if n <1, expr1 if 1 <n <2, expr2 if 2 <n <3, and so on. The expr commands can be numeric expressions, shape adjustments, shape specifications, etc. They must all be of the same type.
Shape 4
let(var1=expr1; var2=expr2; … ; expression)
Evaluates the expr commands and associates them with the var commands. Then expression is evaluated in the context of the linked variables and returns its value. Once var1 has been calculated, it can be used, for example, in expr2.
IX - Transform
transform takes a list of adjustments that it applies to a shape defined in the body of the transform function
Example
startshape box
path box {
MOVETO(0.5, 0.5)
LINETO(-0.5, 0.5)
LINETO(-0.5, -0.5)
LINETO( 0.5, -0.5)
CLOSEPOLY()
transform [s 0.5 x 0.1] {
MOVETO(0.25, sqrt(3)/4)
loop 5 [r -60]
LINETO(0.5, 0)
CLOSEPOLY()
}
}
X - Definition of variables
A variable is written as
myVariable = myValue
where myValue can be a number
shape myShape{
myVariable = 0.5
SQUARE[sat 0.5 b myVariable]
}
a shape
shape myShape{
myVariable = SQUARE
myVariable[sat 0.5 b 0.5]
}
an adjustment
shape myShape{
myVariable = [[sat 0.5 b 0.5]]
SQUARE[transform myVariable]
}
Note the use of the transform instruction in the last case. The value of a variable cannot be changed once it has been defined.
XI - Expression
Random variables
x .. y or x … y returns a random number between [x, y)
x +- y or x ± y returns a random number between [x-y, x + y)
Unicode symbols
≤, ≥, ≠, ∞ (infinity), π (3.1415926535)
Integral functions
div(x, y) returns the integral division of x by y
divides(x, y) returns 1 if x is divisible by y and otherwise 0
factorial(n) equals 1x2x3 ... xn
floor(x) rounds x up or down to the smallest integer
isNatural(x) returns 1 if x is a natural integer
sg(x) returns 0 if x = 0 or otherwise 1
Binary functions
bitnot(x) binary inverse of x
bitand(x, y) logic function AND
bitor(x, y) logic function OR
bitxor(x, y) logic function XOR
bitleft(x, y) offset to the left by x of y bits
bitright(x, y) offset to the right by x of y bits
Various functions
infinity() is infinity ∞
infinity(x) returns ∞ if x≥0 or -∞ if x<0
max (x0, x1, x2, etc.) returns the highest number in the list
min (x0, x1, x2, etc.) returns the lowest number in the list
Random functions
rand_static() returns a random static number (when the file is compiled) in the interval [0,1] with uniform distribution
rand_static(x) returns a random static number (when the file is compiled) in the interval [0, x) if x>0 or [x,0) if x<0, with uniform distribution
rand()/rand(x)/rand(x, y) returns a random number in the same intervals as rand_static
rand::normal(mean, stddev): returns a random number based on normal (or Gaussian) distribution
rand::lognormal(mean, stddev): returns a random number based on log-normal random distribution
rand::exponential(rate): returns a random number based on exponential probability distribution.
rand::gamma(alpha_shape, beta_scale): returns a random number based on gamma random distribution.
rand::weibull(alpha_shape, beta_scale): returns a random number based on weibull random distribution.
rand::extremeV(location, scale): returns a random number based on random distribution of the extreme value.
rand::chisquared(degree_freedom): returns a random number based on chi-square random distribution.
rand::cauchy(location, scale): returns a random number based on Cauchy random distribution.
rand::fisherF(m_degree_freedom, n_degree_freedom): returns a random number based on Fishers F- distribution.
rand::studentT(degree_freedom): returns a random number based on Student's T-distribution.
randint()/randint(x)/randint(x, y):: returns a random integer in the same interval as rand_static.
randint::bernoulli(probability): returns a random boolean number with a specified probability of being true.
randint::binomial(trials, probability): returns a positive integer based on binomial distribution.
randint::negbinomial(trial_failures, probability): returns a positive integer based on negative binomial distribution.
randint::geometric(probability): returns a positive integer that represents the number of yes/no attempts needed to achieve a single success.
randint::fish(mean): returns a positive integer based on Poisson distribution.
randint::discrete(weight_0, weight_1, etc., weight_n): returns a random number in the interval [0, n] where each value i is found with a probability based on weight_i.
Context Free Art in breve
I - Istruzioni di base
startshape
Indica la forma che viene utilizzata come punto di partenza di un'immagine generata. In presenza di più istruzioni startshape,viene considerata solo la prima.
Esempio
startshape miaForma
shape miaForma{
SQUARE[]
}
import
Importa il contenuto del file specificato dopo l'istruzione import. Le virgolette nei nomi dei file sono facoltative, a meno che non si debba specificare una directory, il nome non contenga uno spazio o non termini con ".cdfg". Il contenuto può essere inserito anche in uno spazio di nome (namespace) diverso.
Esempi
import@font alfreebet.cfdg
import "lib/alien eyes.cfdg"
Colore dello sfondo
Modifica il colore dello sfondo che, per impostazione predefinita, è bianco opaco. Se ci sono più sfondi specificati, viene considerato solo il primo.
Esempio
CF::Background = [a -1] # sfondo trasparente
Dimensioni dello sfondo
Definisce le dimensioni fisse della tela, impedendo loro di variare in modo dinamico con il disegno.
Esempi
CF::Size = [s 30]
CF::Size = [s 20 30] # sfondo rettangolare
Aspetto a mosaico
Attiva l'aspetto a mosaico e definisce le dimensioni della pavimentazione. Se ci sono più tipi di pavimentazione specificati, viene considerato solo il primo. La pavimentazione può essere quadrata, rettangolare, inclinata o ruotata se l'asse della pavimentazione è perfettamente verticale o orizzontale.
Esempi
CF::Tile = [s 30]
CF::Tile = [s 20 30] # pavimentazione rettangolare
CF::Tile = [s 30 x 15 y 10]
Il divario tra x e y sposta il contenuto in rapporto alla pavimentazione, consentendo all'utente di centrare una parte del disegno rispetto alla pavimentazione.
II - Forme
Una forma può essere definita a partire da altre forme. Di seguito, ad esempio, un cerchio viene definito all'interno di un quadrato. Esistono forme di base predefinite, come SQUARE, CIRCLE, TRIANGLE o FILL a partire dalle quali è possibile realizzare forme più complesse. In una forma sono presenti le forme di base che vengono valutate in un primo momento, mentre le altre vengono disposte in un elenco per essere poi disegnate in seguito.
Esempio
shape miaForma{
SQUARE []
CIRCLE [b 1]
}
Comportamenti aleatori
Una forma può essere definita da regole (istruzione rule). In presenza di più regole, la regola eseguita viene scelta a caso.
Esempio
shape miaForma
rule { SQUARE[] }
rule { CIRCLE[] }
L'istruzione rule può essere seguita da un numero che stabilisce la probabilità relativa perché la regola corrispondente venga eseguita. Così, nell'esempio che segue, un cerchio ha il 90,8% di probabilità di essere disegnato durante l'esecuzione della forma miaForma.
Esempio
shape miaForma
rule {SQUARE[] } # 1/11,01=9,1%
rule 10 {CIRCLE[] } # 10/11,01=90,8%
rule 0,01 {} # 0,01/11,01=0,09%
Nel seguente esempio, sono state attribuite direttamente delle percentuali alle regole tranne alla prima, pertanto la probabilità di riproduzione di quest'ultima corrisponderà al 100% meno le percentuali assegnate alle altre regole.
shape miaForma
rule {SQUARE[] } # 9,9% restante
rule 90% {CIRCLE[] } # 90%
rule 0,1% {} # 0,1%
III - Regolazione delle forme
Lo stato di una forma (posizione, colore, ecc.) viene definito in rapporto alla forma precedentemente disegnata. Così, nell'esempio seguente
shape miaForma{
SQUARE []
CIRCLE [x 1]
}
viene disegnato un quadrato nero al centro della tela. Poi un cerchio nero viene spostato lungo l'asse x (orizzontalmente, per impostazione predefinita) del 100% (x 1) rispetto alle dimensioni del quadrato precedente. La forma seguente
shape miaForma {
SQUARE []
CIRCLE [x 0,5 b 0,5]
}
corrisponde al disegno di un quadrato nero seguito da un cerchio spostato orizzontalmente del 50% rispetto alle dimensioni del quadrato (x 0,5) e 50% meno brillante (b 0,5), ovvero grigio.
I disegni vengono eseguiti su 3 assi: x (orizzontale per impostazione predefinita), y (verticale per impostazione predefinita) e z (che determina quale forma si trova al di sopra dell'altra).
Le variabili di regolazione delle forme (x, size, ecc,) sono indicate nella tabella seguente.
x val : Spostamento val lungo l'asse x
x val1 val2 : Spostamento val1 e val2 lungo gli assi x e y
x va1 val2 val3 : Spostamento val1, val2, val3 lungo gli assi x, y e z
y val : Spostamento val lungo l'asse y
z val : Spostamento val lungo l'asse z
size val o s val : In scala rispetto agli assi x e y del valore val
size val1 val2 o s val1 val2 : In scala rispetto agli assi x e y dei valori val1 e val2
size val1 val2 val3 o s val1 val2 val3 : In scala rispetto agli assi x, y, z dei valori val1, val2, val3
rotate val o r val : Rotazione di val gradi
flip val o f val : Riflessione rispetto a una linea passante per l'origine del punto di riferimento a val gradi
skew val1 val2 : Taglio di val1 e val2 gradi in rapporto agli assi x e y
time val1 val2 : Intervallo di val1 e val2 tra il momento di origine e di termine
timescale val1 : Modifica di scala temporale di val1
Inoltre, nella nota tra parentesi quadre è presente una lieve differenza. Ad esempio, in
SQUARE [mie regolazioni], le regolazioni vengono eseguite nell'ordine x, y, rotate, size, skew e flip e i valori duplicati vengono eliminati. Mentre in SQUARE [[mie regolazioni]], le regolazioni vengono applicate nell'ordine in cui vengono scritte.
IV - Regolazione dei colori
hue val o h val
Aggiunge val alla tinta (hue), val è compreso tra 0 e 360.
saturation val o sat val
val assume un valore compreso tra 0 e 1. Se val<0, la saturazione del colore di val% varia verso 0. Se val>0, la saturazione di val% varia verso 1.
brightness val o b val
val assume un valore compreso tra 0 e 1. Se val<0, la luminosità del colore di val% varia verso 0. Se val>0, la luminosità di val% varia verso 1.
alpha val a val
val assume un valore compreso tra 0 e 1. Se val<0, la forma diventa più trasparente. Se val>0, la trasparenza della forma diminuisce.
Così
shape miaForma{
SQUARE []
CIRCLE [x 0,5 hue 240 sat 0,5 b 0,5 a -0,5]
}
disegna un quadrato e un cerchio spostato del 50% (x 0,5) rispetto al cerchio, di colore azzurrino (hue 240 sat 0,5 b 0,5) e semi trasparente (a -0,5)
V - Percorsi
L'istruzione path consente di realizzare nuove forme di base.
Esempio
startshape quadrato
path quadrato{
MOVETO(0,5, 0,5) #posizione iniziale
LINETO(-0,5, 0,5) #traccia una retta
LINETO(-0,5, -0,5) #traccia una retta
LINETO(0,5, -0,5) #traccia una retta
CLOSEPOLY() #torna in posizione (0,5, 0,5) e richiude la linea
}
disegna un quadrato nero. I comandi per definire nuove forme sono i seguenti
MOVETO(xnum, ynum): posizionarsi in un punto del disegno
LINETO(xnum, ynum): tracciare una retta da un punto a un altro in (xnum, ynum)
ARCTO(xnum, ynum, xradius, yradius, angle): tracciato in semicerchio
ARCTO(xnum, ynum, radius): tracciato in semicerchio
CURVETO(xnum, ynum, CF::Continuous): tracciato in semicerchio
CURVETO(xnum, ynum, xctrl1, yctrl1): tracciato in semicerchio
CURVETO(xnum, ynum, xctrl2, yctrl2, CF::Continuous): tracciato in semicerchio
CURVETO(xnum, ynum, xctrl1, yctrl1, xctrl2, yctrl2): tracciato in semicerchio
CLOSEPOLY() / CLOSEPOLY(CF::Align): chiusura di una curva partendo dall'ultimo punto al punto iniziale.
Tutte queste istruzioni in xxxTO trovano il loro equivalente in xxxREL oppure la posizione dell'ultimo punto è relativa a quella del primo punto.
Per quanto riguarda
STROKE [regolazioni]
STROKE(stroke flags) [regolazioni]
CF::IsoWidth, CF::ButtCap, ecc.
FILL [regolazioni]
FILL(fill flags) [regolazioni]
CF::EvenOdd
VI - Espressioni
Operatori matematici
( ) parentesi
^ potenza
-, ! negativo, valore booleano not
*, / moltiplicazione e divisione
+, - addizione e sottrazione
-- restituisce il risultato della sottrazione se è positivo e 0 in caso contrario
+-, ±, .., … intervalli casuali
<, >, <=, ≤, >=, ≥, <>, ≠ paragone
&&, ||, ^^ valori booleani
Funzioni matematiche
sin, cos, tan, cot, in gradi
asin, acos, atan, acot, risultato in gradi
sinh, cosh, tanh, asinh, acosh, atanh
log, log10, sqrt, exp, abs, floor,
atan2(y, x), mod(x, y), divides(x, y), div(x, y),
infinity, factorial, sg,
rand_static(), rand_static(x), rand_static(x, y),
rand(), rand(x), rand(x, y),
randint(), randint(x), randint(x, y),
min(exp0, exp1, exp2,…),
max(exp0, exp1, exp2,…),
ftime, frame
VII - Anelli
Forma 1
loop val [regolazioni]
{
Istruzioni
}
Ripete val volte le istruzioni istruzioni, regolando di volta in volta (regolazioni) i parametri di forme e colori.
Esempio:
shape miaForma{
loop 10 [x 0,1 hue 20]
{
CIRCLE[sat 0,5 b 0,5]
}
}
Disegna dei cerchi concentrici di colori diversi che si sovrappongono.
Forma 2
loop var=val [regolazioni]
{
Istruzioni
}
Ripete val volte le istruzioni istruzioni, regolando di volta in volta i parametri di forme e colori. Il valore qui è assegnato a una variabile var che può essere utilizzata nelle istruzioni.
Esempio:
shape miaForma{
loop i=10 [x 0,1 hue 20]
{
CIRCLE[sat i b 0,5]
}
}
In questo esempio vengono disegnati cerchi di colori sfumati che si sovrappongono modificando la saturazione in base all'indice i.
Forma 3
loop val [regolazioni]
{
Istruzione1
}
finally
{
Istruzione2
}
o
loop var=val [regolazioni]
{
istruzioni1
}
finally
{
istruzioni2
}
Ripete istruzioni1 e alla fine 1 volta sola istruzioni2
È possibile scrivere "val" in vari modi. Può essere un numero, indicando così le volte in cui si ripete il cerchio. Può essere un "valore di partenza, valore di arrivo" o ancora "valore di partenza, valore di arrivo, incremento". In tal caso, il cerchio parte dal valore di partenza e finisce nel valore di arrivo, tramite gli incrementi indicati. Ad esempio "i=2,10,2" prende i valori i=2, 4, 6, 8, 10. In presenza di una sola istruzione, non è obbligatorio inserire delle parentesi graffe. Così
shape miaForma{
loop 10 [x 0,1 hue 20]
CIRCLE[sat 0,5 b 0,5]
}
funziona in egual modo e ripete 10 volte l'istruzione CIRCLE regolando ogni volta la posizione e il colore.
VIII - Condizioni
Forma 1
if (condizione) then
{
istruzione1
}
else
{
istruzione2
}
Se condizione viene rispettata, viene eseguita istruzione1, in caso contrario istruzione2. In mancanza di "in caso contrario", è possibile anche scrivere
if (condizione) then
{
istruzione1
}
È inoltre possibile scrivere
if (cond, true_exp, false_exp)
Valuta cond e restituisce true_exp se cond ≠ 0 e false_exp se cond=0.
Forma 1
Le condizioni possono essere scritte anche in un altro modo
switch (espressione) {
case const-case-expression1: case-body1
case const-case-expression2: case-body2
case const-case-expression3: case-body3
case const-case-expression4: case-body4
…
else: else-body
}
switch valuta espressione e confronta il risultato con const-case-expression. Se uno qualsiasi di questi casi corrisponde a ciò che è stato valutato per espressione, esegue la corrispondente istruzione case-body. In assenza di corrispondenza, esegue le istruzioni dopo else
Forma 3
select(n, expr0, expr1, expr2, expr3,…)
Valuta n e restituisce expr0 se n<1, expr1 se 1<n<2, expr2 se 2<n<3, ecc. expr possono essere espressioni numeriche, regolazioni di forma, specifiche di forma, ecc. Devono essere tutte dello stesso tipo.
Forma 4
let(var1=expr1; var2=expr2; … ; expression)
Valuta expr e le associa a var. expression viene quindi valutata nel contesto delle variabili correlate e restituisce il suo valore. Dopo aver calcolato var1, questo può essere utilizzato, ad esempio, in expr2.
IX - Transform
transform prende un elenco di regolazioni che applica a una forma definita nel corpo della funzione transform
Esempio
startshape box
path box {
MOVETO(0,5, 0,5)
LINETO(-0,5, 0,5)
LINETO(-0,5, -0,5)
LINETO(0,5, -0,5)
CLOSEPOLY()
transform [s 0,5 x 0,1] {
MOVETO(0,25, sqrt(3)/4)
loop 5 [r -60]
LINETO(0,5, 0)
CLOSEPOLY()
}
}
X - Definizione delle variabili
Una variabile può essere scritta come
miaVariabile = mioValore
dove mioValore può essere un numero
shape miaForma{
miaVariabile = 0,5
SQUARE[sat 0,5 b miaVariabile]
}
una forma
shape miaForma{
miaVariabile = SQUARE
miaVariabile[sat 0,5 b 0,5]
}
una regolazione
shape miaForma{
miaVariabile = [[sat 0,5 b 0,5]]
SQUARE[transform miaVariabile]
}
Notare l'utilizzo dell'istruzione transform in quest'ultimo caso. Il valore di una variabile non può essere modificato una volta impostato.
XI - Espressione
Variabili aleatorie
x .. y o x … y restituisce un numero casuale tra [x,y)
x +- y o x ± y restituisce un numero casuale tra [x-y,x+y)
Simboli Unicode
≤, ≥, ≠, ∞ (infinito), π (3,1415926535)
Funzioni intere
div(x, y) restituisce la divisione intera di x per y
divides(x, y) restituisce 1 se x è divisibile per y e 0 in caso contrario
factorial(n) vale 1x2x3…xn
floor(x) arrotonda x all'intero minore
isNatural(x) restituisce 1 se x è un intero naturale
sg(x) restituisce 0 se x=0 o 1 in caso contrario
Funzioni binarie
bitnot(x) binario inverso di x
bitand(x, y) funzione logica AND
bitor(x, y) funzione logica OR
bitxor(x, y) funzione logica XOR
bitleft(x, y) spostamento verso sinistra di x di y bit
bitright(x, y) spostamento verso destra di x di y bit
Funzioni diverse
infinity() è il simbolo dell'infinito ∞
infinity(x) rinvia ∞ se x ≥0 o -∞ se x<0
max(x0, x1, x2, …) restituisce l'elemento più grande dell'elenco
min(x0, x1, x2, …) restituisce l'elemento più piccolo dell'elenco
Funzioni aleatorie
rand_static() restituisce un numero statico (quando il file viene compilato) casuale compreso nell'intervallo [0,1) con una distribuzione uniforme
rand_static(x) restituisce un numero statico (quando il file viene compilato) casuale compreso nell'intervallo [0,x) se x>0 o [x,0) se x < 0, con una distribuzione uniforme
rand()/rand(x)/rand(x,y) restituisce un numero casuale compreso negli stessi intervalli di rand_static
rand::normal(mean, stddev): restituisce un numero casuale in base a una distribuzione normale (o di Gauss)
rand::normal(mean, stddev): restituisce un numero casuale in base a una distribuzione causale log-normale
rand:: exponential(rate): restituisce un numero causale in base a una distribuzione di probabilità esponenziale.
rand::gamma(alpha_shape, beta_scale): restituisce un numero casuale in base alla distribuzione casuale Gamma.
rand::weibull(alpha_shape, beta_scale): restituisce un numero casuale in base alla distribuzione casuale di Weibull.
rand::extremeV(location, scale): restituisce un numero casuale in base alla distribuzione casuale del valore estremo.
rand::chisquared(degree_freedom): restituisce un numero casuale in base alla distribuzione casuale chi quadrato.
rand::cauchy(location, scale): restituisce un numero casuale in base alla distribuzione casuale di Cauchy.
rand::fisherF(m_degree_freedom, n_degree_freedom): restituisce un numero casuale in base alla distribuzione di Fisher-Snedecor.
rand::studentT(degree_freedom): restituisce un numero casuale in base alla distribuzione t di Student.
randint()/randint(x)/randint(x, y):: restituisce un numero intero casuale compreso nello stesso intervallo di rand_static.
randint::bernoulli(probability): restituisce un valore booleano casuale con una probabilità specificata di costituire un valore vero.
randint::binomial(trials, probability): restituisce un valore intero positivo in base a una distribuzione binomiale.
randint::negbinomial(trial_failures, probability): restituisce un valore intero positivo in base a una distribuzione binomiale negativa.
randint::geometric(probability): restituisce un numero intero positivo che rappresenta il numero di prova sì/no necessario per ottenere un successo unico.
randint::poisson(mean): restituisce un numero intero positivo in base alla distribuzione di Poisson.
randint::discrete(weight_0, weight_1, … , weight_n): restituisce un numero casuale compreso nell'intervallo [0,n] oppure ogni valore i si trova con una probabilità in base al peso weight_i.
Erreur de syntaxe
Context Free Art en bref
I - Instructions de base
startshape
Indique quelle forme est utilisée comme point de départ d'une image générée. S'il y a plusieurs instructions startshape alors seule la première est prise en compte.
Exemple
startshape maForme
shape maForme{
SQUARE[]
}
import
Importe le contenu du fichier spécifié après l'instruction import. Les guillemets sont optionnels pour les noms de fichiers sauf si l'on doit spécifier un répertoire, si le nom contient un espace ou ne finit pas en '.cdfg'. Le contenu peut aussi être inséré dans un espace de nom (namespace) différent.
Exemple
import@font alfreebet.cfdg
import "lib/alien eyes.cfdg"
Couleur de fond
Change la couleur de fond qui par défaut est blanche opaque. S'il y a plusieurs fonds spécifiés, seul le premier est pris en compte.
Exemple
CF::Background = [a -1] # fond transparent
Taille du fond
Fixe les dimensions de la toile plutôt qu'elle ne varie dynamiquement avec le dessin.
Exemple
CF::Size = [s 30]
CF::Size = [s 20 30] # fond rectangulaire
Aspect mosaïque
Active le rendu en mosaïque et défini la taille du pavage. S'il y a plusieurs types de pavage spécifiés, seul le premier est pris en compte. Le pavage peut-être carré, rectangulaire, incliné ou tourné tant que l'axe du pavage est parfaitement vertical ou horizontal.
Exemple
CF::Tile = [s 30]
CF::Tile = [s 20 30] # pavage rectangulaire
CF::Tile = [s 30 x 15 y 10]
Le décalage en x et y déplace le contenu par rapport au pavage. Cela permet à l'utilisateur de centrer une partie du dessin par rapport à un pavé.
II - Formes
Une forme peut être définie à partir d'autres formes, dans l'exemple ci-dessous, un cercle dans un carré. Il existe des formes de bases prédéfinies: SQUARE, CIRCLE, TRIANGLE ou FILL à partir desquelles on dessine des formes plus complexes. Dans une forme, ce sont les formes de bases qui sont évaluées en premier, les autres sont placées dans une liste pour être dessinées après.
Exemple
shape maForme{
SQUARE []
CIRCLE [b 1]
}
Comportements aléatoires
Une forme peut être définie par des règles (instruction rule). S'il y a plusieurs règles, la règle exécutée est choisie aléatoirement.
Exemple
shape maForme
rule { SQUARE[] }
rule { CIRCLE[] }
L'instruction rule peut-être suivie d'un nombre qui définit la probabilité relative pour que la règle correspondante soir exécutée. Ainsi, dans l'exemple ci-dessous, un cercle a 90,8% de chance d'être dessiné lors de l'exécution de la forme maForme.
Exemple
shape maForme
rule {SQUARE[] } # 1/11.01=9.1%
rule 10 {CIRCLE[] } # 10/11.01=90.8%
rule 0.01 {} # 0.01/11.01=0.09%
Dans l'exemple suivant, on a attribué directement des pourcentages aux règles sauf à la première dont la probabilité de ce produire sera 100% moins les pourcentages des autres règles.
shape maForme
rule {SQUARE[] } # 9.9% restant
rule 90% {CIRCLE[] } # 90%
rule 0.1% {} # 0.1%
III - Ajustement des formes
L'état d'une forme (position, couleur, etc) se définit par rapport à la forme précédemment dessinée. Ainsi, dans l'exemple suivant
shape maForme{
SQUARE []
CIRCLE [x 1]
}
un carré noir au centre de la toile est dessiné. Puis un cercle lui aussi noir décalé le long de l'axe x (horizontalement par défaut) de 100% (x 1) de la taille du carré précédent. La forme ci-dessous
shape maForme {
SQUARE []
CIRCLE [x 0.5 b 0.5]
}
correspond au dessin d'un carré noir suivi d'un cercle décalé horizontalement de 50% de la taille du carré (x 0.5) et 50% moins brillant (b 0.5) ce qui correspond à du gris.
Les dessins, sont repérés par 3 axes: x (par défaut horizontal), y (par défaut vertical) et z (qui détermine quelle forme est par-dessus l'autre).
Les variables d'ajustements de formes (x, size, etc) sont indiquées ci-dessous :
x val : Décalage val le long de l'axe x
x va1 val2 : Décalage val1 et val2 le long des axes x et y
x va1 val2 val3 : Décalage val1, val2, val3 le long des axes x, y et z
y val : Décalage val le long de l'axe y
z val : Décalage val le long de l'axe z
size val ou s val : Mise à l'échelle selon les axes x et y de la valeur val
size val1 val2 ou s val1 val2 : Mise à l'échelle selon les axes x et y des valeurs val1 et val2
size val1 val2 val3 ou s val1 val2 val3 : Mise à l'échelle selon les axes x, y, z des valeurs val1, val2, val3
rotate val ou r val : Rotation de val degrés
flip val ou f val : Réflexion par rapport à une ligne passant par l'origine du repère à val degrés
skew val 1 val2 : Cisaillement de val1 et val2 degrés par rapport aux axes x et y
time val1 val2 : Décalage de val1 et val2 du temps de naissance et de mort
timescale val1 : Changement d'échelle temporelle de val1
Il existe également une subtilité dans la notation par crochet. Ainsi dans
SQUARE [mes ajustements], les ajustements sont exécutés dans l'ordre x, y, rotate, size, skew et flip et ce qui est dupliqué est supprimé. Alors que dans SQUARE [[mes ajustements]] les ajustements sont appliqués dans l'ordre dans lequel vous les écrivez.
IV - Ajustement des couleurs
hue val ou h val
Ajoute val à la teinte (hue), val allant de 0 à 360.
saturation val ou sat val
val prend une valeur entre 0 et 1. Si val<0, change la saturation de la couleur de val% vers 0. Si val>0, change la saturation de val% vers 1.
brightness val ou b val
val prend une valeur entre 0 et 1. Si val<0, change la brillance de la couleur de val% vers 0. Si val>0, change la brillance de val% vers 1.
alpha val a val
val prend une valeur entre 0 et 1. Si val<0, la forme devient plus transparente. Si val>0, la forme devient moins transparente.
Ainsi
shape maForme{
SQUARE []
CIRCLE [x 0.5 hue 240 sat 0.5 b 0.5 a -0.5]
}
dessine un carré et un cercle décalé de 50% (x 0.5) par rapport au carré, de couleur bleuté (hue 240 sat 0.5 b 0.5) et à moitié transparent (a -0.5)
V - Chemins
Il est possible de créer de nouvelles formes de base avec l'instruction path.
Exemple
startshape carre
path carre{
MOVETO( 0.5, 0.5) #position initiale
LINETO(-0.5, 0.5) #trace une droite
LINETO(-0.5, -0.5) #trace une droite
LINETO( 0.5, -0.5) #trace une droite
CLOSEPOLY() #retourne en position (0.5,0.5) et referme le tracé
}
dessine un carré noir. Les commandes pour définir de nouvelles formes sont les suivantes
MOVETO(xnum, ynum ): se positioner en un point du dessin
LINETO(xnum, ynum ): tracer une droite depuis un point jusqu'à un autre en (xnum, ynum )
ARCTO(xnum, ynum, xradius, yradius, angle ): tracé d'arc de cercle
ARCTO(xnum, ynum, radius ): tracé d'arc de cercle
CURVETO(xnum, ynum, CF::Continuous): tracé d'arc de cercle
CURVETO(xnum, ynum, xctrl1, yctrl1 ) : tracé d'arc de cercle
CURVETO(xnum, ynum, xctrl2, yctrl2, CF::Continuous) : tracé d'arc de cercle
CURVETO(xnum, ynum, xctrl1, yctrl1, xctrl2, yctrl2 ) : tracé d'arc de cercle
CLOSEPOLY() / CLOSEPOLY(CF::Align): fermeture d'une courbe en partant du dernier point au point initial.
Toutes ces instructions en xxxTO ont leur équivalent en xxxREL ou la position du dernier point est alors relative à celle du premier point.
En ce qui concerne
STROKE [adjustments ]
STROKE(stroke flags) [adjustments ]
CF::IsoWidth, CF::ButtCap, etc.
FILL [adjustments ]
FILL(fill flags) [adjustments ]
CF::EvenOdd
VI - Expressions
Opérateurs mathématiques
( ) parenthèses
^ puissance
-, ! négation, booléen not
*, / multiplication et division
+, - addition et soustraction
-- retourne le résultat de la soustraction s'il est positif et 0 sinon
+-, ±, .., … intervalles aléatoires
<, >, <=, ≤, >=, ≥, <>, ≠ comparaison
&&, ||, ^^ booléen
Fonctions mathématiques
sin, cos, tan, cot, en degrés
asin, acos, atan, acot, retourne des degrés
sinh, cosh, tanh, asinh, acosh, atanh
log, log10, sqrt, exp, abs, floor,
atan2(y, x), mod(x, y), divides(x, y), div(x, y),
infinity, factorial, sg,
rand_static(), rand_static(x), rand_static(x, y),
rand(), rand(x), rand(x, y),
randint(), randint(x), randint(x, y),
min(exp0, exp1, exp2, …),
max(exp0, exp1, exp2, …),
ftime, frame
VII - Boucles
Forme 1
loop val [adjustements]
{
Instructions
}
Répète val fois les instructions instructions en ajustant à chaque fois (adjustements) des paramètres de formes et de couleurs.
Exemple
shape maForme{
loop 10 [x 0.1 hue 20]
{
CIRCLE[sat 0.5 b 0.5]
}
}
Dessine des cercles décalés et de couleurs différentes qui se superposent.
Forme 2
loop var=val [adjustements]
{
Instructions
}
Répète val fois les instructions instructions en ajustant à chaque fois des paramètres de formes et de couleurs. La valeur est ici attribuée à une variable var dont on peut se servir dans instructions.
Exemple
shape maForme{
loop i=10 [x 0.1 hue 20]
{
CIRCLE[sat i b 0.5]
}
}
Cet exemple dessine des cercles de couleurs décalés qui se superposent en modifiant la saturation selon l'index i.
Forme 3
loop val [adjustements]
{
Instruction1
}
finally
{
Instruction2
}
ou
loop var=val [adjustements]
{
instructions1
}
finally
{
instructions2
}
Répète instructions1 et finalement 1 fois instructions2
"val" peut s'écrire sous plusieurs formes. Cela peut être un nombre et la boucle se répète autant de fois que ce nombre. Cela peut être sous la forme "valeur de départ, valeur d'arrivée" ou encore sous la forme "valeur de départ, valeur d'arrivée, pas". Dans ce dernier cas la boucle compte depuis la valeur de départ à la valeur d'arrivée de pas en pas. Par exemple "i=2,10,2" prend les valeurs i=2, 4, 6, 8, 10. S'il n'y a qu'une seule instruction, on n'est pas obligé de mettre des accolades. Ainsi
shape maForme{
loop 10 [x 0.1 hue 20]
CIRCLE[sat 0.5 b 0.5]
}
fonctionne aussi et répète 10 fois l'instruction CIRCLE en ajustant chaque fois sa position et sa couleur.
VIII - Conditions
Forme 1
if (condition) then
{
instruction1
}
else
{
instruction2
}
Si condition est respectée alors les instruction1 sont exécutées sinon ce sont les instruction2 . S'il n'y a pas de "sinon" on peut aussi écrire
if (condition) then
{
instruction1
}
On peut aussi écrire
if (cond, true_exp, false_exp)
Evalue cond et retourne true_exp si cond ≠ 0 et false_exp si cond=0.
Forme 1
Une autre manière d'écrire des conditions est
switch (expression) {
case const-case-expression1: case-body1
case const-case-expression2: case-body2
case const-case-expression3: case-body3
case const-case-expression4: case-body4
…
else: else-body
}
switch évalue expression et compare le résultat au const-case-expression. Si l'un de ces cas correspond à ce qui a été évalué pour expression, il exécute l'instruction case-body correspondante. S'il n'en trouve aucun, il exécute les instructions après else
Forme 3
select(n, expr0, expr1, expr2, expr3,…)
Evalue n et retourne expr0 si n<1, expr1 si 1<n<2, expr2 si 2<n<3, etc. Les expr peuvent être des expressions numériques, des ajustements de forme, des spécifications de forme, etc. Ils doivent tous être du même type.
Forme 4
let(var1=expr1; var2=expr2; … ; expression)
Evalue les expr et les associe au var. Alors expression est évalué dans le contexte des variables liées et retourne sa valeur. Une fois var1 calculé, il peut être utilisé, par exemple, dans expr2.
IX - Transform
transform prend une liste d'ajustements qu'il applique à une forme définie dans le corps de la fonction transform
Exemple
startshape box
path box {
MOVETO( 0.5, 0.5)
LINETO(-0.5, 0.5)
LINETO(-0.5, -0.5)
LINETO( 0.5, -0.5)
CLOSEPOLY()
transform [s 0.5 x 0.1] {
MOVETO(0.25, sqrt(3)/4)
loop 5 [r -60]
LINETO(0.5, 0)
CLOSEPOLY()
}
}
X - Définition des variables
Une variable s'écrit comme
maVariable = maValeur
où maValeur peut être un nombre
shape maForme{
maVariable = 0.5
SQUARE[sat 0.5 b maVariable]
}
une forme
shape maForme{
maVariable = SQUARE
maVariable[sat 0.5 b 0.5]
}
un ajustement
shape maForme{
maVariable = [[sat 0.5 b 0.5]]
SQUARE[transform maVariable]
}
Notez dans ce dernier cas, l'utilisation de l'instruction transform. La valeur d'une variable ne peut pas être changée une fois qu'elle a été définie.
XI - Expression
Variables aléatoires
x .. y ou x … y retourne un nombre aléatoire entre [x,y)
x +- y or x ± y retourne un nombre aléatoire entre [x-y,x+y)
Symboles unicode
≤, ≥, ≠, ∞ (infini), π (3.1415926535)
Fonctions entières
div(x, y) retourne la division entière de x par y
divides(x, y) retourne 1 si x est divisible par y et 0 sinon
factorial(n) vaux 1x2x3…xn
floor(x) arrondit x à l'entier le plus petit
isNatural(x) retourne 1 si x est un entier naturel
sg(x) retourne 0 si x=0 ou 1 sinon
Fonctions binaires
bitnot(x) inverse binaire de x
bitand(x, y) fonction logique AND
bitor(x, y) fonction logique OR
bitxor(x, y) fonction logique XOR
bitleft(x, y) décalage vers la gauche de x de y bits
bitright(x, y) décalage vers la droite de x de y bits
Fonctions diverses
infinity() est l'infini ∞
infinity(x) renvoie ∞ si x ≥0 ou -∞ si x<0
max(x0, x1, x2, …) retourne le plus grand élément de la liste
min(x0, x1, x2, …) retourne le plus petit élément de la liste
Fonctions aléatoires
rand_static() retourne un nombre statique (lorsque le fichier est compilé) aléatoire dans l'intervalle [0,1) avec une distribution uniforme
rand_static(x) retourne un nombre statique (lorsque le fichier est compilé) aléatoire dans l'intervalle [0,x) si x>0 ou [x,0) si x < 0, avec une distribution uniforme
rand()/rand(x)/rand(x,y) retourne un nombre aléatoire dans les mêmes intervalles que les rand_static
rand::normal(mean, stddev): retourne un nombre aléatoire selon une distribution normale (ou gausienne)
rand::lognormal(mean, stddev): retourne un nombre aléatoire selon une distribution aléatoire log-normale
rand:: exponential(rate): retourne un nombre aléatoire selon une distribution de probabilité exponentielle.
rand::gamma(alpha_shape, beta_scale): retourne un nombre aléatoire selon la distribution aléatoire gamma.
rand::weibull(alpha_shape, beta_scale): retourne un nombre aléatoire selon la distribution aléatoire weibull.
rand::extremeV(location, scale): retourne un nombre aléatoire selon la distribution aléatoire de la valeur extrême.
rand::chisquared(degree_freedom): retourne un nombre aléatoire selon la distribution aléatoire en chi carré.
rand::cauchy(location, scale): retourne un nombre aléatoire selon la distribution aléatoire de Cauchy.
rand::fisherF(m_degree_freedom, n_degree_freedom): retourne un nombre aléatoire selon la distribution de Fishers F-.
rand::studentT(degree_freedom): retourne un nombre aléatoire selon la T-distribution de Student.
randint()/randint(x)/randint(x, y):: retourne un entier aléatoire dans le même intervalle que les rand_static.
randint::bernoulli(probability): retourne un booléen aléatoire avec une probabilité spécifiée d'être vraie.
randint::binomial(trials, probability): retourne un entier positif selon une distribution binomiale.
randint::negbinomial(trial_failures, probability): retourne un entier positif selon une distribution binomiale négative.
randint::geometric(probability): retourne un entier positif qui représente le nombre d'essai oui/non nécessaire pour obtenir un unique succès.
randint::poisson(mean): retourne un entier positif selon une distribution de Poisson.
randint::discrete(weight_0, weight_1, … , weight_n): retourne un nombre aléatoire dans l'intervalle [0,n] ou chaque valeur i se trouve avec une probabilité selon le poids weight_i.
Context Free Art in brief
I - Basic instructions
startshape
Indicates which shape is used as the starting point of a generated image. If there are several startshape instructions then only the first one is taken into account.
Example
startshape myShape
shape myShape{
SQUARE[]
}
import
Imports the content of the specified file after the import instruction. The quotation marks are optional for file names unless you need to specify a directory, or the name contains a space or does not end in '.cdfg'. The content can also be inserted into a different namespace.
Examples
import@font alfreebet.cfdg
import "lib/alien eyes.cfdg"
Background colour
Changes the background colour, which by default is solid white. If several backgrounds are specified, then only the first one is taken into account.
Example
CF::Background = [a -1] # transparent background
Background size
Sets the canvas dimensions rather than letting them vary dynamically with the drawing.
Examples
CF::Size = [s 30]
CF::Size = [s 20 30] # rectangular background
Mosaic style
Activates the mosaic tiling and sets the tiling size. If several tiled backgrounds have been specified, then only the first one is taken into account. The tiling can be square, rectangular, tilted or rotated as long as the tiling axis is exactly vertical or horizontal.
Examples
CF::Tile = [s 30]
CF::Tile = [s 20 30] # rectangular tiling
CF::Tile = [s 30 x 15 y 10]
The offset x and y values move the content relative to the tiling. This allows users to centre part of the drawing relative to a tile.
II - Shapes
A shape can be defined from other shapes, for example, a circle in a square, as shown below. There are predefined basic shapes: SQUARE, CIRCLE, TRIANGLE and FILL from which more complex shapes are drawn. Within one shape, the basic shapes are evaluated first, and the others are placed in a list to be drawn after.
Example
shape myShape{
SQUARE []
CIRCLE [b 1]
}
Randomness
A shape can be defined by rules (rule instruction). If there are multiple rules, the rule executed is chosen randomly.
Example
shape myShape
rule { SQUARE[] }
rule { CIRCLE[] }
The rule instruction can be followed by a number that defines the relative probability of the corresponding rule being executed. Thus, in the example below, a circle has a 90.8% chance of being drawn when the myShape shape is executed.
Example
shape myShape
rule {SQUARE[] } # 1/11.01=9.1%
rule 10 {CIRCLE[] } # 10/11.01=90.8%
rule 0.01 {} # 0.01/11.01=0.09%
In the following example, percentages have been attributed directly to the rules except for the first one. The probability of its occurrence will be 100% minus the percentages of the other rules.
shape myShape
rule {SQUARE[] } # 9.9% remainder
rule 90% {CIRCLE[] } # 90%
rule 0.1% {} # 0.1%
III - Adjusting shapes
The status of a shape (position, colour, etc.) is defined in relation to the previously drawn shape. So, in the following example
shape myShape{
SQUARE []
CIRCLE [x 1]
}
a black square is drawn in the centre of the canvas. Then a circle, also black, is shifted along the x axis (horizontally by default) by 100% (x 1) of the size of the previous square. The shape below
shape myShape {
SQUARE []
CIRCLE [x 0.5 b 0.5]
}
corresponds to the drawing of a black square followed by a circle, which is horizontally offset by 50% of the size of the square (x 0.5), and 50% darker (b 0.5), which comes out grey.
The drawings are identified by 3 axes: x (horizontal by default), y (vertical by default) and z (which determines which shape is above the other).
The shape adjustment variables (x, size, etc.) are shown in the table below.
x val : val offset along the x axis
x val1 val2 : val1 and val2 offset along the x and y axes
x va1 val2 val3 : val1, val2, val3 offset along the x, y and z axes
y val : val offset along the y axis
z val : val offset along the z axis
size val or s val : Scaling along the x and y axes of the val value
size val1 val2 or s val1 val2 : Scaling along the x and y axes of values val1 and val2
size val1 val2 val3 or s val1 val2 val3 : Scaling along the x, y, z axes of values val1, val2, val3
rotate val or r val : Rotation of val degrees
flip val or f val : Reflection in relation to a line passing through the origin of the reference point at val degrees
skew val 1 val2 : Shear of val1 and val2 degrees in relation to the x and y axes
time val1 val2 : val1 and val2 offset of birth and death time
timescale val1 : Changing the time scale of val1
There is also a subtle difference in the bracket notation. So in
SQUARE [my adjustments], the adjustments are executed in the order x, y, rotate, size, skew and flip and any duplications are deleted. While in SQUARE [[my adjustments]] the adjustments are applied in the order in which you write them.
IV - Colour adjustment
hue val or h val
Adds val to the hue, ranging from 0 to 360.
saturation val or sat val
val takes a value between 0 and 1. If val<0, change the colour saturation of val% to 0. If val>0, change the saturation of val% to 1.
brightness val or b val
val takes a value between 0 and 1. If val<0, change the brightness of the colour from val% to 0. If val>0, change the brightness of val% to 1.
alpha val to val
val takes a value between 0 and 1. If val<0, the shape becomes more transparent. If val>0, the shape becomes less transparent.
So
shape myShape{
SQUARE []
CIRCLE [x 0.5 hue 240 sat 0.5 b 0.5 a -0.5]
}
draws a square and a circle offset by 50% (x 0.5) from the square, of a bluish colour (hue 240 sat 0.5 b 0.5) and semi-transparent (a -0.5)
V - Paths
You can create new basic shapes with the path instruction.
Example
startshape square
path square{
MOVETO(0.5, 0.5) #initial position
LINETO(-0.5, 0.5) #draws a straight line
LINETO(-0.5, -0.5) #draws a straight line
LINETO(0.5, -0.5) #draws a straight line
CLOSEPOLY() #returns to position (0.5,0.5) and completes the shape
}
draws a black square. The commands for defining new shapes are as follows
MOVETO(xnum, ynum ): moves to a point in the drawing
LINETO(xnum, ynum): draws a straight line from one point to another with (xnum, ynum)
ARCTO(xnum, ynum, xradius, yradius, angle ): draws a circle arc
ARCTO(xnum, ynum, radius ): draws a circle arc
CURVETO(xnum, ynum, CF::Continuous): draws a circle arc
CURVETO(xnum, ynum, xctrl1, yctrl1 ): draws a circle arc
CURVETO(xnum, ynum, xctrl2, yctrl2, CF::Continuous): draws a circle arc
CURVETO(xnum, ynum, xctrl1, yctrl1, xctrl2, yctrl2 ): draws a circle arc
CLOSEPOLY() / CLOSEPOLY(CF::Align): completes a curved shape by connecting the last point to the first point.
All these instructions in the form xxxTO have an equivalent as xxxREL, where the position of the last point is relative to the first point.
For
STROKE [adjustments ]
STROKE(stroke flags) [adjustments ]
CF::IsoWidth, CF::ButtCap, etc.
FILL [adjustments ]
FILL(fill flags) [adjustments ]
CF::EvenOdd
VI - Expressions
Mathematical operators
( ) brackets
^ power
-,! negation, boolean not
*, / multiplication and division
+, - addition and subtraction
- returns the result of the subtraction if it is positive and otherwise 0
+-, ±, .., ... random intervals
<, >, <=, ≤, >=, ≥, <>, ≠ comparison
&&, ||, ^^ boolean
Mathematical functions
sin, cos, tan, cot, degrees
asin, acos, atan, acot, returns degrees
sinh, cosh, tanh, asinh, acosh, atanh
log, log10, sqrt, exp, abs, floor,
atan2(y, x), mod(x, y), divides(x, y), div(x, y),
infinity, factorial, sg,
rand_static(), rand_static(x), rand_static(x, y),
rand(), rand(x), rand(x, y),
randint(), randint(x), randint(x, y),
min(exp0, exp1, exp2, …),
max(exp0, exp1, exp2, …),
ftime, frame
VII - Loops
Shape 1
loop val [adjustments]
{
Instructions
}
Repeats the instructions instructions val times by adjusting the shape and colour settings each time (adjustments).
Example:
shape myShape{
loop 10 [x 0.1 hue 20]
{
CIRCLE[sat 0.5 b 0.5]
}
}
Draw offset circles of different colours that are overlapping.
Shape 2
loop var=val [adjustments]
{
Instructions
}
Repeats the instructions instructions val times by adjusting the shape and colour settings each time. Here the value is assigned to a variable var which can be used in instructions.
Example:
shape myShape{
loop i=10 [x 0.1 hue 20]
{
CIRCLE[sat i b 0.5]
}
}
This example draws offset circles of different colours that overlap, by changing the saturation according to the index i.
Shape 3
loop val [adjustments]
{
Instruction1
}
finally
{
Instruction2
}
or
loop var=val [adjustments]
{
instructions1
}
finally
{
instructions2
}
Repeat instructions1 and finally instructions2 once
"val" can be written in several ways. It can be a number and the loop is repeated as many times as this number. It can be in the form of "start value, end value" or in the form "start value, end value, step". In this case, the loop counts from the start value to the end value, from step to step. For example "i = 2,10,2" takes the values i = 2, 4, 6, 8, 10. If there is only one instruction, you do not have to add curly brackets. So
shape myShape{
loop 10 [x 0.1 hue 20]
CIRCLE[sat 0.5 b 0.5]
}
also works and repeats the CIRCLE instruction 10 times, adjusting its position and colour each time.
VIII - Conditions
Shape 1
if (condition) then
{
instruction1
}
else
{
instruction2
}
If condition applies then the instructions1 are executed, if not instructions2 are executed. If there is no "else" we can also write
if (condition) then
{
instruction1
}
We can also write
if (cond, true_exp, false_exp)
Evaluate cond and return true_exp if cond ≠ 0 and false_exp if cond = 0.
Shape 1
Another way of writing conditions is
switch (expression) {
case const-case-expression1: case-body1
case const-case-expression2: case-body2
case const-case-expression3: case-body3
case const-case-expression4: case-body4
etc.
else: else-body
}
switch evaluates expression and compares the result to const-case-expression. If one of these cases matches what has been evaluated for expression, it executes the corresponding case-body instruction. If it doesn't find one, it executes the instructions after else
Shape 3
select (n, expr0, expr1, expr2, expr3, etc.)
Evaluates n and returns expr0 if n <1, expr1 if 1 <n <2, expr2 if 2 <n <3, and so on. The expr commands can be numeric expressions, shape adjustments, shape specifications, etc. They must all be of the same type.
Shape 4
let(var1=expr1; var2=expr2; … ; expression)
Evaluates the expr commands and associates them with the var commands. Then expression is evaluated in the context of the linked variables and returns its value. Once var1 has been calculated, it can be used, for example, in expr2.
IX - Transform
transform takes a list of adjustments that it applies to a shape defined in the body of the transform function
Example
startshape box
path box {
MOVETO(0.5, 0.5)
LINETO(-0.5, 0.5)
LINETO(-0.5, -0.5)
LINETO( 0.5, -0.5)
CLOSEPOLY()
transform [s 0.5 x 0.1] {
MOVETO(0.25, sqrt(3)/4)
loop 5 [r -60]
LINETO(0.5, 0)
CLOSEPOLY()
}
}
X - Definition of variables
A variable is written as
myVariable = myValue
where myValue can be a number
shape myShape{
myVariable = 0.5
SQUARE[sat 0.5 b myVariable]
}
a shape
shape myShape{
myVariable = SQUARE
myVariable[sat 0.5 b 0.5]
}
an adjustment
shape myShape{
myVariable = [[sat 0.5 b 0.5]]
SQUARE[transform myVariable]
}
Note the use of the transform instruction in the last case. The value of a variable cannot be changed once it has been defined.
XI - Expression
Random variables
x .. y or x … y returns a random number between [x, y)
x +- y or x ± y returns a random number between [x-y, x + y)
Unicode symbols
≤, ≥, ≠, ∞ (infinity), π (3.1415926535)
Integral functions
div(x, y) returns the integral division of x by y
divides(x, y) returns 1 if x is divisible by y and otherwise 0
factorial(n) equals 1x2x3 ... xn
floor(x) rounds x up or down to the smallest integer
isNatural(x) returns 1 if x is a natural integer
sg(x) returns 0 if x = 0 or otherwise 1
Binary functions
bitnot(x) binary inverse of x
bitand(x, y) logic function AND
bitor(x, y) logic function OR
bitxor(x, y) logic function XOR
bitleft(x, y) offset to the left by x of y bits
bitright(x, y) offset to the right by x of y bits
Various functions
infinity() is infinity ∞
infinity(x) returns ∞ if x≥0 or -∞ if x<0
max (x0, x1, x2, etc.) returns the highest number in the list
min (x0, x1, x2, etc.) returns the lowest number in the list
Random functions
rand_static() returns a random static number (when the file is compiled) in the interval [0,1] with uniform distribution
rand_static(x) returns a random static number (when the file is compiled) in the interval [0, x) if x>0 or [x,0) if x<0, with uniform distribution
rand()/rand(x)/rand(x, y) returns a random number in the same intervals as rand_static
rand::normal(mean, stddev): returns a random number based on normal (or Gaussian) distribution
rand::lognormal(mean, stddev): returns a random number based on log-normal random distribution
rand::exponential(rate): returns a random number based on exponential probability distribution.
rand::gamma(alpha_shape, beta_scale): returns a random number based on gamma random distribution.
rand::weibull(alpha_shape, beta_scale): returns a random number based on weibull random distribution.
rand::extremeV(location, scale): returns a random number based on random distribution of the extreme value.
rand::chisquared(degree_freedom): returns a random number based on chi-square random distribution.
rand::cauchy(location, scale): returns a random number based on Cauchy random distribution.
rand::fisherF(m_degree_freedom, n_degree_freedom): returns a random number based on Fishers F- distribution.
rand::studentT(degree_freedom): returns a random number based on Student's T-distribution.
randint()/randint(x)/randint(x, y):: returns a random integer in the same interval as rand_static.
randint::bernoulli(probability): returns a random boolean number with a specified probability of being true.
randint::binomial(trials, probability): returns a positive integer based on binomial distribution.
randint::negbinomial(trial_failures, probability): returns a positive integer based on negative binomial distribution.
randint::geometric(probability): returns a positive integer that represents the number of yes/no attempts needed to achieve a single success.
randint::fish(mean): returns a positive integer based on Poisson distribution.
randint::discrete(weight_0, weight_1, etc., weight_n): returns a random number in the interval [0, n] where each value i is found with a probability based on weight_i.
Context Free Art in breve
I - Istruzioni di base
startshape
Indica la forma che viene utilizzata come punto di partenza di un'immagine generata. In presenza di più istruzioni startshape,viene considerata solo la prima.
Esempio
startshape miaForma
shape miaForma{
SQUARE[]
}
import
Importa il contenuto del file specificato dopo l'istruzione import. Le virgolette nei nomi dei file sono facoltative, a meno che non si debba specificare una directory, il nome non contenga uno spazio o non termini con ".cdfg". Il contenuto può essere inserito anche in uno spazio di nome (namespace) diverso.
Esempi
import@font alfreebet.cfdg
import "lib/alien eyes.cfdg"
Colore dello sfondo
Modifica il colore dello sfondo che, per impostazione predefinita, è bianco opaco. Se ci sono più sfondi specificati, viene considerato solo il primo.
Esempio
CF::Background = [a -1] # sfondo trasparente
Dimensioni dello sfondo
Definisce le dimensioni fisse della tela, impedendo loro di variare in modo dinamico con il disegno.
Esempi
CF::Size = [s 30]
CF::Size = [s 20 30] # sfondo rettangolare
Aspetto a mosaico
Attiva l'aspetto a mosaico e definisce le dimensioni della pavimentazione. Se ci sono più tipi di pavimentazione specificati, viene considerato solo il primo. La pavimentazione può essere quadrata, rettangolare, inclinata o ruotata se l'asse della pavimentazione è perfettamente verticale o orizzontale.
Esempi
CF::Tile = [s 30]
CF::Tile = [s 20 30] # pavimentazione rettangolare
CF::Tile = [s 30 x 15 y 10]
Il divario tra x e y sposta il contenuto in rapporto alla pavimentazione, consentendo all'utente di centrare una parte del disegno rispetto alla pavimentazione.
II - Forme
Una forma può essere definita a partire da altre forme. Di seguito, ad esempio, un cerchio viene definito all'interno di un quadrato. Esistono forme di base predefinite, come SQUARE, CIRCLE, TRIANGLE o FILL a partire dalle quali è possibile realizzare forme più complesse. In una forma sono presenti le forme di base che vengono valutate in un primo momento, mentre le altre vengono disposte in un elenco per essere poi disegnate in seguito.
Esempio
shape miaForma{
SQUARE []
CIRCLE [b 1]
}
Comportamenti aleatori
Una forma può essere definita da regole (istruzione rule). In presenza di più regole, la regola eseguita viene scelta a caso.
Esempio
shape miaForma
rule { SQUARE[] }
rule { CIRCLE[] }
L'istruzione rule può essere seguita da un numero che stabilisce la probabilità relativa perché la regola corrispondente venga eseguita. Così, nell'esempio che segue, un cerchio ha il 90,8% di probabilità di essere disegnato durante l'esecuzione della forma miaForma.
Esempio
shape miaForma
rule {SQUARE[] } # 1/11,01=9,1%
rule 10 {CIRCLE[] } # 10/11,01=90,8%
rule 0,01 {} # 0,01/11,01=0,09%
Nel seguente esempio, sono state attribuite direttamente delle percentuali alle regole tranne alla prima, pertanto la probabilità di riproduzione di quest'ultima corrisponderà al 100% meno le percentuali assegnate alle altre regole.
shape miaForma
rule {SQUARE[] } # 9,9% restante
rule 90% {CIRCLE[] } # 90%
rule 0,1% {} # 0,1%
III - Regolazione delle forme
Lo stato di una forma (posizione, colore, ecc.) viene definito in rapporto alla forma precedentemente disegnata. Così, nell'esempio seguente
shape miaForma{
SQUARE []
CIRCLE [x 1]
}
viene disegnato un quadrato nero al centro della tela. Poi un cerchio nero viene spostato lungo l'asse x (orizzontalmente, per impostazione predefinita) del 100% (x 1) rispetto alle dimensioni del quadrato precedente. La forma seguente
shape miaForma {
SQUARE []
CIRCLE [x 0,5 b 0,5]
}
corrisponde al disegno di un quadrato nero seguito da un cerchio spostato orizzontalmente del 50% rispetto alle dimensioni del quadrato (x 0,5) e 50% meno brillante (b 0,5), ovvero grigio.
I disegni vengono eseguiti su 3 assi: x (orizzontale per impostazione predefinita), y (verticale per impostazione predefinita) e z (che determina quale forma si trova al di sopra dell'altra).
Le variabili di regolazione delle forme (x, size, ecc,) sono indicate nella tabella seguente.
x val : Spostamento val lungo l'asse x
x val1 val2 : Spostamento val1 e val2 lungo gli assi x e y
x va1 val2 val3 : Spostamento val1, val2, val3 lungo gli assi x, y e z
y val : Spostamento val lungo l'asse y
z val : Spostamento val lungo l'asse z
size val o s val : In scala rispetto agli assi x e y del valore val
size val1 val2 o s val1 val2 : In scala rispetto agli assi x e y dei valori val1 e val2
size val1 val2 val3 o s val1 val2 val3 : In scala rispetto agli assi x, y, z dei valori val1, val2, val3
rotate val o r val : Rotazione di val gradi
flip val o f val : Riflessione rispetto a una linea passante per l'origine del punto di riferimento a val gradi
skew val1 val2 : Taglio di val1 e val2 gradi in rapporto agli assi x e y
time val1 val2 : Intervallo di val1 e val2 tra il momento di origine e di termine
timescale val1 : Modifica di scala temporale di val1
Inoltre, nella nota tra parentesi quadre è presente una lieve differenza. Ad esempio, in
SQUARE [mie regolazioni], le regolazioni vengono eseguite nell'ordine x, y, rotate, size, skew e flip e i valori duplicati vengono eliminati. Mentre in SQUARE [[mie regolazioni]], le regolazioni vengono applicate nell'ordine in cui vengono scritte.
IV - Regolazione dei colori
hue val o h val
Aggiunge val alla tinta (hue), val è compreso tra 0 e 360.
saturation val o sat val
val assume un valore compreso tra 0 e 1. Se val<0, la saturazione del colore di val% varia verso 0. Se val>0, la saturazione di val% varia verso 1.
brightness val o b val
val assume un valore compreso tra 0 e 1. Se val<0, la luminosità del colore di val% varia verso 0. Se val>0, la luminosità di val% varia verso 1.
alpha val a val
val assume un valore compreso tra 0 e 1. Se val<0, la forma diventa più trasparente. Se val>0, la trasparenza della forma diminuisce.
Così
shape miaForma{
SQUARE []
CIRCLE [x 0,5 hue 240 sat 0,5 b 0,5 a -0,5]
}
disegna un quadrato e un cerchio spostato del 50% (x 0,5) rispetto al cerchio, di colore azzurrino (hue 240 sat 0,5 b 0,5) e semi trasparente (a -0,5)
V - Percorsi
L'istruzione path consente di realizzare nuove forme di base.
Esempio
startshape quadrato
path quadrato{
MOVETO(0,5, 0,5) #posizione iniziale
LINETO(-0,5, 0,5) #traccia una retta
LINETO(-0,5, -0,5) #traccia una retta
LINETO(0,5, -0,5) #traccia una retta
CLOSEPOLY() #torna in posizione (0,5, 0,5) e richiude la linea
}
disegna un quadrato nero. I comandi per definire nuove forme sono i seguenti
MOVETO(xnum, ynum): posizionarsi in un punto del disegno
LINETO(xnum, ynum): tracciare una retta da un punto a un altro in (xnum, ynum)
ARCTO(xnum, ynum, xradius, yradius, angle): tracciato in semicerchio
ARCTO(xnum, ynum, radius): tracciato in semicerchio
CURVETO(xnum, ynum, CF::Continuous): tracciato in semicerchio
CURVETO(xnum, ynum, xctrl1, yctrl1): tracciato in semicerchio
CURVETO(xnum, ynum, xctrl2, yctrl2, CF::Continuous): tracciato in semicerchio
CURVETO(xnum, ynum, xctrl1, yctrl1, xctrl2, yctrl2): tracciato in semicerchio
CLOSEPOLY() / CLOSEPOLY(CF::Align): chiusura di una curva partendo dall'ultimo punto al punto iniziale.
Tutte queste istruzioni in xxxTO trovano il loro equivalente in xxxREL oppure la posizione dell'ultimo punto è relativa a quella del primo punto.
Per quanto riguarda
STROKE [regolazioni]
STROKE(stroke flags) [regolazioni]
CF::IsoWidth, CF::ButtCap, ecc.
FILL [regolazioni]
FILL(fill flags) [regolazioni]
CF::EvenOdd
VI - Espressioni
Operatori matematici
( ) parentesi
^ potenza
-, ! negativo, valore booleano not
*, / moltiplicazione e divisione
+, - addizione e sottrazione
-- restituisce il risultato della sottrazione se è positivo e 0 in caso contrario
+-, ±, .., … intervalli casuali
<, >, <=, ≤, >=, ≥, <>, ≠ paragone
&&, ||, ^^ valori booleani
Funzioni matematiche
sin, cos, tan, cot, in gradi
asin, acos, atan, acot, risultato in gradi
sinh, cosh, tanh, asinh, acosh, atanh
log, log10, sqrt, exp, abs, floor,
atan2(y, x), mod(x, y), divides(x, y), div(x, y),
infinity, factorial, sg,
rand_static(), rand_static(x), rand_static(x, y),
rand(), rand(x), rand(x, y),
randint(), randint(x), randint(x, y),
min(exp0, exp1, exp2,…),
max(exp0, exp1, exp2,…),
ftime, frame
VII - Anelli
Forma 1
loop val [regolazioni]
{
Istruzioni
}
Ripete val volte le istruzioni istruzioni, regolando di volta in volta (regolazioni) i parametri di forme e colori.
Esempio:
shape miaForma{
loop 10 [x 0,1 hue 20]
{
CIRCLE[sat 0,5 b 0,5]
}
}
Disegna dei cerchi concentrici di colori diversi che si sovrappongono.
Forma 2
loop var=val [regolazioni]
{
Istruzioni
}
Ripete val volte le istruzioni istruzioni, regolando di volta in volta i parametri di forme e colori. Il valore qui è assegnato a una variabile var che può essere utilizzata nelle istruzioni.
Esempio:
shape miaForma{
loop i=10 [x 0,1 hue 20]
{
CIRCLE[sat i b 0,5]
}
}
In questo esempio vengono disegnati cerchi di colori sfumati che si sovrappongono modificando la saturazione in base all'indice i.
Forma 3
loop val [regolazioni]
{
Istruzione1
}
finally
{
Istruzione2
}
o
loop var=val [regolazioni]
{
istruzioni1
}
finally
{
istruzioni2
}
Ripete istruzioni1 e alla fine 1 volta sola istruzioni2
È possibile scrivere "val" in vari modi. Può essere un numero, indicando così le volte in cui si ripete il cerchio. Può essere un "valore di partenza, valore di arrivo" o ancora "valore di partenza, valore di arrivo, incremento". In tal caso, il cerchio parte dal valore di partenza e finisce nel valore di arrivo, tramite gli incrementi indicati. Ad esempio "i=2,10,2" prende i valori i=2, 4, 6, 8, 10. In presenza di una sola istruzione, non è obbligatorio inserire delle parentesi graffe. Così
shape miaForma{
loop 10 [x 0,1 hue 20]
CIRCLE[sat 0,5 b 0,5]
}
funziona in egual modo e ripete 10 volte l'istruzione CIRCLE regolando ogni volta la posizione e il colore.
VIII - Condizioni
Forma 1
if (condizione) then
{
istruzione1
}
else
{
istruzione2
}
Se condizione viene rispettata, viene eseguita istruzione1, in caso contrario istruzione2. In mancanza di "in caso contrario", è possibile anche scrivere
if (condizione) then
{
istruzione1
}
È inoltre possibile scrivere
if (cond, true_exp, false_exp)
Valuta cond e restituisce true_exp se cond ≠ 0 e false_exp se cond=0.
Forma 1
Le condizioni possono essere scritte anche in un altro modo
switch (espressione) {
case const-case-expression1: case-body1
case const-case-expression2: case-body2
case const-case-expression3: case-body3
case const-case-expression4: case-body4
…
else: else-body
}
switch valuta espressione e confronta il risultato con const-case-expression. Se uno qualsiasi di questi casi corrisponde a ciò che è stato valutato per espressione, esegue la corrispondente istruzione case-body. In assenza di corrispondenza, esegue le istruzioni dopo else
Forma 3
select(n, expr0, expr1, expr2, expr3,…)
Valuta n e restituisce expr0 se n<1, expr1 se 1<n<2, expr2 se 2<n<3, ecc. expr possono essere espressioni numeriche, regolazioni di forma, specifiche di forma, ecc. Devono essere tutte dello stesso tipo.
Forma 4
let(var1=expr1; var2=expr2; … ; expression)
Valuta expr e le associa a var. expression viene quindi valutata nel contesto delle variabili correlate e restituisce il suo valore. Dopo aver calcolato var1, questo può essere utilizzato, ad esempio, in expr2.
IX - Transform
transform prende un elenco di regolazioni che applica a una forma definita nel corpo della funzione transform
Esempio
startshape box
path box {
MOVETO(0,5, 0,5)
LINETO(-0,5, 0,5)
LINETO(-0,5, -0,5)
LINETO(0,5, -0,5)
CLOSEPOLY()
transform [s 0,5 x 0,1] {
MOVETO(0,25, sqrt(3)/4)
loop 5 [r -60]
LINETO(0,5, 0)
CLOSEPOLY()
}
}
X - Definizione delle variabili
Una variabile può essere scritta come
miaVariabile = mioValore
dove mioValore può essere un numero
shape miaForma{
miaVariabile = 0,5
SQUARE[sat 0,5 b miaVariabile]
}
una forma
shape miaForma{
miaVariabile = SQUARE
miaVariabile[sat 0,5 b 0,5]
}
una regolazione
shape miaForma{
miaVariabile = [[sat 0,5 b 0,5]]
SQUARE[transform miaVariabile]
}
Notare l'utilizzo dell'istruzione transform in quest'ultimo caso. Il valore di una variabile non può essere modificato una volta impostato.
XI - Espressione
Variabili aleatorie
x .. y o x … y restituisce un numero casuale tra [x,y)
x +- y o x ± y restituisce un numero casuale tra [x-y,x+y)
Simboli Unicode
≤, ≥, ≠, ∞ (infinito), π (3,1415926535)
Funzioni intere
div(x, y) restituisce la divisione intera di x per y
divides(x, y) restituisce 1 se x è divisibile per y e 0 in caso contrario
factorial(n) vale 1x2x3…xn
floor(x) arrotonda x all'intero minore
isNatural(x) restituisce 1 se x è un intero naturale
sg(x) restituisce 0 se x=0 o 1 in caso contrario
Funzioni binarie
bitnot(x) binario inverso di x
bitand(x, y) funzione logica AND
bitor(x, y) funzione logica OR
bitxor(x, y) funzione logica XOR
bitleft(x, y) spostamento verso sinistra di x di y bit
bitright(x, y) spostamento verso destra di x di y bit
Funzioni diverse
infinity() è il simbolo dell'infinito ∞
infinity(x) rinvia ∞ se x ≥0 o -∞ se x<0
max(x0, x1, x2, …) restituisce l'elemento più grande dell'elenco
min(x0, x1, x2, …) restituisce l'elemento più piccolo dell'elenco
Funzioni aleatorie
rand_static() restituisce un numero statico (quando il file viene compilato) casuale compreso nell'intervallo [0,1) con una distribuzione uniforme
rand_static(x) restituisce un numero statico (quando il file viene compilato) casuale compreso nell'intervallo [0,x) se x>0 o [x,0) se x < 0, con una distribuzione uniforme
rand()/rand(x)/rand(x,y) restituisce un numero casuale compreso negli stessi intervalli di rand_static
rand::normal(mean, stddev): restituisce un numero casuale in base a una distribuzione normale (o di Gauss)
rand::normal(mean, stddev): restituisce un numero casuale in base a una distribuzione causale log-normale
rand:: exponential(rate): restituisce un numero causale in base a una distribuzione di probabilità esponenziale.
rand::gamma(alpha_shape, beta_scale): restituisce un numero casuale in base alla distribuzione casuale Gamma.
rand::weibull(alpha_shape, beta_scale): restituisce un numero casuale in base alla distribuzione casuale di Weibull.
rand::extremeV(location, scale): restituisce un numero casuale in base alla distribuzione casuale del valore estremo.
rand::chisquared(degree_freedom): restituisce un numero casuale in base alla distribuzione casuale chi quadrato.
rand::cauchy(location, scale): restituisce un numero casuale in base alla distribuzione casuale di Cauchy.
rand::fisherF(m_degree_freedom, n_degree_freedom): restituisce un numero casuale in base alla distribuzione di Fisher-Snedecor.
rand::studentT(degree_freedom): restituisce un numero casuale in base alla distribuzione t di Student.
randint()/randint(x)/randint(x, y):: restituisce un numero intero casuale compreso nello stesso intervallo di rand_static.
randint::bernoulli(probability): restituisce un valore booleano casuale con una probabilità specificata di costituire un valore vero.
randint::binomial(trials, probability): restituisce un valore intero positivo in base a una distribuzione binomiale.
randint::negbinomial(trial_failures, probability): restituisce un valore intero positivo in base a una distribuzione binomiale negativa.
randint::geometric(probability): restituisce un numero intero positivo che rappresenta il numero di prova sì/no necessario per ottenere un successo unico.
randint::poisson(mean): restituisce un numero intero positivo in base alla distribuzione di Poisson.
randint::discrete(weight_0, weight_1, … , weight_n): restituisce un numero casuale compreso nell'intervallo [0,n] oppure ogni valore i si trova con una probabilità in base al peso weight_i.
Vincent Blech, commissaire de l'exposition
Stéphane Fay, contenus scientifiques
Laurent Viennot, Inria
Conception, graphisme: Fleur de papier
Développement: Fleur de papier + Ben & Lou
Charte graphique: Villar + Vera
Traduction: Alpha
© EPPDCSI 2017
La communauté de Context Free Art
Avec le soutien des donateurs de la campagne de financement participation
La machine qui dessine en codant
Ce site internet a été créé pour être consulté sur un ordinateur
avec les versions récentes des navigateurs chrome ou firefox.
© EPPDCSI 2017