void UILoadingTransition::Draw(const UIGeometricData &geometricData) { if (backgroundSprite) { Sprite::DrawState drawState; drawState.SetRenderState(RenderState::RENDERSTATE_2D_BLEND); drawState.SetPosition(geometricData.position); backgroundSprite->Draw(&drawState); } if (animationSprite) { int frame = (int32)((animationTime/animationDuration) * animationSprite->GetFrameCount()); if (frame > animationSprite->GetFrameCount() - 1) frame = animationSprite->GetFrameCount() - 1; Sprite::DrawState drawState; drawState.SetRenderState(RenderState::RENDERSTATE_2D_BLEND); drawState.SetFrame(frame); drawState.SetPosition(geometricData.position); animationSprite->Draw(&drawState); } }
void PVRTest::Draw(const DAVA::UIGeometricData &geometricData) { RenderManager::Instance()->ClearWithColor(0.f, 0.0f, 0.f, 1.f); Sprite::DrawState state; state.SetFrame(0); if(pngSprite) { state.SetPosition(0.f, 0.f); state.SetScaleSize(256.f, 256.f, pngSprite->GetWidth(), pngSprite->GetHeight()); pngSprite->Draw(&state); } if(pvrSprite) { state.SetPosition(260.f, 0.f); state.SetScaleSize(256.f, 256.f, pvrSprite->GetWidth(), pvrSprite->GetHeight()); pvrSprite->Draw(&state); } TestTemplate<PVRTest>::Draw(geometricData); }
Size2i GraphicsFont::DrawString(float32 x, float32 y, const WideString & string, int32 justifyWidth) { uint32 length = (uint32)string.length(); if(length==0) return Size2i(); uint16 prevChIndex = GraphicsFontDefinition::INVALID_CHARACTER_INDEX; Sprite::DrawState state; state.SetPerPixelAccuracyUsage(true); float32 currentX = x; float32 currentY = y; float32 sizeFix = 0.0f; //Logger::Debug("%S startX:%f", string.c_str(), currentX); RenderManager::Instance()->SetColor(color); for (uint32 indexInString = 0; indexInString < length; ++indexInString) { char16 c = string[indexInString]; uint16 chIndex = fdef->CharacterToIndex(c); if (indexInString == 0) { sizeFix = fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::X_OFFSET_TO_ACTIVE) * fontScaleCoeff; currentX -= sizeFix; } if (chIndex == GraphicsFontDefinition::INVALID_CHARACTER_INDEX) { if(c != '\n') Logger::Debug("*** Error: can't find character %c in font", c); continue; } if (prevChIndex != GraphicsFontDefinition::INVALID_CHARACTER_INDEX) { //Logger::Debug("kern: %c-%c = %f", string[indexInString - 1], c, GetDistanceFromAtoB(prevChIndex, chIndex)); currentX += GetDistanceFromAtoB(prevChIndex, chIndex); } state.SetFrame(chIndex); // draw on baseline Y = currentY - fontSprite->GetHeight() + charTopBottomPadding + fontDescent float32 drawX = currentX; float32 drawY = currentY - fontSprite->GetHeight() * fontScaleCoeff + (fdef->charTopBottomPadding + fdef->fontDescent + fdef->fontAscent) * fontScaleCoeff; //if (indexInString != 0) drawX += fdef->characterPreShift[chIndex] * fontScaleCoeff; state.SetScale(fontScaleCoeff, fontScaleCoeff); state.SetPosition(drawX, drawY); fontSprite->Draw(&state); // RenderManager::Instance()->SetColor(1.0f, 0.0f, 0.0f, 1.0f); // RenderManager::Instance()->DrawRect(Rect(drawX + fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::X_OFFSET_TO_ACTIVE) * fontScaleCoeff, drawY + fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::Y_OFFSET_TO_ACTIVE) * fontScaleCoeff, fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::ACTIVE_WIDTH), fontSprite->GetHeight() * fontScaleCoeff)); // RenderManager::Instance()->ResetColor(); currentX += (fdef->characterWidthTable[chIndex] + horizontalSpacing) * fontScaleCoeff; // Logger::Debug("%c w:%f pos: %f\n", c, fdef->characterWidthTable[chIndex] * fontScaleCoeff, currentX); // if (c == ' ')currentX += fdef->characterWidthTable[chIndex] * fontScaleCoeff; // else currentX += fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::ACTIVE_WIDTH) * fontScaleCoeff; prevChIndex = chIndex; } RenderManager::Instance()->ResetColor(); currentX -= (fdef->characterWidthTable[prevChIndex] + horizontalSpacing) * fontScaleCoeff; currentX += (fdef->characterPreShift[prevChIndex] + fontSprite->GetRectOffsetValueForFrame(prevChIndex, Sprite::ACTIVE_WIDTH)) * fontScaleCoeff; // characterWidthTable[prevChIndex]; // Sprite::DrawState drwState; // float32 drawX = 100; // float32 drawY = 100; // drwState.SetFrame(1); // drwState.SetPosition(drawX, drawY); // fontSprite->Draw(&drwState); // // RenderManager::Instance()->SetColor(1.0f, 0.0f, 0.0f, 1.0f); // RenderManager::Instance()->DrawRect(Rect(drawX + fontSprite->GetRectOffsetValueForFrame(1, Sprite::X_OFFSET_TO_ACTIVE) * fontScaleCoeff // , drawY + fontSprite->GetRectOffsetValueForFrame(1, Sprite::Y_OFFSET_TO_ACTIVE) * fontScaleCoeff // , fdef->characterWidthTable[1] // , fontSprite->GetHeight() * fontScaleCoeff)); // RenderManager::Instance()->ResetColor(); return Size2i((int32)(currentX + sizeFix + 1.5f - x), GetFontHeight()); }