Как сделать чтобы рисунок передвигался а не растягивался?
Всем привет. Суть задания отрисовать косинус и синус, чтобы можно было стрелочками передвигать влево вправо вверх вниз.

class Program
{
static Random random = new Random();
static List<Color> colors = new List<Color>(new Color[]
{
Color.Black,
Color.Blue,
Color.Cyan,
Color.Green,
Color.Magenta,
Color.Red,
Color.White,
Color.Yellow
});
static Color GetRandomColor()
{
var item = colors[random.Next(0, colors.Count)];
return item;
}
static VertexArray GetVertexArray(float scale, float offset, float lambda)
{
VertexArray vertexArray = new VertexArray(PrimitiveType.LineStrip);
for (float i = 0; i < 10 * Math.PI; i += 0.05f)
{
vertexArray.Append(new Vertex(new Vector2f(i * lambda, (float)Math.Cos(i) * scale + offset), GetRandomColor()));
}
return vertexArray;
}
static VertexArray GetVertexArraySin(float scale, float offset, float lambda)
{
VertexArray vertexArray = new VertexArray(PrimitiveType.LineStrip);
for (float i = 0; i < 10 * Math.PI; i += 0.05f)
{
vertexArray.Append(new Vertex(new Vector2f(i * lambda, (float)Math.Sin(i) * scale + offset)));
}
return vertexArray;
}
static void Main(string[] args)
{
float y = 300;
float lambda = 50;
RenderWindow window = new RenderWindow(new VideoMode(800, 600), "Окно");
window.Closed += Window_Closed;
window.MouseButtonPressed += Window_MouseButtonPressed;
window.KeyPressed += Window_KeyPressed;
window.Clear();
window.Draw(GetVertexArray(50, y, lambda));
window.Draw(GetVertexArraySin(50, y, lambda));
window.Display();
while (window.IsOpen)
{
window.WaitAndDispatchEvents();
if (Keyboard.IsKeyPressed(Keyboard.Key.Up))
{
y -= 10;
window.Clear();
window.Draw(GetVertexArray(50, y, lambda));
window.Draw(GetVertexArraySin(50, y, lambda));
window.Display();
}
if (Keyboard.IsKeyPressed(Keyboard.Key.Down))
{
y += 10;
window.Clear();
window.Draw(GetVertexArray(50, y, lambda));
window.Draw(GetVertexArraySin(50, y, lambda));
window.Display();
}
if (Keyboard.IsKeyPressed(Keyboard.Key.Left))
{
lambda--;
window.Clear();
window.Draw(GetVertexArray(50, y, lambda));
window.Draw(GetVertexArraySin(50, y, lambda));
window.Display();
}
if (Keyboard.IsKeyPressed(Keyboard.Key.Right))
{
lambda++;
window.Clear();
window.Draw(GetVertexArray(50, y, lambda));
window.Draw(GetVertexArraySin(50, y, lambda));
window.Display();
}
if (Keyboard.IsKeyPressed(Keyboard.Key.Space))
{
window.Clear();
window.Draw(GetVertexArray(50, 300, 50));
window.Draw(GetVertexArraySin(50, 300, 50));
window.Display();
}
if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
{
window.Close();
}
}
}
private static void Window_KeyPressed(object sender, KeyEventArgs e)
{
//Console.WriteLine(e.Code);
//if (e.Code == Keyboard.Key.Escape) Environment.Exit(0);
}
private static void Window_MouseButtonPressed(object sender, MouseButtonEventArgs e)
{
Console.WriteLine($"{ e.Button }, { e.X }, { e.Y }");
}
private static void Window_Closed(object sender, EventArgs e)
{
Environment.Exit(0);
}
}
}
Мой код. Из скринов видно, особенно на 2, что стрелочка влево просто сжимает рисунок а не двигает, как сделать так, чтобы рисунок не сжимался а просто двигался влево? И ещё вопрос как сделать сплошной цвет линии? Т.е не разноцветный
