OEOE.MOE

[ frontpage ]
about / projects / useful things / not very useful things
page #1 (ptl, dda) page #2 (tri) page #3 (grd, dth) page #4 (3d) page #5 (buf) page #6 (idx) scratches

Gradient slopes .raw
var x0 = 0.4;
var y0 = 0.3;

var x1 = 0.7;
var y1 = 0.5;

var x2 = 0.2;
var y2 = 0.9;

var x3 = x0 + ((y1 - y0) / (y2 - y0)) * (x2 - x0);
var y3 = y1;

var x4 = x2 + ((x1 - x2) / (y1 - y2)) * (y0 - y2);
var y4 = y0;

var x5 = x0;
var y5 = y1 + ((x1 - x0) / (x2 - x1)) * (y1 - y2);

Dithering
var palette = [ 0xFF, 0xDD, 0xBB, 0x99, 0x77, 0x55, 0x33, 0x11 ]; // palette

var ditheringMatrix = [  0, 48, 12, 60,  3, 51, 15, 63,
                        32, 16, 44, 28, 35, 19, 47, 31,
                         8, 56,  4, 52, 11, 59,  7, 55,
                        40, 24, 36, 20, 43, 27, 39, 23,
                         2, 50, 14, 62,  1, 49, 13, 61,
                        34, 18, 46, 30, 33, 17, 45, 29,
                        10, 58,  6, 54,  9, 57,  5, 53,
                        42, 26, 38, 22, 41, 25, 37, 21  ];

var baseColor  = 0;
var colorIndex = baseColor + (ditheringMatrix[(x % 8) + (y % 8) * 8] / 64);
var finalColor = palette[colorIndex];