public void DrawSelf(RenderTarget window, RenderFrame rf, float x, float y) { uint size = (uint)((float)defaultSize * rf.zoom); if (size < 1) return; text.CharacterSize = size; x -= rf.xCenter; y = rf.yCenter - y; x *= rf.zoom; y *= rf.zoom; FloatRect localBounds = text.GetLocalBounds(); x += rf.width / 2 - localBounds.Width/2.0f /*- 0.5f*rf.zoom*/; y += rf.height / 2 - localBounds.Height /*+0.5f*rf.zoom*/; text.Position = new Vector2f(x, y); window.Draw(text); }
/// <summary> /// Прави рисуваеми обекти /// </summary> /// <param name="rf">Рамката, която определя трансформациите</param> /// <returns>Обекти за рисуване</returns> public List<Drawable> getDrawables(RenderFrame rf) { Vector2f actualPos = new Vector2f(center.X - rf.xCenter, center.Y - rf.yCenter); // преместване на камерата actualPos.X *= rf.zoom; actualPos.Y *= rf.zoom; float actualR = radius * rf.zoom; // превръщане в екранни координати actualPos.X += rf.width / 2; actualPos.Y = -actualPos.Y + rf.height / 2; actualPos.X -= radius*rf.zoom; actualPos.Y -= radius*rf.zoom; CircleShape cs = new CircleShape(actualR, 60); cs.Position = actualPos; cs.FillColor = color; return new List<Drawable> { cs }; }
public void DrawSelf(RenderTarget window, RenderFrame rf) { if (!visible) return; CheckWeightProperty(); line.SetDestination(destination.x, destination.y); line.SetSource(source.x, source.y); line.DrawSelf(window, rf); if(arrowLine1!=null) { MakeArrow(); arrowLine1.DrawSelf(window, rf); arrowLine2.DrawSelf(window, rf); } if (weightProperty != null) weightLabel.DrawSelf(window, rf, (source.x + destination.x) / 2.0f, (source.y + destination.y) / 2.0f); }
public void DrawSelf(RenderTarget window, RenderFrame rf) { visible = IsVisible(); if (!visible) return; if(currentColor==null) CheckMarkedProperty(); circle.center.X = x; circle.center.Y = y; selectionCircle.center.X = x; selectionCircle.center.Y = y; List<Drawable> ld = new List<Drawable>(); if (selected) ld.AddRange(selectionCircle.getDrawables(rf)); ld.AddRange(circle.getDrawables(rf)); ld.ForEach(d => window.Draw(d)); idLabel.DrawSelf(window, rf, x, y); }
public void DrawSelf(RenderTarget window, RenderFrame rf) { edges.ForEach(e => e.DrawSelf(window, rf)); vertices.ForEach(v => v.DrawSelf(window, rf)); }
public void DrawSelf(RenderTarget window, RenderFrame rf) { va2[0] = va[0]; va2[0].Position.X -= rf.xCenter; va2[0].Position.Y = rf.yCenter - va[0].Position.Y; va2[0].Position.X *= rf.zoom; va2[0].Position.Y *= rf.zoom; va2[0].Position.X += rf.width / 2; va2[0].Position.Y = va2[0].Position.Y + rf.height / 2; va2[1] = va[1]; va2[1].Position.X -= rf.xCenter; va2[1].Position.Y = rf.yCenter - va[1].Position.Y; va2[1].Position.X *= rf.zoom; va2[1].Position.Y *= rf.zoom; va2[1].Position.X += rf.width / 2; va2[1].Position.Y = va2[1].Position.Y + rf.height / 2; window.Draw(va2, PrimitiveType.Lines); }
public static void SaveGraphPicture(string filename, Graph graph) { float minX = 999999; float maxX = -999999; float minY = 999999; float maxY = -99999; foreach(Vertex v in graph.vertices) { if (v.x < minX) minX = v.x; if (v.x > maxX) maxX = v.x; if (v.y < minY) minY = v.y; if (v.y > maxY) maxY = v.y; } minX -= 25; maxX += 25; minY -= 25; maxY += 25; uint width = 3*(uint)(maxX - minX); uint height = 3*(uint)(maxY - minY); RenderTexture tx = new RenderTexture(width, height); tx.Clear(Color.Black); RenderFrame rf = new RenderFrame(); rf.width = width; rf.height = height; rf.xCenter = minX + width; rf.yCenter = minY + height; rf.zoom = 1.2f; graph.DrawSelf(tx, rf); tx.Texture.CopyToImage().SaveToFile("graph.png"); }