static void draw_real_spectrum(SDL_Surface *surface, int size, fftw_complex * spectrum, int v_position, int height, const char * title, Uint32 pixel) { int i; float step; char spectrum_title[255]; step = (((float)surface->w / 2) / (size)); sprintf(spectrum_title, "%s Real Spectrum", title); stringColor(surface, 10, v_position - height + (height / 10), spectrum_title, 0xffffffff); hlineColor(surface, 0, surface->w, v_position, 0xffffffff); for (i=1; i < size; i++) { aalineColor(surface, (int)((surface->w / 2) + ((i-1)*step)), ((int)(spectrum[0][i-1] * height) + v_position), (int)((surface->w / 2) + (i*step)), ((int)(spectrum[0][i] * height) + v_position), pixel); aalineColor(surface, (int)((surface->w / 2) - ((i-1)*step)), ((int)(spectrum[0][i-1] * height) + v_position), (int)((surface->w / 2) - (i*step)), ((int)(spectrum[0][i] * height) + v_position), pixel); } }
void draw_constraint(SDL_Renderer *ren, constraint *c) { bool mass_ok = c->nmasses == 2 && !c->masses[0]->dead && !c->masses[1]->dead; switch(c->type) { case NONE: aalineColor(ren, c->masses[0]->pos.x, c->masses[0]->pos.y, c->masses[1]->pos.x, c->masses[1]->pos.y, mass_ok ? 0x44005500 : 0x44000055); break; case DIST_EQ: aalineColor(ren, c->masses[0]->pos.x, c->masses[0]->pos.y, c->masses[1]->pos.x, c->masses[1]->pos.y, mass_ok ? 0xFFFFFFFF : 0x44444444); break; case DIST_GT: case DIST_LT: case XGT: case YGT: case ZGT: case XLT: case YLT: case ZLT: case XEQ: case YEQ: case ZEQ: default: //printf("Tried to draw constraint with unsupported type\n"); break; } }
static void draw_sound(SDL_Surface *surface, int size, int16_t * left_channel, int16_t * right_channel, int v_position, int height, Uint32 pixel) { int i; float step; /* Here as in the other plotting functions we need to compute the step for each data, the only * problem was that, if we computed it as an integer then, for higher value of size (That are the * frames for each period) then all the values would have collapsed, since the "step" would have * been 0. */ step = (((float)surface->w / 2) / size); stringColor(surface, 10, v_position - height + (height / 10), "Amplitude", 0xffffffff); stringColor(surface, (surface->w / 2) - 20, v_position - height + (height / 10), "L", 0xffffffff); stringColor(surface, (surface->w / 2) + 10, v_position - height + (height / 10), "R", 0xffffffff); hlineColor(surface, 0, surface->w, v_position, 0xffffffff); // We plot directly both channels, by going from left to right. for (i=1; i<size; i++) { aalineColor(surface, (int)((surface->w / 2) + ((i-1)*step)), ((int)(right_channel[i-1] * height / (float)DAMP_FACTOR) + v_position), (int)((surface->w / 2) + (i*step)), ((int)(right_channel[i] * height / (float)DAMP_FACTOR) + v_position), pixel); aalineColor(surface, (int)((surface->w / 2) - ((i-1)*step)), ((int)(left_channel[i-1] * height / (float)DAMP_FACTOR) + v_position), (int)((surface->w / 2) - (i*step)), ((int)(left_channel[i] * height / (float)DAMP_FACTOR) + v_position), pixel); } }
void Surface::AALine (const Point & begin, const Point & end, const Color & c) { if (aalineColor (surface, begin.x, begin.y, end.x, end.y, c.GetRGBAColor ())) throw SDLException (); }
int GeoLayer::aaline(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t col) { if(!surf) { error("%s can't run: layer not initialized", __PRETTY_FUNCTION__); return -1; } res = aalineColor(surf, x1, y1, x2, y2, col); if(res < 0) error("error in %s", __PRETTY_FUNCTION__); return(res); }
CAMLprim value ml_aalineColor(value dst,value p1,value p2, value col) { SDL_Surface *sur= SDL_SURFACE(dst); SDL_Rect rect1,rect2; int r; SDLRect_of_value(&rect1,p1); SDLRect_of_value(&rect2,p2); r=aalineColor(sur,rect1.x,rect1.y,rect2.x,rect2.y,Int32_val(col)); return Val_bool(r); }
static PyObject* _gfx_aalinecolor (PyObject *self, PyObject* args) { PyObject *surface, *color; PyObject *p1, *p2; int x1, x2, _y1, y2; pguint32 c; ASSERT_VIDEO_INIT (NULL); if (!PyArg_ParseTuple (args, "OOOO:aaline", &surface, &p1, &p2, &color)) { PyErr_Clear (); if (!PyArg_ParseTuple (args, "OiiiiO:aaline", &surface, &x1, &_y1, &x2, &y2, &color)) return NULL; } else { if (!PointFromObj (p1, &x1, &_y1) || !PointFromObj (p2, &x2, &y2)) return NULL; } if (!PySDLSurface_Check (surface)) { PyErr_SetString (PyExc_TypeError, "surface must be a Surface"); return NULL; } if (!ColorFromObj (color, &c)) return NULL; if (aalineColor (((PySDLSurface*)surface)->surface, (Sint16)x1, (Sint16)_y1, (Sint16)x2, (Sint16)y2, (Uint32)c) == -1) { PyErr_SetString (PyExc_PyGameError, SDL_GetError ()); return NULL; } Py_RETURN_NONE; }
bool Bullet::render() { aalineColor(SDL_GetVideoSurface(), X(), Y(), X()+cos(angle)*-5, Y()+sin(angle)*-5, 0x0088ffff); return isAlive(); }
void Surface::line(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, const SDL_Color& c) { aalineColor(surface, x1, y1, x2, y2, getRGBA(c)); }
void GameOver::render() { // G aalineColor(SDL_GetVideoSurface(), 200, 100, 230, 100, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 200, 100, 200, 180, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 200, 180, 230, 180, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 230, 180, 230, 150, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 230, 150, 215, 150, 0xffffffff); // A aalineColor(SDL_GetVideoSurface(), 240, 100, 240, 180, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 240, 130, 270, 130, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 240, 100, 270, 100, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 270, 100, 270, 180, 0xffffffff); // M aalineColor(SDL_GetVideoSurface(), 280, 100, 280, 180, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 280, 100, 295, 130, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 295, 130, 310, 100, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 310, 100, 310, 180, 0xffffffff); // E aalineColor(SDL_GetVideoSurface(), 320, 100, 320, 180, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 320, 100, 350, 100, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 320, 130, 350, 130, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 320, 180, 350, 180, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 200, 200, 200, 280, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 230, 200, 230, 280, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 200, 200, 230, 200, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 200, 280, 230, 280, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 240, 200, 255, 280, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 270, 200, 255, 280, 0xffffffff); // E aalineColor(SDL_GetVideoSurface(), 280, 200, 280, 280, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 280, 200, 310, 200, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 280, 230, 310, 230, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 280, 280, 310, 280, 0xffffffff); // E aalineColor(SDL_GetVideoSurface(), 320, 200, 320, 280, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 320, 200, 350, 200, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 350, 200, 320, 230, 0xffffffff); aalineColor(SDL_GetVideoSurface(), 320, 230, 350, 280, 0xffffffff); }