public static List <VertexArray> FunctionPresenter(Func <float, float> function, FloatRect borders, float x_step, Color cl, float line_width, LineStyle style) { bool[] lines = Lines[(int)style]; List <Vector2f> vertexList = new List <Vector2f>( ); //VertexArray result = new VertexArray(PrimitiveType.Lines); float start = borders.Left; float end = borders.Left + borders.Width; float up = borders.Top; float down = borders.Top + borders.Height; float y_prev = 0; // undefined float x_prev = 0; // undefined for (float x = start; x <= end; x += x_step) { try { float y = function(x); //result.Append(new Vertex(new Vector2f(x_prev, y_prev), cl)); //result.Append(new Vertex(new Vector2f(x, y), cl)); if (y < down && y > up) { vertexList.Add(new Vector2f(x, y)); } x_prev = x; y_prev = y; } catch { } } //return result; return(SimpleUtils.GenerateLineWithThickness(vertexList, cl, line_width, lines)); }
public void Draw(SpriteBatch surface) { new CircleShape(Size, this.Transform).Draw(surface); if (Orbit == null) { Orbit = SimpleUtils.GenerateRingTexture((UInt32)Math.Round(Radius), 0f); } surface.Draw(Orbit, Parent.Transform.Position - _orbitSize); }
public override void Draw(SpriteBatch surface, Transform transform) { SimpleUtils.Draw(surface, Texture, new Transform(transform.Position, transform.Scale * 2f * Radius / BASE_RADIUS, transform.Rotation, transform.Color)); }