if you want to see the next demonstration, optimize this code or else!!!Code:/***************************** fuzz ******************************************** This function takes coordinate parameters and fuzzes the graphics display. It his perhaps the slowest of all graphics functions in this program. *******************************************************************************/ vo OUTPUT :: fuzz (un xl, un yl, un xh, un yh) { un *master_buffer; un *r_add_table, *g_add_table, *b_add_table, *div_table; un alloc_size = (yh - yl) * (xh - xl); // allocate the master buffer if ( (master_buffer = (un *) calloc (alloc_size * 4, 4)) == NULL) return; r_add_table = master_buffer + 0 * alloc_size; g_add_table = master_buffer + 1 * alloc_size; b_add_table = master_buffer + 2 * alloc_size; div_table = master_buffer + 3 * alloc_size; // add the buffers for (un u0 = 0; u0 < yh - yl; u0++) for (un u1 = 0; u1 < xh - xl; u1++) { un pix_add = h.vb.g_pixel (u1 + xl, u0 + yl); uc r, g, b; // over line flow, reword... r = (pix_add >> (h.vb.vars.g_bpp + h.vb.vars.b_bpp)) & h.vb.vars.r_max; g = (pix_add >> h.vb.vars.b_bpp ) & h.vb.vars.g_max; b = (pix_add >> 0 ) & h.vb.vars.b_max; // add the original pixel to the add buffers *(r_add_table + u0 * (xh - xl) + u1) += r; *(g_add_table + u0 * (xh - xl) + u1) += g; *(b_add_table + u0 * (xh - xl) + u1) += b; *(div_table + u0 * (xh - xl) + u1) += 1; // add up the rgbs to random adjacent/on pixels for (un u2 = 0; u2 < 8; u2++) { un x_t = u1 + (rand () % 3) - 1, y_t = u0 + (rand () % 3) - 1; if ((x_t < (xh - xl)) && (y_t < (yh - yl))) { *(r_add_table + y_t * (xh - xl) + x_t) += r; *(g_add_table + y_t * (xh - xl) + x_t) += g; *(b_add_table + y_t * (xh - xl) + x_t) += b; *(div_table + y_t * (xh - xl) + x_t) += 1; } } } for (un u0 = 0; u0 < yh - yl; u0++) for (un u1 = 0; u1 < xh - xl; u1++) { un offset = u0 * (xh - xl) + u1; *(r_add_table + offset) /= *(div_table + offset); *(g_add_table + offset) /= *(div_table + offset); *(b_add_table + offset) /= *(div_table + offset); } for (un u0 = 0; u0 < yh - yl; u0++) for (un u1 = 0; u1 < xh - xl; u1++) P_PIXEL (xl + u1, yl + u0, *(r_add_table + u0 * (xh - xl) + u1), *(g_add_table + u0 * (xh - xl) + u1), *(b_add_table + u0 * (xh - xl) + u1)); h.vb.update (xl, yl, xh, yh); free (master_buffer); }