本文整理汇总了C++中Font::DrawText方法的典型用法代码示例。如果您正苦于以下问题:C++ Font::DrawText方法的具体用法?C++ Font::DrawText怎么用?C++ Font::DrawText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Font
的用法示例。
在下文中一共展示了Font::DrawText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
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());
}
}
示例2: OnPaint
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);
}
示例3: CreateButton
/* 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);
}
示例4: Render
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();
}
示例5: FancyTextCore
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;
}