It presents a wide range of different generative algorithms; from organic flow fields and particle systems to rigid fractals and grammar-based shapes.
Génération procédural. C'est juste hallucinant !
L’algorithme de tracé de cercle d'Andres1 permet, pour une complexité algorithmique très réduite, de tracer des cercles en image matricielle. Cet algorithme permet de paver entièrement le plan par des cercles concentriques, sans les trous que laisse par exemple l'algorithme de tracé d'arc de cercle de Bresenham.
JavaScript
Implementation that draws a circle in HTML5 canvas (for educational purposes only; there are better ways to draw circles in canvas).
const CHANNELS_PER_PIXEL = 4; //rgba
function drawCircle (x0, y0, radius, canvas) {
var x = radius-1;
var y = 0;
var dx = 1;
var dy = 1;
var diameter = radius * 2;
var decisionOver2 = dx - diameter; // Decision criterion divided by 2 evaluated at x=r, y=0
var imageWidth = canvas.width;
var imageHeight = canvas.height;
var context = canvas.getContext('2d');
var imageData = context.getImageData(0, 0, imageWidth, imageHeight);
var pixelData = imageData.data;
var makePixelIndexer = function (width) {
return function (i, j) {
var index = CHANNELS_PER_PIXEL * (j * width + i);
//index points to the Red channel of pixel
//at column i and row j calculated from top left
return index;
};
};
var pixelIndexer = makePixelIndexer(imageWidth);
var drawPixel = function (x, y) {
var idx = pixelIndexer(x,y);
pixelData[idx] = 255; //red
pixelData[idx + 1] = 0; //green
pixelData[idx + 2] = 255;//blue
pixelData[idx + 3] = 255;//alpha
};
while (x >= y) {
drawPixel(x + x0, y + y0);
drawPixel(y + x0, x + y0);
drawPixel(-x + x0, y + y0);
drawPixel(-y + x0, x + y0);
drawPixel(-x + x0, -y + y0);
drawPixel(-y + x0, -x + y0);
drawPixel(x + x0, -y + y0);
drawPixel(y + x0, -x + y0);
if (decisionOver2 <= 0)
{
y++;
decisionOver2 += dy; // Change in decision criterion for y -> y+1
dy += 2;
}
if (decisionOver2 > 0)
{
x--;
dx += 2;
decisionOver2 += (-diameter) + dx; // Change for y -> y+1, x -> x-1
}
}
context.putImageData(imageData, 0, 0);
}
Comparatif des algos du plus court chemin
avec options intéressante :
- Obstacles
- Allow diagonal
- Bi-directional
- A*
- Dijkstra
"In Dungeons of Everchange you take a role of a lonely hero, who tries to descend into unknown depths of twisted mazes of Everchange to kill ultimate tyrant Belphegore. There is no written documentation or maps of survivors who dared to enter the mazes and escaped alive, at least no rumours match what you can found down there. Except one: mazes are always different, walls and corridors change, and utmost horrors of every size and shape lurk in dark, waiting for its next prey. "
RogueBasin : http://www.roguebasin.com/index.php?title=Dungeons_Of_Everchange