void TextureResourceLoader::initTitleTexture(const String& pathImage)
{
	this->titleTexture	= Texture(pathImage);
	this->tMain			= this->titleTexture.uv(RectF(Vec2(  0.0,  0.0), Vec2(384.0, 64.0)));
	this->tSub			= this->titleTexture.uv(RectF(Vec2(384.0, 24.0), Vec2( 88.0, 36.0)));
	this->tSpace		= this->titleTexture.uv(RectF(Vec2( 16.0, 72.0), Vec2(224.0, 18.0)));
}
Esempio n. 2
0
// 画图片信息
void CPopupList::DrawWindowEx(CDC &dc, CRect rcClient)
{
	int nItemCount =  m_vecItem.size();
	CRect rcItem;
	CSize sizeImage;
	Graphics graphics(dc);

	for(int i = 0; i < nItemCount; i++)
	{
		EditListItem &editListItem = m_vecItem.at(i);
		rcItem = editListItem.rcItem;
		sizeImage = editListItem.sizeImage;

		// 删除按钮
		if((i == m_nHoverItem) && (m_pImageClose != NULL))
		{
			graphics.DrawImage(m_pImageClose, RectF((Gdiplus::REAL)m_rcClose.left, (Gdiplus::REAL)m_rcClose.top, (Gdiplus::REAL)m_rcClose.Width(), (Gdiplus::REAL)m_rcClose.Height()),
				(Gdiplus::REAL)(m_buttonState * m_sizeClose.cx), 0, (Gdiplus::REAL)m_sizeClose.cx, (Gdiplus::REAL)m_sizeClose.cy, UnitPixel); 
		}

		// 列表图片
		if(editListItem.pImage)
		{	
			CRect rcHead(rcItem.left + 1, rcItem.top + 2, rcItem.left + 1 + rcItem.Height() - 4, rcItem.top + 2 + rcItem.Height() - 4);
			graphics.DrawImage(editListItem.pImage, RectF((Gdiplus::REAL)rcHead.left, (Gdiplus::REAL)rcHead.top, (Gdiplus::REAL)rcHead.Width(), (Gdiplus::REAL)rcHead.Height()),
				0, 0, (Gdiplus::REAL)editListItem.sizeImage.cx, (Gdiplus::REAL)editListItem.sizeImage.cy, UnitPixel);

			DrawImageFrame(graphics, m_pImageHead, rcHead, i == m_nHoverItem ? m_sizeHead.cx : 0, 0, m_sizeHead.cx, m_sizeHead.cy, 5);
		}
	}
}
Esempio n. 3
0
GraphicsPath* GdipCreateRoundRect( RectF& rect, int nRadiusLT, int nRadiusRT, int nRadiusRB, int nRadiusLB )
{
	GraphicsPath roundRect;
	if( nRadiusLT == 0 )
		roundRect.AddLine( rect.GetLeft(), rect.GetTop(), rect.GetRight() - (nRadiusRT<<1), rect.GetTop() );
	else
		roundRect.AddArc( RectF(rect.GetLeft(), rect.GetTop(), (float)(nRadiusLT<<1), (float)(nRadiusLT<<1)), 180, 90 );

	if( nRadiusRT == 0 )
		roundRect.AddLine( rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom()-(float)(nRadiusRB<<1) );
	else
		roundRect.AddArc( RectF(rect.GetRight() - (float)(nRadiusRT<<1), rect.GetTop(), (float)(nRadiusRT<<1), (float)(nRadiusRT<<1)), 270, 90 );

	if( nRadiusRB == 0 )
		roundRect.AddLine( rect.GetRight(), rect.GetBottom(), rect.GetLeft()-(float)(nRadiusLB<<1), rect.GetBottom() );
	else
		roundRect.AddArc( RectF(rect.GetRight() - (float)(nRadiusRB<<1), rect.GetBottom() -(float)(nRadiusRB<<1), (float)(nRadiusRB<<1), (float)(nRadiusRB<<1)), 0, 90 );

	if( nRadiusLB == 0 )
		roundRect.AddLine( rect.GetLeft(), rect.GetBottom(), rect.GetLeft(), rect.GetTop()-(float)(nRadiusLT<<1) );
	else
		roundRect.AddArc( RectF(rect.GetLeft(), rect.GetBottom() -(float)(nRadiusLB<<1), (float)(nRadiusLB<<1), (float)(nRadiusLB<<1)), 90, 90 );

	roundRect.CloseFigure();

	return roundRect.Clone();
}
Esempio n. 4
0
		[[nodiscard]] inline Array<RectF> GetBlackBars(const Size& baseSize = Window::BaseSize())
		{
			const double sx = static_cast<double>(Window::Width()) / baseSize.x;
	
			const double sy = static_cast<double>(Window::Height()) / baseSize.y;
	
			const double s = Min(sx, sy);
	
			if (sx < sy)
			{
				const double h = (Window::Height() - baseSize.y * s) * 0.5;
	
				return Array<RectF>{ RectF(0, 0, Window::Width(), h), RectF(0, Window::Height() - h,Window::Width(), h) };
			}
			else if (sx > sy)
			{
				const double w = (Window::Width() - baseSize.x * s) * 0.5;
	
				return Array<RectF>{ RectF(0, 0, w, Window::Height()), RectF(Window::Width() - w, 0, w, Window::Height()) };
			}
			else
			{
				return Array<RectF>();
			}
		}
	CoreRectangleShape_Imp::CoreRectangleShape_Imp()
		:drawingArea(RectF())
		, uv(RectF())
		, angle(0)
	{

	}
