void renderStepZoneDMX(int player) { int startColumn = player == 0 ? 0 : 4; if ( gs.isSingles() ) { if ( gs.player[0].centerLeft ) { startColumn = 0; } else if ( gs.player[0].centerRight ) { startColumn = 4; } else { startColumn = 2; // center play } } int endColumn = gs.isDoubles ? 8 : startColumn+4; for ( int i = startColumn; i < endColumn; i++ ) { int x = getColumnOffsetX_DMX(i); int blink = gs.player[player].stepZoneBlinkTimer > 0 ? 0 : 1; // pick the state of the step zone int hitcolor = 0x7F000000; int outlineColor = 0xFFB4B4B4; const int fadeOutLength = 100; if ( blink == 1 ) { static int colors[3] = { makeacol(41, 239, 115, 255), makeacol(239, 101, 190, 255), makeacol(76, 0, 190, 255) }; int stageColor = gs.player[player].stagesLevels[gs.currentStage] % 10; outlineColor = colors[stageColor]; } if ( gs.player[player].laneFlareColors[i] == 2 ) { blink = 2; // currently holding a hold note in this column } int color = getColorOfColumn(i); if ( im.isKeyDown(i) ) { hitcolor = color == 0 ? 0xEECC0000 : 0xEE0000CC; } else if ( im.getReleaseLength(i) <= fadeOutLength ) { int a = getValueFromRange(0xFF, 0x7F, im.getReleaseLength(i) * 100/ fadeOutLength); if ( i ==4 ) { al_trace("%d\r\n", a); } hitcolor = color == 0 ? makeacol32(0xFF, 0, 0, a) : makeacol32(0, 0, 0xFF, a); } renderStepLaneDMX(x, hitcolor, outlineColor); masked_blit(m_stepZoneSourceDMX[color], rm.m_backbuf, blink*34, 0, x, (gs.player[player].isColumnReversed(i) ? DMX_STEP_ZONE_REV_Y-34 : DMX_STEP_ZONE_Y), 34, 38); } }
inline int to_allegro(int color_depth, gfx::Color color) { if (color_depth == 32) { return makeacol32( gfx::getr(color), gfx::getg(color), gfx::getb(color), gfx::geta(color)); } else { if (gfx::is_transparent(color)) return -1; else return makecol_depth(color_depth, gfx::getr(color), gfx::getg(color), gfx::getb(color)); } }
/* makeacol_depth: * Converts R, G, B, and A values (ranging 0-255) to whatever pixel format * is required by the specified color depth. */ int makeacol_depth(int color_depth, int r, int g, int b, int a) { switch (color_depth) { case 8: return makecol8(r, g, b); case 15: return makecol15(r, g, b); case 16: return makecol16(r, g, b); case 24: return makecol24(r, g, b); case 32: return makeacol32(r, g, b, a); } return 0; }
int convert_color_to_allegro<GrayscaleTraits, 32>(color_t c, const Palette* palette) { return makeacol32(graya_getv(c), graya_getv(c), graya_getv(c), graya_geta(c)); }
int convert_color_to_allegro<RgbTraits, 32>(color_t c, const Palette* palette) { return makeacol32(rgba_getr(c), rgba_getg(c), rgba_getb(c), rgba_geta(c)); }
int convert_color_to_allegro<BitmapTraits, 32>(color_t color, const Palette* palette) { color_t c = palette->getEntry(color); return makeacol32(rgba_getr(c), rgba_getg(c), rgba_getb(c), rgba_geta(c)); }
void DrawList::draw(Font *fnt) { glPushMatrix(); const float screen_w = float(SCREEN_W); const float screen_h = float(SCREEN_H); switch(prim.type) { case DRAW_TYPE_POINT: glScalef(screen_w / 640.0f, screen_h / 480.0f, 1.0f); glBegin(GL_POINTS); glColor3f(prim.r[0],prim.g[0],prim.b[0]); glVertex2f(prim.x[0],prim.y[0]); glEnd(); break; case DRAW_TYPE_LINE: glScalef(screen_w / 640.0f, screen_h / 480.0f, 1.0f); glBegin(GL_LINES); glColor3f(prim.r[0],prim.g[0],prim.b[0]); glVertex2f(prim.x[0],prim.y[0]); glVertex2f(prim.x[1],prim.y[1]); glEnd(); break; case DRAW_TYPE_CIRCLE: glScalef(screen_w / 640.0f, screen_h / 480.0f, 1.0f); glBegin(GL_LINE_STRIP); glColor3f(prim.r[0],prim.g[0],prim.b[0]); { const int max = (int)(sqrtf(prim.r[1])*2.0f)*2; if (max > 0) for(int i = 0 ; i <= prim.r[1] * 10 ; i++) glVertex2f(prim.x[0] + prim.r[1] * cosf(float(i) * 6.2831853072f / float(max)), prim.y[0] + prim.r[1] * sinf(float(i) * 6.2831853072f / float(max))); } glEnd(); break; case DRAW_TYPE_TRIANGLE: glScalef(screen_w / 640.0f, screen_h / 480.0f, 1.0f); glBegin(GL_TRIANGLES); glColor3f(prim.r[0],prim.g[0],prim.b[0]); glVertex2f(prim.x[0],prim.y[0]); glVertex2f(prim.x[1],prim.y[1]); glVertex2f(prim.x[2],prim.y[2]); glEnd(); break; case DRAW_TYPE_BOX: glScalef(screen_w / 640.0f, screen_h / 480.0f, 1.0f); glBegin(GL_LINE_STRIP); glColor3f(prim.r[0],prim.g[0],prim.b[0]); glVertex2f(prim.x[0],prim.y[0]); glVertex2f(prim.x[1],prim.y[0]); glVertex2f(prim.x[1],prim.y[1]); glVertex2f(prim.x[0],prim.y[1]); glVertex2f(prim.x[0],prim.y[0]); glEnd(); break; case DRAW_TYPE_FILLBOX: glScalef(screen_w / 640.0f, screen_h / 480.0f, 1.0f); glBegin(GL_QUADS); glColor3f(prim.r[0],prim.g[0],prim.b[0]); glVertex2f(prim.x[0],prim.y[0]); glVertex2f(prim.x[1],prim.y[0]); glVertex2f(prim.x[1],prim.y[1]); glVertex2f(prim.x[0],prim.y[1]); glEnd(); break; case DRAW_TYPE_TEXT: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); { float x = prim.x[0] * screen_w / 640.0f; float y = prim.y[0] * screen_h / 480.0f; if (x < 0.0f) x += screen_w - 0.5f * fnt->length(prim.text); if (y < 0.0f) y += screen_h - 0.5f * fnt->height(); gfx->print(fnt, x + 1, y + 1, 0.0f, makeacol32(0,0,0, 0xFF), prim.text); gfx->print(fnt, x, y, 0.0f, makeacol32((int)(prim.r[0] * 255.0f), (int)(prim.g[0] * 255.0f), (int)(prim.b[0] * 255.0f), 0xFF), prim.text); } glDisable(GL_BLEND); break; case DRAW_TYPE_BITMAP: glScalef(screen_w / 640.0f, screen_h / 480.0f,1.0f); if (prim.tex == 0 && !prim.text.empty()) { prim.tex = gfx->load_texture( prim.text ); prim.text.clear(); } glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); gfx->drawtexture(prim.tex,prim.x[0],prim.y[0],prim.x[1],prim.y[1]); glDisable(GL_BLEND); break; } glPopMatrix(); if (next) next->draw(fnt); }
void VariableWidthSpriteFontRenderer::Draw(BITMAP *src, BITMAP *dest, int destx, int desty, int srcx, int srcy, int width, int height) { long srcWidth, srcHeight, destWidth, destHeight, srcColDepth, destColDepth; unsigned char **srccharbuffer = _engine->GetRawBitmapSurface (src); //8bit unsigned short **srcshortbuffer = (unsigned short**)srccharbuffer; //16bit; unsigned long **srclongbuffer = (unsigned long**)srccharbuffer; //32bit unsigned char **destcharbuffer = _engine->GetRawBitmapSurface (dest); //8bit unsigned short **destshortbuffer = (unsigned short**)destcharbuffer; //16bit; unsigned long **destlongbuffer = (unsigned long**)destcharbuffer; //32bit int transColor = _engine->GetBitmapTransparentColor(src); _engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, &srcColDepth); _engine->GetBitmapDimensions(dest, &destWidth, &destHeight, &destColDepth); if (srcy + height > srcHeight || srcx + width > srcWidth || srcx < 0 || srcy < 0) return; if (width + destx > destWidth) width = destWidth - destx; if (height + desty > destHeight) height = destHeight - desty; int startx = MAX(0, (-1 * destx)); int starty = MAX(0, (-1 * desty)); int srca, srcr, srcg, srcb, desta, destr, destg, destb, finalr, finalg, finalb, finala, col; for(int x = startx; x < width; x ++) { for(int y = starty; y < height; y ++) { int srcyy = y + srcy; int srcxx = x + srcx; int destyy = y + desty; int destxx = x + destx; if (destColDepth == 8) { if (srccharbuffer[srcyy][srcxx] != transColor) destcharbuffer[destyy][destxx] = srccharbuffer[srcyy][srcxx]; } else if (destColDepth == 16) { if (srcshortbuffer[srcyy][srcxx] != transColor) destshortbuffer[destyy][destxx] = srcshortbuffer[srcyy][srcxx]; } else if (destColDepth == 32) { //if (srclongbuffer[srcyy][srcxx] != transColor) destlongbuffer[destyy][destxx] = srclongbuffer[srcyy][srcxx]; srca = (geta32(srclongbuffer[srcyy][srcxx])); if (srca != 0) { srcr = getr32(srclongbuffer[srcyy][srcxx]); srcg = getg32(srclongbuffer[srcyy][srcxx]); srcb = getb32(srclongbuffer[srcyy][srcxx]); destr = getr32(destlongbuffer[destyy][destxx]); destg = getg32(destlongbuffer[destyy][destxx]); destb = getb32(destlongbuffer[destyy][destxx]); desta = geta32(destlongbuffer[destyy][destxx]); finalr = srcr; finalg = srcg; finalb = srcb; finala = 255-(255-srca)*(255-desta)/255; finalr = srca*finalr/finala + desta*destr*(255-srca)/finala/255; finalg = srca*finalg/finala + desta*destg*(255-srca)/finala/255; finalb = srca*finalb/finala + desta*destb*(255-srca)/finala/255; col = makeacol32(finalr, finalg, finalb, finala); destlongbuffer[destyy][destxx] = col; } } } } _engine->ReleaseBitmapSurface(src); _engine->ReleaseBitmapSurface(dest); }
static int scale_icon(ICON_DATA *icon) { BITMAP *shape; int size, x_ofs = 2, y_ofs = 2; int x, y, m, n; int i_x, i_y; float k, f_x, f_y, a, b, r1, r2; float red, green, blue, alpha; unsigned int color; if (icon->original->w > icon->original->h) { size = 4 + icon->original->w; y_ofs = 2 + ((icon->original->w - icon->original->h) / 2); } else { size = 4 + icon->original->h; x_ofs = 2 + ((icon->original->h - icon->original->w) / 2); } k = (float)(size - 4) / (float)icon->size; icon->workspace = create_bitmap_ex(32, size, size); if (!icon->workspace) return -1; icon->scaled = create_bitmap_ex(32, icon->size, icon->size); if (!icon->scaled) return -1; shape = create_bitmap_ex(32, icon->original->w, icon->original->h); if (!shape) return -1; blit(icon->original, shape, 0, 0, 0, 0, icon->original->w, icon->original->h); clear_to_color(icon->workspace, makeacol32(0, 0, 0, 255)); shape->vtable->mask_color = makeacol32(255, 0, 255, 0); masked_blit(shape, icon->workspace, 0, 0, x_ofs, y_ofs, shape->w, shape->h); destroy_bitmap(shape); for (y = 0; y < icon->size; y++) { f_y = (float)y * k; i_y = (int)floor(f_y); a = f_y - floor(f_y); for (x = 0; x < icon->size; x++) { f_x = (float)x * k; i_x = (int)floor(f_x); b = f_x - floor(f_x); red = green = blue = alpha = 0.0; for (m = -1; m < 3; m++) { r1 = cubic_bspline((float)m - a); for (n = -1; n < 3; n++) { r2 = cubic_bspline(b - (float)n); color = ((unsigned int *)(icon->workspace->line[i_y + m + 2]))[i_x + n + 2]; red += ((float)getr32(color) * r1 * r2); green += ((float)getg32(color) * r1 * r2); blue += ((float)getb32(color) * r1 * r2); alpha += ((float)geta32(color) * r1 * r2); } } color = makeacol32((int)floor(red), (int)floor(green), (int)floor(blue), 255 - (int)floor(alpha)); ((unsigned int *)(icon->scaled->line[y]))[x] = color; } } return 0; }