Hamming Quilt
Renders a Hamming Quilt.
Code
Configuration
Configuration.AddSlider("_r", "Red", "", 0, 255, 136);
Configuration.AddSlider("_g", "Green", "", 0, 255, 86);
Configuration.AddSlider("_b", "Blue", "", 0, 255, 167);
Configuration.AddSlider("_a", "Alpha", "", 0, 255, 255);
Execution
function hamming(a, b) {
var distance = 0,
v = a ^ b;
while (v) {
distance++;
v &= v - 1;
}
return distance;
}
var image = Document.RasterImage;
var sizeX = image.sizeX;
var sizeY = image.sizeY;
var scaleTo = Math.ceil(Math.log(Math.max(sizeX, sizeY)) / Math.LN2);
for (x=0,xEnd=sizeX; x<xEnd; x++){
for (y=0,yEnd=sizeY; y<yEnd; y++){
var d = 1 - (hamming(x, y) / scaleTo);
var r = d * Configuration._r;
var g = d * Configuration._g;
var b = d * Configuration._b;
c=(Configuration._a << 24) | // alpha
(r << 16) | // red
(g << 8) | // green
b; // blue
image.SetPixel(x, y, 0, 0, c);
}
}
Find out how Vista icons differ from XP icons.
See how RealWorld Icon Editor handles Vista icons.