void TextureResourceLoader::divideBackgroundGraphs(const Image& baseImage)
{
	const auto bkSize = Vec2(321.0f, 241.0f);

	this->bkFrontSun	=  Texture(clipImage(baseImage, RectF(Vec2( 334.0, 10.0), bkSize), tsTransColor));
	this->bkSun			=  Texture(clipImage(baseImage, RectF(Vec2(1630.0, 10.0), Vec2(97.0, 97.0)), tsTransColor));
	this->bkBehindSun	=  Texture(clipImage(baseImage, RectF(Vec2( 658.0, 10.0), bkSize), tsTransColor));
	this->bkBuildings.emplace_back(clipImage(baseImage, RectF(Vec2( 982.0, 10.0), bkSize), tsTransColor));
	this->bkBuildings.emplace_back(clipImage(baseImage, RectF(Vec2(1306.0, 10.0), bkSize), tsTransColor));
}
void TextureResourceLoader::divideMapchipGraphs(const Image& baseImage)
{
	const auto mcSize = Vec2(17.0, 17.0);

	this->mcTop			= Texture(clipImage(baseImage, RectF(Vec2(5.0, 5.0), mcSize), tsTransColor));
	this->mcRoad		= Texture(clipImage(baseImage, RectF(Vec2(5.0 + 20.0, 5.0), mcSize), tsTransColor));
	this->mcGrass		= Texture(clipImage(baseImage, RectF(Vec2(5.0 + 40.0, 5.0), mcSize), tsTransColor));
	this->mcGrassUnder	= Texture(clipImage(baseImage, RectF(Vec2(5.0 + 60.0, 5.0), mcSize), tsTransColor));
	this->mcUnder		= Texture(clipImage(baseImage, RectF(Vec2(5.0 + 80.0, 5.0), mcSize), tsTransColor));
}
 AnimationFrame::AnimationFrame(spNativeTexture t)
 {
     _row = _column = 0;
     _resAnim = 0;
     _diffuse.base = t;
     _diffuse.premultiplied = true;
     _srcRect = RectF(0, 0, 1, 1);
     _destRect = RectF(0, 0, (float)t->getWidth(), (float)t->getHeight());
     _frameSize = Vector2((float)t->getWidth(), (float)t->getHeight());
 }
