public GLPoint ScreenToView(GLPoint location) { //GL.Scale(1.0 / WindowWidth, 1.0 / WindowHeight, 1.0); //GL.Translate(50, 50, 0); //GL.Scale(WindowWidth, WindowHeight, 1.0); //GL.Scale(1.0 / DataWidth, 1.0 / DataHeight, 0); //GL.Translate(-DataOrigin.X, -DataOrigin.Y, 0); var x = location.X; var y = location.Y; y = WindowHeight - y; x -= 50; y -= 50; x = x * (DataWidth / WindowWidth); y = y * (DataHeight / WindowHeight); x += DataOrigin.X; y += DataOrigin.Y; return new GLPoint(x, y); }
public GLRect(GLPoint point1, GLPoint point2) { Location = new GLPoint(Math.Min(point1.X, point2.X), Math.Min(point1.Y, point2.Y)); // Max with 0 to prevent double weirdness from causing us to be (-epsilon..0) Width = Math.Max(Math.Max(point1.X, point2.X) - X, 0); Height = Math.Max(Math.Max(point1.Y, point2.Y) - Y, 0); }
public Rectangle(GLColor color, bool border, GLPoint origin, GLSize size) { Origin = origin; Border = border; Size = size; Color = color; }
public GLPoint ScreenToView(GLPoint location) { //GL.Scale(1.0 / WindowWidth, 1.0 / WindowHeight, 1.0); //GL.Translate(50, 50, 0); //GL.Scale(WindowWidth, WindowHeight, 1.0); //GL.Scale(1.0 / DataWidth, 1.0 / DataHeight, 0); //GL.Translate(-DataOrigin.X, -DataOrigin.Y, 0); var x = location.X; var y = location.Y; y = WindowHeight - y; x -= 50; y -= 50; x = x * (DataWidth / WindowWidth); y = y * (DataHeight / WindowHeight); x += DataOrigin.X; y += DataOrigin.Y; return(new GLPoint(x, y)); }
public void AddPoint(GLPoint point, bool update = true) { Points.Add(point); if (update) { if (Changed != null) { Changed(this, new LineChangedEventArgs(this)); } } }
public Line(float thickness, GLColor color, GLPoint[] points) { var copy = new List<GLPoint>(); copy.AddRange(points); Color = color; Thickness = thickness; Points = copy; }
public static void DrawQuad(GLPoint topLeft, GLPoint topRight, GLPoint bottomRight, GLPoint bottomLeft) { GL.Begin(BeginMode.Quads); GL.Vertex2(topLeft.X, topLeft.Y); GL.Vertex2(topRight.X, topRight.Y); GL.Vertex2(bottomRight.X, bottomRight.Y); GL.Vertex2(bottomLeft.X, bottomLeft.Y); GL.End(); }
public Line (float thickness , double intesity, GLPoint[] points) { var copy = new List<GLPoint>(); copy.AddRange(points); Color = GetRandomColor(intesity); Thickness = thickness; Points = copy; }
public GLPoint ViewToScreen(GLPoint location) { var x = location.X; var y = location.Y; x -= DataOrigin.X; y -= DataOrigin.Y; x = x / (DataWidth / WindowWidth); y = y / (DataHeight / WindowHeight); x += 50; y += 50; y = WindowHeight - y; return(new GLPoint(x, y)); }
public void Draw(GraphWindow window, GLPoint location) { GL.Color3(1.0, 1.0, 1.0); GL.BindTexture(TextureTarget.Texture2D, _texture); var height = GetMagnitude(new Point(0, _bitmap.Height),window).Y; var width = GetMagnitude(new Point(_bitmap.Width, 0), window).X; var ox = location.X - (width / 2.0); var oy = location.Y - (height / 2.0); GL.Begin(BeginMode.Quads); GL.TexCoord2(0f, 0f); GL.Vertex2(ox, oy + height); GL.TexCoord2(1f, 0f); GL.Vertex2(ox + width, oy + height); GL.TexCoord2(1f, 1f); GL.Vertex2(ox + width, oy); GL.TexCoord2(0f, 1f); GL.Vertex2(ox, oy); GL.End(); GL.BindTexture(TextureTarget.Texture2D, 0); }
public void Draw(GLPoint origin, float? glWidth, float? glHeight, bool offsetHeight) { var width = glWidth ?? _bmpWidth; var height = glHeight ?? _bmpHeight; GL.BindTexture(TextureTarget.Texture2D, _texture); GL.PushMatrix(); GL.Translate(Math.Round(origin.X), offsetHeight ? Math.Round(origin.Y - _font.Height/2.0) : Math.Round(origin.Y), 0); GL.Begin(BeginMode.Quads); GL.Color3(0,0,0); GL.TexCoord2(0f, 0f); GL.Vertex2(0, height); //topleft GL.TexCoord2(1f, 0f); GL.Vertex2(width, height); GL.TexCoord2(1f, 1f); GL.Vertex2(width, 0); GL.TexCoord2(0f, 1f); GL.Vertex2(0, 0); GL.End(); GL.BindTexture(TextureTarget.Texture2D, 0); GL.PopMatrix(); }
public void Draw(GLPoint origin, float?glWidth, float?glHeight, bool offsetHeight) { var width = glWidth ?? _bmpWidth; var height = glHeight ?? _bmpHeight; GL.BindTexture(TextureTarget.Texture2D, _texture); GL.PushMatrix(); GL.Translate(Math.Round(origin.X), offsetHeight ? Math.Round(origin.Y - _font.Height / 2.0) : Math.Round(origin.Y), 0); GL.Begin(BeginMode.Quads); GL.Color3(0, 0, 0); GL.TexCoord2(0f, 0f); GL.Vertex2(0, height); //topleft GL.TexCoord2(1f, 0f); GL.Vertex2(width, height); GL.TexCoord2(1f, 1f); GL.Vertex2(width, 0); GL.TexCoord2(0f, 1f); GL.Vertex2(0, 0); GL.End(); GL.BindTexture(TextureTarget.Texture2D, 0); GL.PopMatrix(); }
public void Draw(GLPoint origin) { var width = 200; var height = 50; using (var bmp = new Bitmap(width, height)) { using (var g = Graphics.FromImage(bmp)) { g.Clear(Color.Transparent); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; g.DrawString(Text, _font, Brushes.Black, new PointF(0, 25)); } GL.BindTexture(TextureTarget.Texture2D, _texture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear); var data = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0); bmp.UnlockBits(data); } GL.PushMatrix(); GL.Translate(origin.X, origin.Y, 0); GL.Begin(BeginMode.Quads); GL.TexCoord2(0f, 0f); GL.Vertex2(0, height); //topleft GL.TexCoord2(1f, 0f); GL.Vertex2(width, height); GL.TexCoord2(1f, 1f); GL.Vertex2(width, 0); GL.TexCoord2(0f, 1f); GL.Vertex2(0, 0); GL.End(); GL.BindTexture(TextureTarget.Texture2D, 0); GL.PopMatrix(); }
public void Draw(GraphWindow window, GLPoint location) { if (_disposed) { throw new ObjectDisposedException("PersistentTexture"); } GL.Color3(1.0, 1.0, 1.0); GL.BindTexture(TextureTarget.Texture2D, _texture); var height = GetMagnitude(new Point(0, _bitmap.Height), window).Y; var width = GetMagnitude(new Point(_bitmap.Width, 0), window).X; var ox = location.X - (width / 2.0); var oy = location.Y - (height / 2.0); GL.Begin(BeginMode.Quads); GL.TexCoord2(0f, 0f); GL.Vertex2(ox, oy + height); GL.TexCoord2(1f, 0f); GL.Vertex2(ox + width, oy + height); GL.TexCoord2(1f, 1f); GL.Vertex2(ox + width, oy); GL.TexCoord2(0f, 1f); GL.Vertex2(ox, oy); GL.End(); GL.BindTexture(TextureTarget.Texture2D, 0); }
public void AddPoint(GLPoint point) { Points.Add(point); if (Changed != null) { Changed(this, new LineChangedEventArgs(this)); } }
public GLPoint ViewToScreen(GLPoint location) { var x = location.X; var y = location.Y; x -= DataOrigin.X; y -= DataOrigin.Y; x = x / (DataWidth / WindowWidth); y = y / (DataHeight / WindowHeight); x += 50; y += 50; y = WindowHeight - y; return new GLPoint(x, y); }
public static void DrawVertices(GLPoint[] points) { foreach (var p in points) { GL.Vertex2(p.X, p.Y); } }
public GLRect(double x, double y, double width, double height) { Location = new GLPoint(x, y); Width = width; Height = height; }
public GLRect(GLPoint point1, GLPoint point2) { Location = new GLPoint(Math.Min(point1.X, point2.X),Math.Min(point1.Y, point2.Y)); // Max with 0 to prevent double weirdness from causing us to be (-epsilon..0) Width = Math.Max(Math.Max(point1.X, point2.X) - X, 0); Height = Math.Max(Math.Max(point1.Y, point2.Y) - Y, 0); }