/* Function: al_draw_tinted_bitmap */ void al_draw_tinted_bitmap(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR tint, float dx, float dy, int flags) { ASSERT(bitmap); al_draw_tinted_bitmap_region(bitmap, tint, 0, 0, bitmap->w, bitmap->h, dx, dy, flags); }
void shal_draw_tinted_bitmap_region(ALLEGRO_BITMAP * bitmap, float tint_r, float tint_g, float tint_b, float tint_a, float sx, float sy, float sw, float sh, float dx, float dy, int flags) { ALLEGRO_COLOR tint; tint.r = tint_r; tint.g = tint_g; tint.b = tint_b; tint.a = tint_a; return al_draw_tinted_bitmap_region(bitmap, tint, sx, sy, sw, sh, dx, dy, flags); }
void Enemy::draw() { al_draw_filled_ellipse(posx_+width_/2, posy_- height_/2+5, width_/2, height_/2, al_map_rgba(0,0,0,50)); if (lastHurt_ + 0.5 < al_get_time()) al_draw_bitmap_region(picture_, animationState_*pic_width_, 0, pic_width_, pic_height_, posx_, posy_ - pic_height_ - posz_, 0); else al_draw_tinted_bitmap_region(picture_, al_map_rgba(200,100,100,100), animationState_*pic_width_, 0, pic_width_, pic_height_, posx_, posy_ - pic_height_ - posz_, 0); }
// draw alpha animation void DrawAlphaAnimation( animation* ani, float xoffset, float yoffset, float alpha ) { int frameIdx = ani->curTime / ani->interval; int curIdx = frameIdx % ani->frameCnt; al_draw_tinted_bitmap_region( ani->spritesheet, al_map_rgba_f( 1.0f, 1.0f, 1.0f, alpha ), ani->frames[curIdx].x, ani->frames[curIdx].y, (float)ani->wid, (float)ani->hei, xoffset, yoffset, 0 ); }
void draw_nine_patch_bitmap(NINE_PATCH_BITMAP *p9, ALLEGRO_COLOR tint, int dx, int dy, int dw, int dh) { int i, j; bool release_drawing = false; /* don't draw bitmaps that are smaller than the fixed area */ if (dw < p9->h.fix || dh < p9->v.fix) return; /* if the bitmap is the same size as the origin, then draw it as-is */ if (dw == p9->width && dh == p9->height) { al_draw_tinted_bitmap_region(p9->bmp, tint, 1, 1, dw, dh, dx, dy, 0); return; } /* due to the caching mechanism, multiple threads cannot draw this image at the same time */ al_lock_mutex(p9->mutex); /* only recalculate the offsets if they have changed since the last draw */ if (p9->cached_dw != dw || p9->cached_dh != dh) { calc_nine_patch_offsets(&p9->h, dw); calc_nine_patch_offsets(&p9->v, dh); p9->cached_dw = dw; p9->cached_dh = dh; } if (!al_is_bitmap_drawing_held()) { release_drawing = true; al_hold_bitmap_drawing(true); } /* draw each region */ for (i = 0; i < p9->v.count; ++i) { for (j = 0; j < p9->h.count; ++j) { al_draw_tinted_scaled_bitmap(p9->bmp, tint, p9->h.m[j].offset, p9->v.m[i].offset, p9->h.m[j].length, p9->v.m[i].length, dx + p9->h.m[j].dest_offset, dy + p9->v.m[i].dest_offset, p9->h.m[j].dest_length, p9->v.m[i].dest_length, 0 ); } } al_unlock_mutex(p9->mutex); if (release_drawing) al_hold_bitmap_drawing(false); }
void Bomb::draw() { if (exploded_) { double timeLeft = explosionTime_ - al_get_time(); if (timeLeft > -0.1) al_draw_tinted_bitmap_region(picture_, al_map_rgba(0,0,0,100), 0, 35, 173, 156, posx_-69, posy_-95, 0); else if (timeLeft > -0.2) al_draw_tinted_bitmap_region(picture_, al_map_rgba(0,0,0,50), 0, 35, 173, 156, posx_-69, posy_-95, 1); else al_draw_tinted_bitmap_region(picture_, al_map_rgba(0,0,0,20), 0, 35, 173, 156, posx_-69, posy_-95, 2); return; } al_draw_filled_ellipse(posx_+width_/2, posy_- height_/2+5, width_/2, height_/2, al_map_rgba(0,0,0,50)); if (color_ == 0) al_draw_bitmap_region(picture_, pic_width_, 0, pic_width_, pic_height_, posx_, posy_ - pic_height_, 0); else al_draw_tinted_bitmap_region(picture_, al_map_rgb(255, 0, 0), pic_width_, 0, pic_width_, pic_height_, posx_, posy_ - pic_height_, 0); }
void AnimPage(struct Game *game, int page, ALLEGRO_COLOR tint) { int offset = 0; if (game->intro.in_animation) offset = -1*game->viewportWidth + (cos(((-1*((game->intro.position)%game->viewportWidth))/(float)game->viewportWidth)*(ALLEGRO_PI))/2.0)*game->viewportWidth + game->viewportWidth/2.0; int amount1 = 2, amount2 = 2; float anim = game->intro.anim; if (page==2) { amount1=4; amount2=3; } if (page==3) { amount1=3; amount2=3; } if (page==5) { amount1=5; amount2=3; anim*=2; } if (page<6) al_draw_tinted_bitmap_region(game->intro.animsprites[page-1],tint,game->viewportHeight*1.6*0.3125*(int)fmod(anim,amount1),game->viewportHeight*0.63*(((int)(anim/amount1))%amount2),game->viewportHeight*1.6*0.3125, game->viewportHeight*0.63,offset+game->viewportWidth*0.08, game->viewportHeight*0.18,0); amount1 = 2; amount2 = 2; if (page==1) { amount1=4; amount2=3; } if (page==2) { amount1=3; amount2=3; } if (page==4) { amount1=5; amount2=3; anim*=2; } if (page<5) al_draw_tinted_bitmap_region(game->intro.animsprites[page],tint,game->viewportHeight*1.6*0.3125*(int)fmod(anim,amount1),game->viewportHeight*0.63*(((int)(anim/amount1))%amount2),game->viewportHeight*1.6*0.3125, game->viewportHeight*0.63,offset+game->viewportWidth*1.08, game->viewportHeight*0.18,0); }
void drawenemy(Game *game, int i) { Enemy enemy; enemy = game->room->enemies[i]; al_draw_filled_ellipse(enemy.posx+enemy.szer/2,enemy.posy-enemy.grub/2 + 5,enemy.szer/2, enemy.grub/2, al_map_rgba(0,0,0,50)); if (enemy.lasthurt > al_get_time() - 0.3) al_draw_tinted_bitmap_region(enemy.picture, al_map_rgba(100,100,100,100),enemy.picposx,enemy.picposy, enemy.szer, enemy.wys, enemy.posx, enemy.posy-enemy.wys, 0); else al_draw_bitmap_region(enemy.picture,enemy.picposx,enemy.picposy, enemy.szer, enemy.wys, enemy.posx, enemy.posy-enemy.wys, 0); }
void Graphics::DrawRegion(Texture* source, float srcX, float srcY, float srcWidth, float srcHeight, float destX, float destY, float alpha, bool flipped, float angle) { if(!source) { al_show_native_message_box(TF::engine->display, "Error", "Error", "[TEXTURE DRAW] The texture is NULL!", NULL, ALLEGRO_MESSAGEBOX_ERROR); return; } if(angle == 0.0f) { if(!flipped) { al_draw_tinted_bitmap_region(source->tex, al_map_rgba_f(1.0f * alpha, 1.0f * alpha, 1.0f * alpha, alpha), srcX, srcY, srcWidth, srcHeight, destX, destY, 0); } else { al_draw_tinted_bitmap_region(source->tex, al_map_rgba_f(1.0f * alpha, 1.0f * alpha, 1.0f * alpha, alpha), srcX, srcY, srcWidth, srcHeight, destX, destY, ALLEGRO_FLIP_HORIZONTAL); } } else { if(!flipped) { al_draw_tinted_scaled_rotated_bitmap_region(source->tex, srcX, srcY, srcWidth, srcHeight, al_map_rgba_f(1.0f * alpha, 1.0f * alpha, 1.0f * alpha, alpha), 0.0f, 0.0f, destX, destY, 1.0f, 1.0f, angle, 0); } else { al_draw_tinted_scaled_rotated_bitmap_region(source->tex, srcX, srcY, srcWidth, srcHeight, al_map_rgba_f(1.0f * alpha, 1.0f * alpha, 1.0f * alpha, alpha), 0.0f, 0.0f, destX, destY, 1.0f, 1.0f, angle, ALLEGRO_FLIP_HORIZONTAL); } } }
static mrb_value bitmap_draw_tinted_region(mrb_state *mrb, mrb_value self) { ALLEGRO_BITMAP *b; mrb_float sx; mrb_float sy; mrb_float sw; mrb_float sh; mrb_float dx; mrb_float dy; mrb_sym flag1; mrb_sym flag2; int argc; ALLEGRO_COLOR *tint; int flags; Check_Destroyed(mrb, self, bitmap, b); argc = mrb_get_args(mrb, "dffffff|nn", &tint, &mrbal_color_data_type, &sx, &sy, &sw, &sh, &dx, &dy, &flag1, &flag2); flags = argc > 7 ? mrbal_bitmap_get_flags(mrb, argc, flag1, flag2) : 0; al_draw_tinted_bitmap_region(b, *tint, sx, sy, sw, sh, dx, dy, flags); return mrb_nil_value(); }
void Map::Draw(float interpolation) { for(int i = 0; i < width; i++) for(int j = 0; j < height; j++) { al_draw_tinted_bitmap_region(terrainTileSheet, (tiles[i][j].DrawOverlay() ? al_map_rgba_f(0.5, 0.5, 1, 1) : al_map_rgba_f(1, 1, 1, 1)), (tiles[i][j].getTerrain() % terrainTileSheetCols) * terrainTileWidth, (tiles[i][j].getTerrain() / terrainTileSheetCols) * terrainTileHeight, terrainTileWidth, terrainTileHeight, i*tileWidth, j*tileHeight, 0); if(tiles[i][j].getBuilding() != NULL) { al_draw_bitmap_region(buildingTileSheet, tiles[i][j].getBuilding()->getBuildingType() * buildingTileWidth, tiles[i][j].getBuilding()->getSide() * buildingTileHeight, buildingTileWidth, buildingTileHeight, i*tileWidth, j*tileHeight, 0); } if(tiles[i][j].getUnit() != NULL) { al_draw_bitmap_region(unitTileSheet, ((tiles[i][j].getUnit()->getUnitType()) % unitTileSheetCols) * unitTileWidth, ((tiles[i][j].getUnit()->getUnitType()) / unitTileSheetCols) * unitTileHeight, unitTileWidth, unitTileHeight, i*tileWidth, j*tileHeight, 0); } } }
/* Function: al_draw_bitmap_region */ void al_draw_bitmap_region(ALLEGRO_BITMAP *bitmap, float sx, float sy, float sw, float sh, float dx, float dy, int flags) { al_draw_tinted_bitmap_region(bitmap, solid_white, sx, sy, sw, sh, dx, dy, flags); }
void draw_sprite(TileSet * tileset, s_sprite sprite, s_map_block * block, float x, float y, int shrink, bool flip = 0, int offset = 0, bool shiftup = false) { if(offset < 0) return; int target_width = al_get_bitmap_width(al_get_target_bitmap()); int target_height = al_get_bitmap_height(al_get_target_bitmap()); if((x + sprite.origin_x > target_width) || (y + sprite.origin_y > target_height) || ((x + sprite.origin_x + sprite.width) < 0) || ((y + sprite.origin_y + (sprite.height - shrink)) < 0))return; int flags = 0; if(flip) flags = ALLEGRO_FLIP_HORIZONTAL; ALLEGRO_COLOR color; switch(sprite.color_by) { case COLOR_NONE: color = block->light; break; case COLOR_INI: color = mix_colors(sprite.color, block->light); break; case COLOR_BIOME: color = mix_colors(block->biome_color, block->light); break; case COLOR_COMBINED: color = mix_colors(block->combined_color, block->light); break; case COLOR_STRUCTURE: color = mix_colors(block->structure_color, block->light); break; case COLOR_TRADE: color = mix_colors(block->trade_color, block->light); break; case COLOR_PALETTE: switch(sprite.color_source) { case SOURCE_ELEV: color = mix_colors(tileset->get_palette_color(sprite.palette_number, block->height), block->light); break; case SOURCE_DEPTH: color = mix_colors(tileset->get_palette_color(sprite.palette_number,block->water_height-block->height), block->light); break; case SOURCE_TEMPERATURE: color = mix_colors(tileset->get_palette_color(sprite.palette_number,block->levels[SOURCE_TEMPERATURE]), block->light); break; case SOURCE_RAINFALL: color = mix_colors(tileset->get_palette_color(sprite.palette_number,block->levels[SOURCE_RAINFALL]), block->light); break; case SOURCE_DRAINAGE: color = mix_colors(tileset->get_palette_color(sprite.palette_number,block->levels[SOURCE_DRAINAGE]), block->light); break; case SOURCE_SAVAGERY: color = mix_colors(tileset->get_palette_color(sprite.palette_number,block->levels[SOURCE_SAVAGERY]), block->light); break; case SOURCE_VOLCANISM: color = mix_colors(tileset->get_palette_color(sprite.palette_number,block->levels[SOURCE_VOLCANISM]), block->light); break; case SOURCE_EVIL: color = mix_colors(tileset->get_palette_color(sprite.palette_number,block->levels[SOURCE_EVIL]), block->light); break; case SOURCE_SALINITY: color = mix_colors(tileset->get_palette_color(sprite.palette_number,block->levels[SOURCE_SALINITY]), block->light); break; default: color = block->light; } break; default: color = block->light; break; } al_draw_tinted_bitmap_region( imagelist.get_image(sprite.index), color, sprite.x + (sprite.width * offset), sprite.y + ((!shiftup)*shrink), sprite.width, sprite.height - shrink, x + sprite.origin_x, y + sprite.origin_y, flags); }
/** Draws part of this bitmap onto the target bitmap tinted by the given color. @param color color. @param sx source x position. @param sy source y position. @param sw source width. @param sh source height. @param dx target horizontal position. @param dy target vertical position. @param flags flags. */ void drawTinted(const ALLEGRO_COLOR &color, float sx, float sy, float sw, float sh, float dx, float dy, int flags = 0) const { al_draw_tinted_bitmap_region(get(), color, sx, sy, sw, sh, dx, dy, flags); }
void al_draw_tinted_bitmap_region_w(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR *tint, float sx, float sy, float sw, float sh, float dx, float dy, int flags) { return al_draw_tinted_bitmap_region(bitmap, *tint, sx, sy, sw, sh, dx, dy, flags); }