Esempio n. 9
0
	RectF FontData::getRegion(const String& codePoints, const double lineSpacingScale)
	{
		if (!render(codePoints))
		{
			return RectF(0);
		}

		Vec2 penPos(0, 0);
		Vec2 minPos(DBL_MAX, DBL_MAX);
		Vec2 maxPos(DBL_MIN, DBL_MIN);
		int32 lineCount = 0;

		for (const auto codePoint : codePoints)
		{
			if (codePoint == U'\n')
			{
				penPos.x = 0;
				penPos.y += m_lineSpacing * lineSpacingScale;
				++lineCount;
			}
			else if (codePoint == U'\t')
			{
				minPos.x = std::min(minPos.x, penPos.x);
				minPos.y = std::min(minPos.y, penPos.y + m_ascender);
				maxPos.x = std::max(maxPos.x, penPos.x + m_tabWidth);
				maxPos.y = std::max(maxPos.y, penPos.y);
				penPos.x += m_tabWidth;
			}
			else if (!IsControl(codePoint))
			{
				if (lineCount == 0)
				{
					++lineCount;
				}

				const auto& glyphInfo = m_glyphs[m_glyphIndexTable[codePoint]];
				const RectF region(penPos + glyphInfo.offset, glyphInfo.bitmapRect.size);
				const int32 characterWidth = glyphInfo.xAdvance;
				minPos.x = std::min(minPos.x, region.x);
				minPos.y = std::min(minPos.y, region.y);
				maxPos.x = std::max(maxPos.x, penPos.x + characterWidth);
				maxPos.y = std::max(maxPos.y, region.y + region.h);
				penPos.x += glyphInfo.xAdvance;
			}
		}

		if (minPos == Vec2(DBL_MAX, DBL_MAX))
		{
			return RectF(0);
		}

		return RectF(0, 0, maxPos.x, lineCount * m_lineSpacing * lineSpacingScale);
	}
