public void Draw(Renderer.Base render, Rectangle r, Color col) { if (m_Texture == null) { return; } render.DrawColor = col; if (r.Width < m_Width && r.Height < m_Height) { render.DrawTexturedRect(m_Texture, r, m_Rects[0].uv[0], m_Rects[0].uv[1], m_Rects[8].uv[2], m_Rects[8].uv[3]); return; } DrawRect(render, 0, r.X, r.Y, m_Margin.Left, m_Margin.Top); DrawRect(render, 1, r.X + m_Margin.Left, r.Y, r.Width - m_Margin.Left - m_Margin.Right, m_Margin.Top); DrawRect(render, 2, (r.X + r.Width) - m_Margin.Right, r.Y, m_Margin.Right, m_Margin.Top); DrawRect(render, 3, r.X, r.Y + m_Margin.Top, m_Margin.Left, r.Height - m_Margin.Top - m_Margin.Bottom); DrawRect(render, 4, r.X + m_Margin.Left, r.Y + m_Margin.Top, r.Width - m_Margin.Left - m_Margin.Right, r.Height - m_Margin.Top - m_Margin.Bottom); DrawRect(render, 5, (r.X + r.Width) - m_Margin.Right, r.Y + m_Margin.Top, m_Margin.Right, r.Height - m_Margin.Top - m_Margin.Bottom); DrawRect(render, 6, r.X, (r.Y + r.Height) - m_Margin.Bottom, m_Margin.Left, m_Margin.Bottom); DrawRect(render, 7, r.X + m_Margin.Left, (r.Y + r.Height) - m_Margin.Bottom, r.Width - m_Margin.Left - m_Margin.Right, m_Margin.Bottom); DrawRect(render, 8, (r.X + r.Width) - m_Margin.Right, (r.Y + r.Height) - m_Margin.Bottom, m_Margin.Right, m_Margin.Bottom); }
void DrawRect(Renderer.Base render, int i, int x, int y, int w, int h, Color clr) { render.DrawTexturedRect( mTexture, new Rectangle(x, y, w, h), clr, mRects[i].Uv[0], mRects[i].Uv[1], mRects[i].Uv[2], mRects[i].Uv[3] ); }
public void Draw(Renderer.Base render, Rectangle r, Color col) { if (m_Texture == null) { return; } render.DrawColor = col; render.DrawTexturedRect(m_Texture, r, m_uv[0], m_uv[1], m_uv[2], m_uv[3]); }
// can't have this as default param /*public void Draw(Renderer.Base render, Rectangle r, Color col ) * { * Draw(render, r, Color.Red); * }*/ public void Draw(Renderer.Base render, Rectangle r, Color col) { if (mTexture == null) { return; } render.DrawColor = col; if (r.Width < mWidth && r.Height < mHeight) { render.DrawTexturedRect( mTexture, r, col, mRects[0].Uv[0], mRects[0].Uv[1], mRects[8].Uv[2], mRects[8].Uv[3] ); return; } DrawRect(render, 0, r.X, r.Y, mMargin.Left, mMargin.Top, col); DrawRect(render, 1, r.X + mMargin.Left, r.Y, r.Width - mMargin.Left - mMargin.Right, mMargin.Top, col); DrawRect(render, 2, r.X + r.Width - mMargin.Right, r.Y, mMargin.Right, mMargin.Top, col); DrawRect(render, 3, r.X, r.Y + mMargin.Top, mMargin.Left, r.Height - mMargin.Top - mMargin.Bottom, col); DrawRect( render, 4, r.X + mMargin.Left, r.Y + mMargin.Top, r.Width - mMargin.Left - mMargin.Right, r.Height - mMargin.Top - mMargin.Bottom, col ); DrawRect( render, 5, r.X + r.Width - mMargin.Right, r.Y + mMargin.Top, mMargin.Right, r.Height - mMargin.Top - mMargin.Bottom, col ); DrawRect(render, 6, r.X, r.Y + r.Height - mMargin.Bottom, mMargin.Left, mMargin.Bottom, col); DrawRect( render, 7, r.X + mMargin.Left, r.Y + r.Height - mMargin.Bottom, r.Width - mMargin.Left - mMargin.Right, mMargin.Bottom, col ); DrawRect( render, 8, r.X + r.Width - mMargin.Right, r.Y + r.Height - mMargin.Bottom, mMargin.Right, mMargin.Bottom, col ); }
public void Draw(Renderer.Base render, Rectangle r, Color col) { if (m_Texture == null) { return; } render.DrawColor = col; if (r.Width < m_Width && r.Height < m_Height) { //this control is smaller than the texture, so we don't need to do any stretching. Use the top left UV coordinates and the bottom right UV coordinates render.DrawTexturedRect(m_Texture, r, m_Rects[0].uv[0], m_Rects[0].uv[1], m_Rects[8].uv[2], m_Rects[8].uv[3]); return; } //This control is larger than the texture, so we need to stretch the textures //Draw the upper left rectangle DrawRect(render, 0, r.X, r.Y, m_Margin.Left, m_Margin.Top); //Draw the upper center rectangle DrawRect(render, 1, r.X + m_Margin.Left, r.Y, r.Width - m_Margin.Left - m_Margin.Right, m_Margin.Top); //draw the upper right rectangle DrawRect(render, 2, (r.X + r.Width) - m_Margin.Right, r.Y, m_Margin.Right, m_Margin.Top); //Draw the center left rectangle DrawRect(render, 3, r.X, r.Y + m_Margin.Top, m_Margin.Left, r.Height - m_Margin.Top - m_Margin.Bottom); //Draw the center center rectangle DrawRect(render, 4, r.X + m_Margin.Left, r.Y + m_Margin.Top, r.Width - m_Margin.Left - m_Margin.Right, r.Height - m_Margin.Top - m_Margin.Bottom); //Draw the center right rectangle DrawRect(render, 5, (r.X + r.Width) - m_Margin.Right, r.Y + m_Margin.Top, m_Margin.Right, r.Height - m_Margin.Top - m_Margin.Bottom); //Draw the lower left rectangle DrawRect(render, 6, r.X, (r.Y + r.Height) - m_Margin.Bottom, m_Margin.Left, m_Margin.Bottom); //Draw the lower center rectangle DrawRect(render, 7, r.X + m_Margin.Left, (r.Y + r.Height) - m_Margin.Bottom, r.Width - m_Margin.Left - m_Margin.Right, m_Margin.Bottom); //Draw the lower right rectangle DrawRect(render, 8, (r.X + r.Width) - m_Margin.Right, (r.Y + r.Height) - m_Margin.Bottom, m_Margin.Right, m_Margin.Bottom); }
void DrawRect(Renderer.Base render, int i, int x, int y, int w, int h) { render.DrawTexturedRect(m_Texture, new Rectangle(x, y, w, h), m_Rects[i].uv[0], m_Rects[i].uv[1], m_Rects[i].uv[2], m_Rects[i].uv[3]); }