void color::blend(const color &other) { if (other.is_invisible()) return; r = alpha_over_c(other.r, other.a, r, a); g = alpha_over_c(other.g, other.a, g, a); b = alpha_over_c(other.b, other.a, b, a); a = a + (other.a * (0xff - a)) / 0xff; r = ((r * 0xff) / a); g = ((g * 0xff) / a); b = ((b * 0xff) / a); }
void image_operations::add_pixel(pos_t x, pos_t y, color &c) { if (c.is_invisible()) { return; } if (!(x >= min_x)) { return; } if (!(y >= min_y)) { return; } if (!(x < max_x)) { return; } if (!(y < max_y)) { return; } color n = color(c); // tag with depth. n.z = z; image_operation oper; oper.x = (uint16_t)x; oper.y = (uint16_t)y; oper.c = n; operations.push_back(oper); }