Esempio n. 10
0
void CPropSelUser::drawSkin(void)
{

	if(!imgDialog)
		return;
	CDC *pdc=this->GetWindowDC();
	if(!pdc)return;
	CRect rc;
	this->GetWindowRect(&rc);
	Graphics g(pdc->m_hDC);

	int topHeight=32;//GetSystemMetrics(SM_CYFRAME)+GetSystemMetrics(SM_CYSIZE)+6;
	g.DrawImage(imgDialog,RectF(0.0f,0.0f,10.0f,topHeight),0.0f,0.0f,10.0f,topHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(10.0f,0.0f,rc.Width()-20,topHeight),9.0f,0.0f,1.0f,topHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF((REAL)rc.Width()-10,0.0f,10.0f,topHeight),imgDialog->GetWidth()-10,0.0f,10.0f,topHeight,UnitPixel);
	m_bkColor=pdc->GetPixel(9,topHeight-1);
	m_txtColor^=m_bkColor;
	int bottomHeight=10;
	g.DrawImage(imgDialog,RectF(0.0f,topHeight,10.0f,rc.Height()-topHeight-bottomHeight),0.0f,topHeight,10.0f,imgDialog->GetHeight()-topHeight-bottomHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(rc.Width()-10.0f,topHeight,10.0f,rc.Height()-topHeight-bottomHeight),
		imgDialog->GetWidth()-10,topHeight,10.0f,1,UnitPixel);

	g.DrawImage(imgDialog,RectF(0,rc.Height()-bottomHeight,imgDialog->GetWidth()-5,bottomHeight),0,imgDialog->GetHeight()-bottomHeight,10,bottomHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(10,rc.Height()-bottomHeight,rc.Width()-20,bottomHeight),10,imgDialog->GetHeight()-bottomHeight,1,bottomHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(rc.Width()-10,rc.Height()-bottomHeight,10,bottomHeight),imgDialog->GetWidth()-10,imgDialog->GetHeight()-bottomHeight,10,bottomHeight,UnitPixel);

	CString s="宋体";

	Font font(s.AllocSysString(),12,0,UnitPixel);
	SolidBrush brush(Color(255,255,255));
	s.Format("请选择道具 [%s] 使用对象,当前游戏中有 %d 个可用用户对象",propItemName,maxUser);
	g.DrawString(s.AllocSysString(),-1,&font,PointF(5,5),0,&brush);
	
	StringFormat sf;
	sf.SetAlignment(StringAlignmentCenter);

	m_bnClose.Invalidate(FALSE);
	brush.SetColor(Color(0,0,0));
	Pen pen(&brush);//20081128
	REAL x,y,w,h; //20081128,计算具体图片的位置
	for(int i=0;i<maxUser;i++)
	{
		x=userRect[i].left+(66-userImg[i]->GetWidth())/2;
		y=userRect[i].top+(105-userImg[i]->GetHeight())/2;
		w=userImg[i]->GetWidth();
		h=userImg[i]->GetHeight();
		g.DrawImage(userImg[i],x,y,w,h);//画头像,替换原来的画头像代码
		//画选择区域边框
		g.DrawRectangle(&pen,userRect[i].left , userRect[i].top , 
			userRect[i].Width() , userRect[i].Height());
		g.DrawString(userName[i].AllocSysString() ,-1 ,&font , 
			RectF(userRect[i].left,userRect[i].bottom+5,userRect[i].Width(),30),&sf,&brush);
	}
	g.ReleaseHDC(pdc->m_hDC);
}
        TextureLine(spNativeTexture t)
        {
            setVerticalMode(Box9Sprite::TILING_FULL);
            setHorizontalMode(Box9Sprite::TILING_FULL);
            Sprite::setResAnim(DebugActor::resSystem->getResAnim("checker"));

            AnimationFrame f;
            Vector2 s = fitSize(itemSize, Vector2((float)t->getWidth(), (float)t->getHeight()));

            setSize(s);

            Diffuse df;
            df.base = t;

            f.init(0, df, RectF(0, 0, 1.0f, 1.0f), RectF(0, 0, s.x, s.y), s);
            spSprite image = initActor(new Sprite,
                                       arg_blend = blend_disabled,
                                       arg_resAnim = f);
            addChild(image);

            spColorRectSprite rect = initActor(new ColorRectSprite,
                                               arg_color = Color(Color::White, 255),
                                               arg_attachTo = this);

            rect->addTween(Sprite::TweenColor(Color(Color::White, 0)), 4000, -1, true);

            char path[255];
            path::normalize(t->getName().c_str(), path);

            char txt[255];
            safe_sprintf(txt, "%s\n<div c=\"FF0000\">%s</div>-<div c=\"0000ff\">%dx%d</div>\nid: %d",
                         path,
                         textureFormat2String(t->getFormat()),
                         t->getWidth(), t->getHeight(), t->getObjectID());

            spTextField text = initActor(new TextField,
                                         arg_color = Color::Black,
                                         arg_w = (float)itemSize.x,
                                         arg_vAlign = TextStyle::VALIGN_TOP,
                                         arg_hAlign = TextStyle::HALIGN_LEFT,
                                         arg_multiline = true,
                                         arg_attachTo = rect,
                                         arg_htmlText = txt
                                        );

            text->setBreakLongWords(true);

            rect->setSize(text->getTextRect().size.cast<Vector2>() + Vector2(2, 2));
            rect->setY((itemSize.y - rect->getHeight()) / 2.0f);
        }
