/** * The getColor function associated with the image. * * @param pos The position * * @return The color of the pixel at that position. **/ inline RGBc getColor(iVec2 pos) { if (_im == nullptr) return RGBc::c_Transparent; const int64 lx = _im->lx(); const int64 ly = _im->ly(); int64 x = pos.X(); int64 y = pos.Y(); if (_typepos == TYPECENTER) { x += lx/2; y += ly/2; } return _im->getPixel(x, ly - 1 - y); }
/** * The getColor function associated with the image. * * @param pos The position * * @return The color of the pixel at that position. **/ inline RGBc getColor(iVec2 pos) { if (_im == nullptr) return RGBc::c_Transparent; const int64 lx = _im->width(); const int64 ly = _im->height(); int64 x = pos.X(); int64 y = pos.Y(); if (_typepos == TYPECENTER) { x += lx/2; y += ly/2; } if ((x <0)||(y < 0)||(x >= lx)||(y >= ly)) return RGBc::c_Transparent; y = ly - 1 - y; const int64 lxy = lx*ly; int64 off = x + lx*y; const unsigned char * p = _im->data(); const char r = *(p + off); const char g = *(p + off + lxy); const char b = *(p + off + 2*lxy); const char a = ((_im->spectrum() < 4) ? (const char)255 : (*(p + off + 3*lxy))); return RGBc(r, g, b, a); }
/* circle of similar volume colored in blue */ RGBc colorCircle(iVec2 pos) { if (PI*(pos.X()*pos.X() + pos.Y()*pos.Y()) <= N) return RGBc::c_Blue; return RGBc::c_TransparentWhite; }