public Box2 GetBounds() { float posX = transform.position.X; float posY = transform.position.Y; float halfX = 0.5f * transform.scale.X; float halfY = 0.5f * transform.scale.Y; Box2 box = new OpenTK.Box2(posX - halfX, posY + halfY, posX + halfX, posY - halfY); return(box); }
public void DrawTexturedQuad(int TextureID, Box2 Box, Box2 subImageBox) { GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.BindTexture(TextureTarget.Texture2D, TextureID); GL.Begin(PrimitiveType.Quads); GL.TexCoord2(subImageBox.Left, subImageBox.Top); GL.Vertex2(Box.Left, Box.Bottom); GL.TexCoord2(subImageBox.Right, subImageBox.Top); GL.Vertex2(Box.Right, Box.Bottom); GL.TexCoord2(subImageBox.Right, subImageBox.Bottom); GL.Vertex2(Box.Right, Box.Top); GL.TexCoord2(subImageBox.Left, subImageBox.Bottom); GL.Vertex2(Box.Left, Box.Top); GL.End(); GL.BindTexture(TextureTarget.Texture2D, 0); }
public void DrawBox(Box2 box, Color4 fillColor, Color4 outlineColor) { if (fillColor.A > 0.0f) { SetColor(fillColor); GL.Begin(PrimitiveType.Quads); GL.Vertex2(box.Left, box.Bottom); GL.Vertex2(box.Right, box.Bottom); GL.Vertex2(box.Right, box.Top); GL.Vertex2(box.Left, box.Top); GL.End(); } if (outlineColor.A > 0.0f) { SetColor(outlineColor); GL.Begin(PrimitiveType.LineLoop); GL.Vertex2(box.Left, box.Bottom); GL.Vertex2(box.Right, box.Bottom); GL.Vertex2(box.Right, box.Top); GL.Vertex2(box.Left, box.Top); GL.End(); } }
private Box2 BoundingBox() { if (!bounding_box_is_good) { boundingBox = new Box2(float.PositiveInfinity, float.NegativeInfinity, float.NegativeInfinity, float.PositiveInfinity); foreach (Vector2 p in Points) { if (p.X > boundingBox.Right) { boundingBox.Right = p.X; } if (p.X < boundingBox.Left) { boundingBox.Left = p.X; } if (p.Y > boundingBox.Top) { boundingBox.Top = p.Y; } if (p.Y < boundingBox.Bottom) { boundingBox.Bottom = p.Y; } } boundingBox.Bottom -= width / 2; boundingBox.Top += width / 2; boundingBox.Left -= width / 2; boundingBox.Right += width / 2; bounding_box_is_good = true; } return boundingBox; }
public static void FillBox(Box2 b) { GL.Begin(BeginMode.Quads); GL.Vertex2(b.Bottom, b.Left); GL.Vertex2(b.Bottom, b.Right); GL.Vertex2(b.Top, b.Right); GL.Vertex2(b.Top, b.Left); GL.End(); }
public void SetBounds(Box2 bound) { m_bounds = bound; }
public SizeF Measure(string text, int width, QFontAlignment alignment) { var dims = new Box2 (0, 0, width, 0); return Measure (text, dims, alignment); }
/// <summary> /// Measures the actual width and height of the block of text. /// </summary> /// <param name="text"></param> /// <param name="bounds"></param> /// <param name="alignment"></param> /// <returns></returns> public SizeF Measure(string text, Box2 bounds, QFontAlignment alignment) { var processedText = ProcessText(text, bounds, alignment); return Measure(processedText); }
public void PrintToVBO(string text, QFontAlignment alignment, Vector3 position, Color color, Box2 maxSize) { Options.Colour = color; PrintOffset = position; Print(text, maxSize, alignment); }
public void Print(string text, Box2 maxSize, QFontAlignment alignment, Vector2 position) { position = TransformPositionToViewport(position); position = LockToPixel(position); GL.PushMatrix(); GL.Translate(position.X, position.Y, 0f); Print(text, maxSize, alignment); GL.PopMatrix(); }
public void Print(string text, int maxSize, QFontAlignment alignment) { var dims = new Box2 (0, 0, maxSize, 0); Print(text, dims, alignment); }
/// <summary> /// Creates node list object associated with the text. /// </summary> /// <param name="text"></param> /// <param name = "maxSize"></param> /// <param name = "alignment"></param> /// <returns></returns> public ProcessedText ProcessText(string text, Box2 maxSize, QFontAlignment alignment) { //TODO: bring justify and alignment calculations in here var width = TransformWidthToViewport(maxSize.Width); var nodeList = new TextNodeList(text); nodeList.MeasureNodes(fontData, Options); //we "crumble" words that are two long so that that can be split up var nodesToCrumble = new List<TextNode>(); foreach (TextNode node in nodeList) if ((!Options.WordWrap || node.Length >= width) && node.Type == TextNodeType.Word) nodesToCrumble.Add(node); foreach (var node in nodesToCrumble) nodeList.Crumble(node, 1); //need to measure crumbled words nodeList.MeasureNodes(fontData, Options); var processedText = new ProcessedText(); processedText.textNodeList = nodeList; processedText.maxWidth = width; processedText.alignment = alignment; return processedText; }
/// <summary> /// Prints text inside the given bounds. /// </summary> /// <param name="text"></param> /// <param name="maxSize"></param> /// <param name="alignment"></param> public void Print(string text, Box2 maxSize, QFontAlignment alignment) { var processedText = ProcessText(text, maxSize, alignment); Print(processedText); }
public void DrawTexturedQuad(int TextureID, Box2 Box, Color4 color, bool flipX) { SetColor(color); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.BindTexture(TextureTarget.Texture2D, TextureID); GL.Begin(PrimitiveType.Quads); if (!flipX) { GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(Box.Left, Box.Bottom); GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(Box.Right, Box.Bottom); GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(Box.Right, Box.Top); GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(Box.Left, Box.Top); } else { GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(Box.Left, Box.Bottom); GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(Box.Right, Box.Bottom); GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(Box.Right, Box.Top); GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(Box.Left, Box.Top); } GL.End(); GL.BindTexture(TextureTarget.Texture2D, 0); }