Esempio n. 12
0
void Actor::TweenState::Init()
{
	pos	= RageVector3( 0, 0, 0 );
	rotation = RageVector3( 0, 0, 0 );
	quat = RageVector4( 0, 0, 0, 1 );
	scale = RageVector3( 1, 1, 1 );
	crop = RectF( 0,0,0,0 );
	fade = RectF( 0,0,0,0 );
	fadecolor = RageColor( 1, 1, 1, 0 );
	for(int i=0; i<4; i++) 
		diffuse[i] = RageColor( 1, 1, 1, 1 );
	glow = RageColor( 1, 1, 1, 0 );
	glowmode = GLOW_WHITEN;
}
Esempio n. 13
0
	RectF FontData::draw(const String& codePoints, const Vec2& pos, const ColorF& color, double lineSpacingScale)
	{
		if (!render(codePoints))
		{
			return RectF(pos, 0);
		}
		
		Vec2 penPos(pos);
		double maxPosX = DBL_MIN;
		int32 lineCount = 0;
		
		for (const auto codePoint : codePoints)
		{
			if (codePoint == U'\n')
			{
				penPos.x = pos.x;
				penPos.y += m_lineSpacing * lineSpacingScale;
				++lineCount;
				continue;
			}
			else if (codePoint == U'\t')
			{
				maxPosX = std::max(maxPosX, penPos.x + m_tabWidth);
				penPos.x += m_tabWidth;
				continue;
			}
			else if (!IsControl(codePoint))
			{
				if (lineCount == 0)
				{
					++lineCount;
				}

				const auto& glyphInfo = m_glyphs[m_glyphIndexTable[codePoint]];
				const RectF region = m_texture(glyphInfo.bitmapRect).draw(penPos + glyphInfo.offset, color);
				const int32 characterWidth = glyphInfo.xAdvance;
				maxPosX = std::max(maxPosX, region.x + characterWidth);
				penPos.x += glyphInfo.xAdvance;
			}
		}

		if (!lineCount)
		{
			return RectF(pos, 0);
		}
		
		return RectF(pos, maxPosX - pos.x, lineCount * m_lineSpacing * lineSpacingScale);
	}
