#include "OmNeo.h" int pin(int x) { if(x < 0) return 0; if(x > 255) return 255; return x; } void OmNeoGrid::drawGradientDisk(float fx, float fy, float radius, long color) { float fr = (color >> 16) & 0xff; float fg = (color >> 8) & 0xff; float fb = (color >> 0) & 0xff; // Make the grid points be *between* the pixels. fx -= 0.5; fy -= 0.5; for(int x = 0; x < this->width; x++) for(int y = 0; y < this->height; y++) { float dx = fx - x; float dy = fy - y; float d = sqrt(dx * dx + dy * dy); d = 1.0 - d / radius; int b = d * 100; d = d * 100.9; long co = g4->color(d * fr, d * fg, d * fb); this->setPixelXy(x, y, co); } } void OmNeoGrid::drawRect(float left, float top, float right, float bottom, long color) { left = max(0, left); right = min(this->width, right); top = max(0, top); bottom = min(this->height, bottom); int iLeft = (int)floor(left); int iRight = (int)ceil(right); int iTop = (int)floor(top); int iBottom = (int)ceil(bottom); for(int x = iLeft; x < iRight; x++) { for(int y = iTop; y < iBottom; y++) { this->setPixelXy(x, y, color); } } }