/// <summary> /// Function to draw an unfilled rectangle. /// </summary> private void DrawUnfilled() { TransformVertices(); for (int i = 0; i < _corners.Length; i++) { _corners[i].X = (float)System.Math.Ceiling(_corners[i].X); _corners[i].Y = (float)System.Math.Ceiling(_corners[i].Y) + 1; } // Set global line state. _line.AlphaTestValues = AlphaTestValues; _line.Texture = Texture; _line.LineThickness = LineThickness; _line.CullingMode = CullingMode; _line.Depth = Depth; _line.Blending = Blending; _line.DepthStencil = DepthStencil; _line.TextureSampler = TextureSampler; _line.TextureStart = TextureRegion.Location; _line.TextureEnd = new Vector2(TextureRegion.Right, TextureRegion.Top); _line.StartColor = _colors[0]; _line.EndColor = _colors[1]; _line.StartPoint = new Vector2(_corners[0].X, _corners[0].Y); _line.EndPoint = new Vector2(_corners[1].X + 1.0f, _corners[1].Y); _line.Draw(); _line.TextureStart = new Vector2(TextureRegion.Right, TextureRegion.Top); _line.TextureEnd = new Vector2(TextureRegion.Right, TextureRegion.Bottom); _line.StartColor = _colors[1]; _line.EndColor = _colors[3]; _line.StartPoint = new Vector2(_corners[1].X + 1, _corners[1].Y); _line.EndPoint = new Vector2(_corners[2].X + 1, _corners[2].Y); _line.Draw(); _line.TextureStart = new Vector2(TextureRegion.Right, TextureRegion.Bottom); _line.TextureEnd = new Vector2(TextureRegion.Left, TextureRegion.Bottom); _line.StartColor = _colors[3]; _line.EndColor = _colors[2]; _line.StartPoint = new Vector2(_corners[2].X, _corners[2].Y); _line.EndPoint = new Vector2(_corners[3].X + 1.0f, _corners[3].Y); _line.Draw(); _line.TextureStart = new Vector2(TextureRegion.Left, TextureRegion.Bottom); _line.TextureEnd = new Vector2(TextureRegion.Left, TextureRegion.Top); _line.StartColor = _colors[2]; _line.EndColor = _colors[0]; _line.StartPoint = new Vector2(_corners[3].X + 1.0f, _corners[3].Y); _line.EndPoint = new Vector2(_corners[0].X + 1.0f, _corners[0].Y); _line.Draw(); }
/// <summary> /// Function to draw the object. /// </summary> public override void Draw() { if (IsFilled) { if (NeedsTextureUpdate) { UpdateTextureCoordinates(); NeedsTextureUpdate = false; } UpdateVertices(); AddToRenderQueue(); return; } UpdateVertices(); // Set global line state. _line.AlphaTestValues = AlphaTestValues; _line.Texture = Texture; _line.CullingMode = CullingMode; _line.Depth = Depth; _line.TextureStart = _points[0].TextureCoordinate; _line.TextureEnd = _points[1].TextureCoordinate; _line.StartColor = _points[0].Color; _line.EndColor = _points[1].Color; _line.StartPoint = new Vector2(Vertices[0].Position.X, Vertices[0].Position.Y); _line.EndPoint = new Vector2(Vertices[1].Position.X, Vertices[1].Position.Y); _line.Draw(); _line.TextureStart = _points[1].TextureCoordinate; _line.TextureEnd = _points[2].TextureCoordinate; _line.StartColor = _points[1].Color; _line.EndColor = _points[2].Color; _line.StartPoint = new Vector2(Vertices[1].Position.X, Vertices[1].Position.Y); _line.EndPoint = new Vector2(Vertices[2].Position.X, Vertices[2].Position.Y); _line.Draw(); _line.TextureStart = _points[2].TextureCoordinate; _line.TextureEnd = _points[0].TextureCoordinate; _line.StartColor = _points[2].Color; _line.EndColor = _points[0].Color; _line.StartPoint = (Vector2)Vertices[2].Position; _line.EndPoint = (Vector2)Vertices[0].Position; _line.Draw(); }
/// <summary> /// Function to draw the ellipse. /// </summary> public override void Draw() { // Draw unfilled with a line object. if (NeedsVertexUpdate) { UpdateVertices(); NeedsVertexUpdate = false; } if (_isFilled) { AddToRenderQueue(); return; } _line.Blending = Blending; _line.DepthStencil = DepthStencil; _line.TextureSampler = TextureSampler; for (int i = 0; i < _points.Length; i++) { int endPointIndex = i + 1; if (endPointIndex >= _points.Length) { endPointIndex = 0; } Vector2 start = TransformUnfilled(ref _points[i]); Vector2 end = TransformUnfilled(ref _points[endPointIndex]); Vector2 uvStart = Vector2.Zero; Vector2 uvEnd = Vector2.Zero; if (Texture != null) { UpdateUnfilledTextureCoordinates(i, endPointIndex, out uvStart, out uvEnd); } _line.TextureStart = uvStart; _line.TextureEnd = uvEnd; _line.StartColor = _colors[i]; _line.EndColor = _colors[endPointIndex]; _line.StartPoint = start; _line.EndPoint = end; _line.Depth = Depth; _line.Draw(); } NeedsTextureUpdate = false; }
/// <summary> /// Function to draw a line to the current target. /// </summary> /// <param name="startPosition">Starting position.</param> /// <param name="endPosition">Ending position.</param> /// <param name="color">Color of the line.</param> /// <param name="thickness">Thickness of the line.</param> /// <param name="texture">Texture to apply to the line.</param> /// <param name="textureStart">Starting point on the texture.</param> /// <param name="textureEnd">Ending point on the texture.</param> public void DrawLine(Vector2 startPosition, Vector2 endPosition, GorgonColor color, Vector2 thickness, GorgonTexture2D texture, Vector2 textureStart, Vector2 textureEnd) { SetStates(_line); _line.StartPoint = startPosition; _line.EndPoint = endPosition; _line.Color = color; _line.LineThickness = thickness; _line.Texture = texture; _line.TextureStart = textureStart; _line.TextureEnd = textureEnd; _line.Draw(); }