void CDDomWidgetA::MakeColor( D3DCOLOR& d3dcolor, DOMINATING_TEAM team ) { if( m_ToBeDominated != DTEAM_NONE ) { switch( team ) { case DTEAM_A: d3dcolor = D3DCOLOR_ARGB( 0xFF, GetAlpha(), 0x00, 0x00 ); break; case DTEAM_B: d3dcolor = D3DCOLOR_ARGB( 0xFF, 0x00, 0x00, GetAlpha() ); break; default: { d3dcolor = 0xDAD5DBBA; }break; } } else { switch( team ) { case DTEAM_A: d3dcolor = 0xFFE01B1B; break; case DTEAM_B: d3dcolor = 0xFF3C47DE; break; default: { d3dcolor = 0xDAD5DBBA; }break; } } }
void CASW_VGUI_Computer_Splash::SetHidden(bool bHidden) { if (bHidden && GetAlpha() > 0) { vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 0, 0, 0.7f, vgui::AnimationController::INTERPOLATOR_LINEAR); } else if (!bHidden && GetAlpha() <= 0) { vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 255, 0, 0.7f, vgui::AnimationController::INTERPOLATOR_LINEAR); } }
void GuiInfomsg::Update(GuiTrigger * t) { if(GetAlpha() == 0){ return; } if(difftime(time(NULL), timer) >= 2.0f){ SetAlpha(GetAlpha()-10); if(GetAlpha() < 0){ SetAlpha(0); } } }
/* ================================================================ コピー。 ソース画像が透明色を持っていない場合はmemory-to-memoryコピー そうでない場合は1pixelづつコピー ================================================================ */ void VnImage::Copy(const VnImage& img, const VnRect& srcRect, int dx, int dy) { // 範囲内のチェック VnRect src_rect(0, 0, img.Width(), img.Height()); src_rect &= srcRect; VnRect dst_rect(0, 0, Width(), Height()); dst_rect &= VnRect(dx, dy, src_rect.width, src_rect.height); if (GetAlpha(img.mTransColor) == 0xff) { // 不透明画像をコピー for(int y = 0; y < dst_rect.height; ++y) { memcpy(GetPixelBuf(dst_rect.x, dst_rect.y + y), img.GetPixelBuf(src_rect.x, src_rect.y + y), dst_rect.width * 4); } } else { const u_int32_t trans_color = ToMachineColor(img.mTransColor & 0xffffff00); // 透明色を考慮したコピー for(int y = 0; y < dst_rect.height; ++y) { const u_int32_t* src = img.GetPixelBuf(src_rect.x, src_rect.y + y); u_int32_t* dst = GetPixelBuf(dst_rect.x, dst_rect.y + y); for(int x = 0; x < dst_rect.width; ++x, ++dst, ++src) { // ソースが透明色でない場合に書き込む // リトルエンディアン限定(:TODO:) if (trans_color != (*src & 0x00ffffff)) { *dst = *src; } } } } // end of if (GetAlpha ...) // cerr << "VnImage::Copy " << t.GetPassed() << "(s)" << endl; }
void WINAPI duListBox::DrawObject(HDC hDC) { duRect rcListBox; Plugin_GetRect(this, &rcListBox); rcListBox.OffsetRect(-rcListBox.left, -rcListBox.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rcListBox, GetState(), GetText(), GetAlpha()); pStyleGroup = (duStyleGroup *)GetResObj(m_szItemStyle, DU_RES_STYLEGROUP); if (pStyleGroup == NULL) return; duRect rcItem; rcItem.SetRectEmpty(); rcItem.right = rcListBox.Width(); rcItem.OffsetRect(0, -m_nYOffset); ListBoxItem *pItem = NULL; int i; int nItemCount = GetItemCount(); for (i = 0;i < nItemCount; i++) { pItem = m_vtItem[i]; rcItem.top = rcItem.bottom; rcItem.bottom = rcItem.top + m_nItemHeight; DrawItem(pItem, hDC, pStyleGroup, rcItem); } }
void WINAPI duOutlookBar::DrawObject(HDC hDC) { duRect rect; GetRect(&rect); rect.OffsetRect(-rect.left, -rect.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rect, DU_STATE_ALL, GetText(), GetAlpha()); duStyleGroup *pItemStyleGroup = (duStyleGroup *)GetResObj(m_szItemStyle, DU_RES_STYLEGROUP); if (pItemStyleGroup == NULL) return ; int i; OutlookBarItem *pOutlookBarItem = NULL; int nItemCount = GetItemCount(); duRect rectItem = rect; rectItem.bottom = rectItem.top + m_nItemHeight; for (i = 0;i < nItemCount; i++) { pOutlookBarItem = m_vtItems[i]; pItemStyleGroup->Draw(hDC, &rectItem, pOutlookBarItem->iState, pOutlookBarItem->strText.c_str(), GetAlpha()); if (pOutlookBarItem->fSelected) { rectItem.top = rect.bottom - (nItemCount - i - 1) * m_nItemHeight; rectItem.bottom = rectItem.top + m_nItemHeight; } else rectItem.OffsetRect(0, m_nItemHeight); } }
void Color::ToFloat(float Dest[]) const { Dest[0] = GetRed() / 255.0f; Dest[1] = GetGreen() / 255.0f; Dest[2] = GetBlue() / 255.0f; Dest[3] = GetAlpha() / 255.0f; }
static int MBAnalyzeBestIntra16Mode(VP8EncIterator* const it) { const int max_mode = (it->enc_->method_ >= FAST_ANALYSIS_METHOD) ? MAX_INTRA16_MODE : NUM_PRED_MODES; int mode; int best_alpha = DEFAULT_ALPHA; int best_mode = 0; VP8MakeLuma16Preds(it); for (mode = 0; mode < max_mode; ++mode) { VP8Histogram histo = { { 0 } }; int alpha; VP8CollectHistogram(it->yuv_in_ + Y_OFF, it->yuv_p_ + VP8I16ModeOffsets[mode], 0, 16, &histo); alpha = GetAlpha(&histo); if (IS_BETTER_ALPHA(alpha, best_alpha)) { best_alpha = alpha; best_mode = mode; } } VP8SetIntra16Mode(it, best_mode); return best_alpha; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CMessageDialog::PaintBackground( void ) { int wide, tall; GetSize( wide, tall ); if ( !( m_nType & MD_SIMPLEFRAME ) ) { int nAlpha = GetAlpha(); m_clrNotSimpleBG[3] = nAlpha; m_clrNotSimpleBGBlack[3] = nAlpha; DrawBox( 0, 0, wide, tall, m_clrNotSimpleBGBlack, 1.0f ); DrawBox( 0, 0, wide, tall - m_FooterTall, m_clrNotSimpleBG, 1.0f ); return; } Color col = GetBgColor(); DrawBox( 0, 0, wide, tall, col, 1.0f ); // offset the inset by title int titleX, titleY, titleWide, titleTall; m_pTitle->GetBounds( titleX, titleY, titleWide, titleTall ); int y = titleY + titleTall; // draw an inset Color darkColor; darkColor.SetColor( 0.70f * (float)col.r(), 0.70f * (float)col.g(), 0.70f * (float)col.b(), col.a() ); vgui::surface()->DrawSetColor( darkColor ); vgui::surface()->DrawFilledRect( 8, y, wide - 8, tall - 8 ); }
void GuiCross::Draw() { GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); f32 x1 = GetLeft(); f32 x2 = x1 + width; f32 y1 = GetTop(); f32 y2 = y1 + height; int alpha = GetAlpha(); GX_Begin(GX_LINES, GX_VTXFMT0, 4); GX_Position3f32(x1, y1, 0.0f); GX_Color4u8(color.r, color.g, color.b, alpha); GX_Position3f32(x2, y2, 0.0f); GX_Color4u8(color.r, color.g, color.b, alpha); GX_Position3f32(x2, y1, 0.0f); GX_Color4u8(color.r, color.g, color.b, alpha); GX_Position3f32(x1, y2, 0.0f); GX_Color4u8(color.r, color.g, color.b, alpha); GX_End(); GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); }
/** * Additional stuff we need to do before drawing (in this case: update the map) */ void IngameMinimap::BeforeDrawing() { // Ab welcher Knotenanzahl (Teil der Gesamtknotenanzahl) die Textur komplett neu erstellt werden soll static const unsigned MAX_NODES_UPDATE_DENOMINATOR = 2; // (2 = 1/2, 3 = 1/3 usw.) if(!nodesToUpdate.empty()) { // Komplette Textur neu erzeugen, weil es zu viele Knoten sind? if(nodesToUpdate.size() >= map_width * map_height / MAX_NODES_UPDATE_DENOMINATOR) { // Ja, alles neu erzeugen UpdateAll(); for(MapPoint p(0, 0); p.y < map_height; p.y++) for(p.x = 0; p.x < map_width; p.x++) nodes_updated[GetMMIdx(p)] = false; } else { // Entsprechende Pixel updaten for(std::vector<MapPoint>::iterator it = nodesToUpdate.begin(); it != nodesToUpdate.end(); ++it) { for(unsigned t = 0; t < 2; ++t) { unsigned color = CalcPixelColor(*it, t); map.tex_setPixel((it->x * 2 + t + (it->y & 1)) % (map_width * 2), it->y, GetRed(color), GetGreen(color), GetBlue(color), GetAlpha(color)); } nodes_updated[GetMMIdx(*it)] = false; } } this->nodesToUpdate.clear(); } }
/** * * @author OLiver */ void Minimap::CreateMapTexture(const void *param) { map.DeleteTexture(); if(!param) return; /// Buffer für die Daten erzeugen unsigned char *buffer = new unsigned char[map_width * 2 * map_height * 4]; for(MapCoord y = 0;y<map_height;++y) { for(MapCoord x = 0;x<map_width;++x) { // Die 2. Terraindreiecke durchgehen for(unsigned t = 0;t<2;++t) { unsigned color = CalcPixelColor(param,x,y,t); unsigned pos = y*map_width*4*2+(x*4*2+t*4+(y&1)*4)%(map_width*4*2); buffer[pos+2] = GetRed(color); buffer[pos+1] = GetGreen(color); buffer[pos] = GetBlue(color); buffer[pos+3] = GetAlpha(color); } } } map.setFilter(GL_LINEAR); map.create(map_width*2, map_height, buffer, map_width*2, map_height, libsiedler2::FORMAT_RGBA, LOADER.GetPaletteN("pal5")); delete [] buffer; }
//----------------------------------------------------------------------------- // Sets the color + transparency //----------------------------------------------------------------------------- void CBaseShader::SetColorState( int colorVar, bool setAlpha ) { Assert( !IsSnapshotting() ); if ( !s_ppParams ) return; // Use tint instead of color if it was specified... IMaterialVar* pColorVar = (colorVar != -1) ? s_ppParams[colorVar] : 0; float color[4] = { 1.0, 1.0, 1.0, 1.0 }; if (pColorVar) { if (pColorVar->GetType() == MATERIAL_VAR_TYPE_VECTOR) { pColorVar->GetVecValue( color, 3 ); } else { color[0] = color[1] = color[2] = pColorVar->GetFloatValue(); } // Clamp... color[0] = clamp( color[0], 0.0f, 1.0f ); color[1] = clamp( color[1], 0.0f, 1.0f ); color[2] = clamp( color[2], 0.0f, 1.0f ); } color[3] = setAlpha ? GetAlpha() : 1.0f; s_pShaderAPI->Color4fv( color ); }
void duSplitter::DrawObject(HDC hDC) { duRect rectSplitter; Plugin_GetRect(this, &rectSplitter); rectSplitter.OffsetRect(-rectSplitter.left, -rectSplitter.top); DrawByStyle(this, GetStyle(), hDC, &rectSplitter, GetState(), GetText(), GetAlpha()); }
void CASW_VGUI_Computer_Container::OnThink() { BaseClass::OnThink(); float fDeathCamInterp = ASWGameRules()->GetMarineDeathCamInterp(); if ( fDeathCamInterp > 0.0f && GetAlpha() >= 255 ) { SetAlpha( 254 ); vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 0, 0, 0.5f, vgui::AnimationController::INTERPOLATOR_LINEAR); } else if ( fDeathCamInterp <= 0.0f && GetAlpha() <= 0 ) { SetAlpha( 1 ); vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 255, 0, 0.5f, vgui::AnimationController::INTERPOLATOR_LINEAR); } }
Color Color::Modulate(const Color& c) const { uint8 R = static_cast<uint8>(GetRed() * c.GetRed() / 255); uint8 G = static_cast<uint8>(GetGreen() * c.GetGreen() / 255); uint8 B = static_cast<uint8>(GetBlue() * c.GetBlue() / 255); uint8 A = static_cast<uint8>(GetAlpha() * c.GetAlpha() / 255); return Color(R, G, B, A); }
sf::Color rbColor::ToSFML( VALUE aColor ) { aColor = rbColor::ToRuby( aColor ); sf::Uint8 r = NUM2CHR( GetRed( aColor ) ); sf::Uint8 g = NUM2CHR( GetGreen( aColor ) ); sf::Uint8 b = NUM2CHR( GetBlue( aColor ) ); sf::Uint8 a = NUM2CHR( GetAlpha( aColor ) ); return sf::Color( r, g, b, a ); }
void SkeletonSprite::Render() const { // TAREA: Implementar la especificacion del enunciado Renderer::Instance().SetBlendMode( GetBlendMode() ); Renderer::Instance().SetColor( GetRed(), GetGreen(), GetBlue(), GetAlpha() ); glPushMatrix(); glTranslated( GetX(), GetY(), 0 ); root->Render(); glPopMatrix(); }
/** * Zeichnet die Textur. * * @author FloSoft */ void glArchivItem_Bitmap::Draw(short dst_x, short dst_y, short dst_w, short dst_h, short src_x, short src_y, short src_w, short src_h, const unsigned int color, const unsigned int unused) { if(texture == 0) GenerateTexture(); if(texture == 0) return; if(src_w == 0) src_w = width_; if(src_h == 0) src_h = height_; if(dst_w == 0) dst_w = src_w; if(dst_h == 0) dst_h = src_h; VIDEODRIVER.BindTexture(texture); assert(getBobType() != libsiedler2::BOBTYPE_BITMAP_PLAYER); struct GL_T2F_C4UB_V3F_Struct { GLfloat tx, ty; GLubyte r, g, b, a; GLfloat x, y, z; }; GL_T2F_C4UB_V3F_Struct tmp[4]; int x = -nx_ + dst_x; int y = -ny_ + dst_y; tmp[0].x = tmp[1].x = GLfloat(x); tmp[2].x = tmp[3].x = GLfloat(x + dst_w); tmp[0].y = tmp[3].y = GLfloat(y); tmp[1].y = tmp[2].y = GLfloat(y + dst_h); tmp[0].z = tmp[1].z = tmp[2].z = tmp[3].z = 0.0f; tmp[0].tx = tmp[1].tx = (GLfloat)src_x / tex_width_; tmp[2].tx = tmp[3].tx = (GLfloat)(src_x + src_w) / tex_width_; tmp[0].ty = tmp[3].ty = (GLfloat)src_y / tex_height_; tmp[1].ty = tmp[2].ty = (GLfloat)(src_y + src_h) / tex_height_; tmp[0].r = tmp[1].r = tmp[2].r = tmp[3].r = GetRed(color); tmp[0].g = tmp[1].g = tmp[2].g = tmp[3].g = GetGreen(color); tmp[0].b = tmp[1].b = tmp[2].b = tmp[3].b = GetBlue(color); tmp[0].a = tmp[1].a = tmp[2].a = tmp[3].a = GetAlpha(color); glInterleavedArrays(GL_T2F_C4UB_V3F, 0, tmp); glDrawArrays(GL_QUADS, 0, 4); return; }
static int MBAnalyzeBestIntra4Mode(VP8EncIterator* const it, int best_alpha) { uint8_t modes[16]; const int max_mode = (it->enc_->method_ >= FAST_ANALYSIS_METHOD) ? MAX_INTRA4_MODE : NUM_BMODES; int i4_alpha; VP8Histogram total_histo = { { 0 } }; int cur_histo = 0; VP8IteratorStartI4(it); do { int mode; int best_mode_alpha = DEFAULT_ALPHA; VP8Histogram histos[2]; const uint8_t* const src = it->yuv_in_ + Y_OFF + VP8Scan[it->i4_]; VP8MakeIntra4Preds(it); for (mode = 0; mode < max_mode; ++mode) { int alpha; memset(&histos[cur_histo], 0, sizeof(histos[cur_histo])); VP8CollectHistogram(src, it->yuv_p_ + VP8I4ModeOffsets[mode], 0, 1, &histos[cur_histo]); alpha = GetAlpha(&histos[cur_histo]); if (IS_BETTER_ALPHA(alpha, best_mode_alpha)) { best_mode_alpha = alpha; modes[it->i4_] = mode; cur_histo ^= 1; // keep track of best histo so far. } } // accumulate best histogram MergeHistograms(&histos[cur_histo ^ 1], &total_histo); // Note: we reuse the original samples for predictors } while (VP8IteratorRotateI4(it, it->yuv_in_ + Y_OFF)); i4_alpha = GetAlpha(&total_histo); if (IS_BETTER_ALPHA(i4_alpha, best_alpha)) { VP8SetIntra4Mode(it, modes); best_alpha = i4_alpha; } return best_alpha; }
const Color& Color::operator -=(const Color& c) { int R = GetRed() - c.GetRed(); int G = GetGreen() - c.GetGreen(); int B = GetBlue() - c.GetBlue(); int A = GetAlpha() - c.GetAlpha(); SetInt(R, G, B, A); return *this; }
void duIMPanelNode::DrawObject(HDC hDC) { duRect rcIMPanelNode; Plugin_GetRect(this, &rcIMPanelNode); rcIMPanelNode.OffsetRect(-rcIMPanelNode.left, -rcIMPanelNode.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rcIMPanelNode, GetState(), GetText(), GetAlpha()); }
const Color& Color::operator *=(float v) { int R = static_cast<int>(GetRed() * v); int G = static_cast<int>(GetGreen() * v); int B = static_cast<int>(GetBlue() * v); int A = static_cast<int>(GetAlpha() * v); SetInt(R, G, B, A); return *this; }
Color Color::operator +(const Color& c) const { int R = GetRed() + c.GetRed(); int G = GetGreen() + c.GetGreen(); int B = GetBlue() + c.GetBlue(); int A = GetAlpha() + c.GetAlpha(); Color Ret; Ret.SetInt(R, G, B, A); return Ret; }
Color Color::operator *(float v) const { int R = static_cast<int>(GetRed() * v); int G = static_cast<int>(GetGreen() * v); int B = static_cast<int>(GetBlue() * v); int A = static_cast<int>(GetAlpha() * v); Color Ret; Ret.SetInt(R, G, B, A); return Ret; }
bool FRenderStyle::IsVisible(fixed_t alpha) const throw() { if (BlendOp == STYLEOP_None) { return false; } if (BlendOp == STYLEOP_Add || BlendOp == STYLEOP_RevSub) { if (Flags & STYLEF_Alpha1) { alpha = FRACUNIT; } else { alpha = clamp(alpha, 0, FRACUNIT); } return GetAlpha(SrcAlpha, alpha) != 0 || GetAlpha(DestAlpha, alpha) != FRACUNIT; } // Treat anything else as visible. return true; }
void WINAPI duXmlStatic::DrawObject(HDC hDC) { duRect rectStatic; Plugin_GetRect(this, &rectStatic); rectStatic.OffsetRect(-rectStatic.left, -rectStatic.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rectStatic, GetState(), NULL, GetAlpha()); DrawXmlText(hDC); }
void FadeInPanel::OnThink() { // fade out if we're ingame for more than a second if (ASWGameRules() && ASWGameRules()->GetGameState() == ASW_GS_INGAME) { //Msg("FadeInPanel ingame, m_fIngameTime = %f\n", m_fIngameTime); m_fIngameTime += gpGlobals->frametime; if (m_fIngameTime >= 2.0f || m_bFastRemove) { m_bSlowRemove = true; } } if (GetAlpha() >= 255 && m_bSlowRemove) { SetAlpha(254); vgui::GetAnimationController()->RunAnimationCommand(this, "alpha", 0, 0.0f, 1.5f, vgui::AnimationController::INTERPOLATOR_LINEAR); } if (GetAlpha() <= 0) { MarkForDeletion(); } }
void WINAPI duStatic::DrawObject(HDC hDC) { duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup == NULL) return; duRect rcCtrl; rcCtrl.SetRectEmpty(); GetRect(&rcCtrl); rcCtrl.OffsetRect(-rcCtrl.left, -rcCtrl.top); pStyleGroup->Draw(hDC, &rcCtrl, GetState(), GetText(), GetAlpha()); }
/** * zeichnet eine Linie. * * @param[in] x X-Koordinate * * @author jh */ void Window::DrawLine(unsigned short ax, unsigned short ay, unsigned short bx, unsigned short by, unsigned short width, unsigned int color) { glDisable(GL_TEXTURE_2D); glColor4ub(GetRed(color), GetGreen(color), GetBlue(color), GetAlpha(color)); glLineWidth(width); glBegin(GL_LINES); glVertex2i(ax, ay); glVertex2i(bx, by); glEnd(); glEnable(GL_TEXTURE_2D); }