void Boot::Draw(Matrix const &) { Font *font = GetRoot()->GetFont(); SDL_Surface *surface = GetRoot()->GetSurface(); Time now = GetRoot()->TimeNow(); font->DrawText(surface, Matrix::Translate(20,4), Box(), GetRoot()->MakeColor(100,100,100), "build 0-2"); // draw the 'xiq' text rotating underneath std::string xiq = "xiq"; size_t len = xiq.size(); float scale = 8; float angle = now; Matrix M = Matrix::Translate(-(int)len*4,-4) *Matrix::Scale(scale,scale) *Matrix::Rotation(angle) *Matrix::Translate(300,200); font->DrawShadowedText( surface , M , Box(Point(50,50), Point(400,200)) , GetRoot()->MakeColor(255,0,0) , xiq.c_str()); font->DrawShadowedText( surface , M*Matrix::Translate(1,1) , Box(Point(50,50), Point(400,200)) , GetRoot()->MakeColor(0,255,0) , xiq.c_str()); font->DrawShadowedText( surface , M*Matrix::Translate(2,2) , Box(Point(50,50), Point(400,200)) , GetRoot()->MakeColor(0,0,255) , xiq.c_str()); // draw 'press space' zooming in and out { std::string text = "press-space"; size_t len = text.size(); float scale = 4 + 1.5*sin(now*2); Matrix M = Matrix::Translate(-(int)len*4 - 2,-4) *Matrix::Scale(scale,scale) *Matrix::Translate(300,200); font->DrawShadowedText( surface , M , Box(Point(50,50), Point(400,200)) , GetRoot()->MakeColor(255,255,255) , text.c_str()); } }
void EditControl::OnPaint(DibBitmap *pbm) { Font *pfnt = gapfnt[m_nfnt]; Rect rcForm; m_pfrm->GetRect(&rcForm); int x = m_rc.left + rcForm.left; int y = m_rc.top + rcForm.top; pbm->Fill(x, y + m_rc.Height() - 1, m_rc.Width(), 1, GetColor(kiclrButtonBorder)); pfnt->DrawText(pbm, m_szText, x + 1, y); }
/* add a button */ void Menu::CreateButton(string fontPath, string t, int posx, int posy, int size, SDL_Color c, SDL_Color shadow) { Font font = Font(fontPath.c_str(), APP->GetRenderer()); font.SetStyle(true, true, size); font.SetPos(posx, posy, true); font.SetColors(c, shadow); font.DrawText(t); }
void PruebaVentana::Render( double elapsed ) { m_d3ddevice.Clear(ClearFlags_Target |ClearFlags_ZBuffer, D3DCOLOR_XRGB(0,40,100),1.0f,0); m_d3ddevice.BeginScene(); static float index = 0; index += 1.5f*elapsed; Matrix matView; matView.LookAtLH(Vector3(3.0f, 1.0f, 3.0f),Vector3(0.0f,0.0f,0.0f), Vector3(0.0f,1.0f,0.0f)); m_d3ddevice.Transform.View = matView; Matrix matProjection; matProjection.PerspectiveFovLH( D3DXToRadian(45),m_aspect_ratio,1.0f,100.0f); m_d3ddevice.Transform.Projection = matProjection; Matrix matTranslate; matTranslate.RotationY(index); mesh.SetTransform(matTranslate); m_d3ddevice.Transform.World = matTranslate; effect.SetTechnique("Default"); effect.SetValue("matWorldViewProj",matTranslate*matView*matProjection); effect.SetValue("base_Tex",mesh.m_textures[0]); //effect.Begin(FX_None); //effect.BeginPass(0); mesh.Render(); char fps[100]; sprintf(fps,"FPS:%d",m_timer.m_fps); font.DrawText(NULL,fps,WRectangle(0,00,100,100),DrawTextFormat_NoClip,0xFFFFFF00); //effect.EndPass(); //effect.End(); m_d3ddevice.EndScene(); m_d3ddevice.Present(); }
void LabelControl::OnPaint(DibBitmap *pbm) { if (m_szLabel == NULL) return; Rect rcForm; m_pfrm->GetRect(&rcForm); Font *pfnt = gapfnt[m_nfnt]; if (m_wf & kfLblMultiLine) { Font *pfnt = gapfnt[m_nfnt]; int cyClip = -1; if (m_wf & kfLblClipVertical) { cyClip = m_rc.Height(); } pfnt->DrawText(pbm, m_szLabel, m_rc.left + rcForm.left, m_rc.top + rcForm.top, m_rc.Width(), cyClip, (m_wf & kfLblEllipsis) != 0); } else { DrawFancyText(pbm, pfnt, m_szLabel, m_rc.left + rcForm.left, m_rc.top + rcForm.top); } }
int FancyTextCore(DibBitmap *pbm, Font *pfntDefault, char *psz, int x, int y, int cch, bool fGetExtent) { dword *mpscaiclr = NULL; Font *pfnt = pfntDefault; if (cch == 0) cch = (int)strlen(psz); int cx = 0; int cchT = cch; char *pchT = psz; while (cchT > 0) { char ch = *pchT++; cchT--; if (ch == '@') { if (pchT != psz + 1) { if (fGetExtent) { cx += pfnt->GetTextExtent(psz, (int)(pchT - psz - 1)); } else { cx += pfnt->DrawText(pbm, psz, x, y, (int)(pchT - psz - 1), mpscaiclr); x += cx; } psz = pchT; } switch (*pchT) { // "@@" outputs a single @ case '@': cchT--; psz = pchT++; continue; // "@S." turns on mapping to local player's side color case 'S': mpscaiclr = TBitmap::s_ampscaiclrSide[gpplrLocal->GetSide()]; cchT--; pchT++; break; } Assert(*pchT == '.'); // Skip past '.' cchT--; pchT++; psz = pchT; } } if (pchT != psz) { if (fGetExtent) cx += pfnt->GetTextExtent(psz, (int)(pchT - psz)); else cx += pfnt->DrawText(pbm, psz, x, y, (int)(pchT - psz), mpscaiclr); } return cx; }