EnermyWhiteBullet::EnermyWhiteBullet(float x, float y, bool  isBoosting, float angle, int kindBullet)
{
	pData = new SpriteData();

	pData -> isHittable = false;

	pData->isDesTroyed = false;

	this->kindBullet = kindBullet;

	pData->ppTextureArrays = new TextureArray*[2];

	pData->ppTextureArrays[0] = new TextureArray("Resources\\Sprites\\Bullets", "wbullet", "", 1, 10);

	pData->ppTextureArrays[0]->setAnchorPoint(0.5f, 0.5f);

	pData->ppTextureArrays[1] = new TextureArray("Resources\\Sprites\\Bullets", "tankbullet", "", 1, 10);

	pData->ppTextureArrays[1]->setAnchorPoint(0.5f, 0.5f);

	pData->x = x;

	pData->y = y;

	pData->body = RectF(-pData->ppTextureArrays[kindBullet]->getWidth() / 2, -pData->ppTextureArrays[0]->getHeight(), pData->ppTextureArrays[0]->getWidth(), pData->ppTextureArrays[0]->getHeight());

	pData->pState = new BulletMovingState(pData, 1.0f, angle, 0);
}
Esempio n. 15
0
// http://www.codeproject.com/KB/GDI-plus/measurestring.aspx
RectF MeasureTextAccurate(Graphics* g, Font* f, const WCHAR* s, int len) {
    if (0 == len) {
        return RectF(0, 0, 0, 0); // TODO: should set height to font's height
    }
    // note: frankly, I don't see a difference between those StringFormat variations
    StringFormat sf(StringFormat::GenericTypographic());
    sf.SetFormatFlags(sf.GetFormatFlags() | StringFormatFlagsMeasureTrailingSpaces);
    // StringFormat sf(StringFormat::GenericDefault());
    // StringFormat sf;
    RectF layoutRect;
    CharacterRange cr(0, len);
    sf.SetMeasurableCharacterRanges(1, &cr);
    Region r;
    Status status = g->MeasureCharacterRanges(s, len, f, layoutRect, &sf, 1, &r);
    if (status != Ok) {
        // TODO: remove whem we figure out why we crash
        if (!s) {
            s = L"<null>";
        }
        auto s2 = str::conv::ToUtf8(s, (size_t)len);
        dbglog::CrashLogF("MeasureTextAccurate: status: %d, font: %p, len: %d, s: '%s'\n", (int)status, f, len,
                          s2.Get());
        CrashIf(status != Ok);
    }
    RectF bbox;
    r.GetBounds(&bbox, g);
    if (bbox.Width != 0)
        bbox.Width += PER_STR_DX_ADJUST + (PER_CHAR_DX_ADJUST * (float)len);
    return bbox;
}
Esempio n. 16
0
void StreamDisplay::Load( const RString & /* unreferenced: _sMetricsGroup  */)
{
	// XXX: actually load from the metrics group passed in -aj
	RString sMetricsGroup = "StreamDisplay";

	m_transformPill.SetFromReference( THEME->GetMetricR(sMetricsGroup,"PillTransformFunction") );
	VELOCITY_MULTIPLIER.Load(sMetricsGroup, "VelocityMultiplier");
	VELOCITY_MIN.Load(sMetricsGroup, "VelocityMin");
	VELOCITY_MAX.Load(sMetricsGroup, "VelocityMax");
	SPRING_MULTIPLIER.Load(sMetricsGroup, "SpringMultiplier");
	VISCOSITY_MULTIPLIER.Load(sMetricsGroup, "ViscosityMultiplier");

	float fTextureCoordScaleX = THEME->GetMetricF(sMetricsGroup,"TextureCoordScaleX");
	int iNumPills = static_cast<int>(THEME->GetMetricF(sMetricsGroup,"NumPills"));
	m_bAlwaysBounce = THEME->GetMetricB(sMetricsGroup,"AlwaysBounceNormalBar");

	FOREACH_ENUM( StreamType, st )
	{
		ASSERT( m_vpSprPill[st].empty() );

		for( int i=0; i<iNumPills; i++ )
		{
			Sprite *pSpr = new Sprite;

			pSpr->Load( THEME->GetPathG( sMetricsGroup, StreamTypeToString(st) ) );
			m_vpSprPill[st].push_back( pSpr );

			m_transformPill.TransformItemDirect( *pSpr, -1, i, iNumPills );
			float f = 1 / fTextureCoordScaleX;
			pSpr->SetCustomTextureRect( RectF(f*i,0,f*(i+1),1) );

			this->AddChild( pSpr );
		}
	}
Esempio n. 17
0
VOID DUI_ImageButton::Draw(DUI_Status s)
{
	m_MemDC->Clear();
	if (m_bVisialbe)
	{
		if (s == S_Invalid)
		{
			s = m_CurState;
		}
		Image* pImg;
		if (m_StatusImage[0] == nullptr)
		{
			pImg = m_StatusImage[s];
			//ASSERT(pImg != nullptr);
			m_MemDC->graphics->DrawImage(pImg, 0, 0);
		}
		else
		{
			pImg = m_StatusImage[0];
			if (s == S_Focus || s == S_Disabled)
			{
				s = S_Normal;
			}
			m_MemDC->graphics->DrawImage(pImg, RectF(0.0, 0.0, m_Rect->Width, m_Rect->Height), m_Start + (s - 1)*m_Rect->Width, 0.0, m_Rect->Width, m_Rect->Height, UnitPixel);
		}
		if (m_Text != nullptr)
		{
			SolidBrush TextBrush(*m_Text->color);
			INT offset = (m_bMouseDown) ? 1 : 0;
			m_MemDC->graphics->DrawString(m_Text->string->GetString(), m_Text->string->GetLength(), m_Text->font, RectF(m_Text->rect->X + offset, m_Text->rect->Y + offset, m_Text->rect->Width, m_Text->rect->Height), m_Text->format, &TextBrush);
		}
		DUI_ControlBase::Draw();
	}
	return VOID();
}
bool ShapeView::onAdd()
{
   RectF rect;
   float width, height;

   if (Parent::onAdd())
   {
      active = true;
      camera = new TSPerspectiveCamera(
         RectI(Point2I(0, 0),       Point2I(0, 0)),
         RectF(Point2F(0.0f, 0.0f), Point2F(0.0f, 0.0f)),
         256.0f, 1.0E8f);

      scene = new TSSceneLighting;
      scene->setAmbientIntensity(ColorF(0.7f, 0.7f, 0.7f));

      light = new TSLight;
      light->setType(TS::Light::LightDirectional);
      light->setIntensity(1.0f, 1.0f, 1.0f);
      scene->installLight(light);

      return (true);
   }

   return (false);
}
Esempio n. 19
0
	TexturedQuad TextureRegion::rotatedAt(const double x, const double y, const double angle) const
	{
		return TexturedQuad(texture,
			uvRect,
			RectF(size).rotatedAt(x, y, angle),
			Float2(x, y));
	}
    AnimationFrame AnimationFrame::getClipped(const RectF& rect) const
    {
        AnimationFrame f = *this;
        float w = (float)_diffuse.base->getWidth();
        float h = (float)_diffuse.base->getHeight();

        f._destRect.clip(rect);
        if (f._destRect.isEmpty())
            f._destRect = RectF(0, 0, 0, 0);


        RectF srcRect = _srcRect * Vector2(w, h);

        float sc = 1.0f;//(float)srcRect.getWidth() / f._destRect.getWidth();
        if (_resAnim)
            sc = _resAnim->getScaleFactor();


        f._srcRect.pos = srcRect.pos - (_destRect.pos - f._destRect.pos) * sc;
        f._srcRect.size = srcRect.size - (_destRect.size - f._destRect.size) * sc;
        f._srcRect = f._srcRect / Vector2(w, h);

        f._frameSize = rect.size;
        f._destRect.pos -= rect.pos;

        return f;
    }
Esempio n. 21
0
	TexturedQuad TextureRegion::rotated(const double angle) const
	{
		return TexturedQuad(texture,
			uvRect,
			RectF(size).rotated(angle),
			size * 0.5f);
	}
Esempio n. 22
0
RectF TextureFilm::get(int id)
{
	std::map<int, RectF>::iterator itr = frames.find(id);
	if (itr != frames.end()) return itr->second;

	return RectF();
}
Esempio n. 23
0
	void KeyHandlesSheet::Draw()
	{
		if (!mResEnabledInHierarchy)
			return;

		Widget::OnDrawn();
		CursorAreaEventsListener::OnDrawn();

		o2Render.EnableScissorTest(layout->GetWorldRect());

		if (mSelectionFrame->enabled) {
			auto offsets = mIsFrameSelecting ? mSelectionFrameCursorOffsets : mSelectionFrameOffsets;
			mSelectionFrame->SetRect(RectF(mTimeline->LocalToWorld(mSelectionRect.left) + offsets.left,
										   mTree->GetLineWorldPosition(mSelectionRect.top) + offsets.top,
										   mTimeline->LocalToWorld(mSelectionRect.right) + offsets.right,
										   mTree->GetLineWorldPosition(mSelectionRect.bottom) + offsets.bottom));
			mSelectionFrame->Draw();

			mCenterFrameDragHandle.Draw();
			mLeftFrameDragHandle.Draw();
			mRightFrameDragHandle.Draw();
		}

		o2Render.DisableScissorTest();

		DrawDebugFrame();
	}
Esempio n. 24
0
	Polygon Quad::asPolygon() const
	{
		const auto [xMin, xMax] = std::minmax({ p0.x, p1.x, p2.x, p3.x });
		const auto [yMin, yMax] = std::minmax({ p0.y, p1.y, p2.y, p3.y });

		return Polygon({ p0, p1, p2, p3 }, { 0, 1, 3, 3, 1, 2 }, RectF(xMin, yMin, xMax - xMin, yMax - yMin));
	}
Esempio n. 25
0
void Sprite::ScaleToClipped( float fWidth, float fHeight )
{
	m_fRememberedClipWidth = fWidth;
	m_fRememberedClipHeight = fHeight;

	if( !m_pTexture )
		return;

	float fScaleFudgePercent = 0.15f;	// scale up to this amount in one dimension to avoid clipping.

	// save the original X and Y.  We're going to restore them later.
	float fOriginalX = GetX();
	float fOriginalY = GetY();

	if( fWidth != -1 && fHeight != -1 )
	{
		// this is probably a background graphic or something not intended to be a CroppedSprite
		Sprite::StopUsingCustomCoords();

		// first find the correct zoom
		Sprite::ScaleToCover( RectF(0, 0, fWidth, fHeight) );
		// find which dimension is larger
		bool bXDimNeedsToBeCropped = GetZoomedWidth() > fWidth+0.01;
		
		if( bXDimNeedsToBeCropped ) // crop X
		{
			float fPercentageToCutOff = (this->GetZoomedWidth() - fWidth) / this->GetZoomedWidth();
			fPercentageToCutOff = max( fPercentageToCutOff-fScaleFudgePercent, 0 );
			float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;

			// generate a rectangle with new texture coordinates
			RectF fCustomImageRect( 
				fPercentageToCutOffEachSide, 
				0, 
				1 - fPercentageToCutOffEachSide, 
				1 );
			SetCustomImageRect( fCustomImageRect );
		}
		else // crop Y
		{
			float fPercentageToCutOff = (this->GetZoomedHeight() - fHeight) / this->GetZoomedHeight();
			fPercentageToCutOff = max( fPercentageToCutOff-fScaleFudgePercent, 0 );
			float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;

			// generate a rectangle with new texture coordinates
			RectF fCustomImageRect( 
				0, 
				fPercentageToCutOffEachSide,
				1, 
				1 - fPercentageToCutOffEachSide );
			SetCustomImageRect( fCustomImageRect );
		}
		m_size = RageVector2( fWidth, fHeight );
		SetZoom( 1 );
	}

	// restore original XY
	SetXY( fOriginalX, fOriginalY );
}
Esempio n. 26
0
		[[nodiscard]] inline RectF GetVirtualWindowArea(const Size& baseSize = Window::BaseSize())
		{
			const double sx = static_cast<double>(Window::Width()) / baseSize.x;
	
			const double sy = static_cast<double>(Window::Height()) / baseSize.y;
	
			const double s = Min(sx, sy);
	
			if (sx <= sy)
			{
				return RectF(baseSize * s).moveBy(0, (Window::Height() - baseSize.y * s) * 0.5);
			}
			else
			{
				return RectF(baseSize * s).moveBy((Window::Width() - baseSize.x * s) * 0.5, 0);
			}
		}
	void ColorRectSprite::doRender(const RenderState &rs)
	{
		_vstyle._apply(rs);
		
		
		rs.renderer->setTexture(Renderer::white, 0);		
		rs.renderer->draw(&rs, getColor(), RectF(0, 0, 1, 1), getDestRect());
	}
Esempio n. 28
0
	void Sprite::setResAnim(const ResAnim *resanim)
	{
		if (resanim)
		{
			if (resanim->getTotalFrames()) 
				setAnimFrame(resanim);
			else
			{
				AnimationFrame fr;

				fr.init(0, Diffuse(), RectF(0,0,0,0), RectF(0,0,0,0), getSize());
				setAnimFrame(fr);
			}
		}
		else
			setAnimFrame(AnimationFrame());
	}
Esempio n. 29
0
bool CrashEffect::update(double sec) {
	for (auto& particle : particles) {
		particle.rad += Radians(3.0);
		particle.pos += particle.vec * sec;//TODO:easing
		RectF(30.0 * (1.0 - sec)).setCenter(particle.pos.asPoint()).rotated(particle.rad).draw(HSV(Palette::White).toColorF(1.0 - sec));
	}
	return sec < 1.0;
}
Esempio n. 30
0
	RectF WidgetLayout::GetParentRectangle() const
	{
		if (mData->owner->mParentWidget)
			return mData->owner->mParentWidget->mChildrenWorldRect;
		else if (mData->owner->mParent)
			return mData->owner->mParent->transform->mData->worldRectangle;

		return RectF();
	}