So I was messing around in c# making a project for school and I ran into this road block. How do I store an older line's variable/coordinate (CF) as the next lines new variable /coordinate (AF)
public void button1_Click(object sender, EventArgs e)
{
if (n < 1)
{
Double AD = 0;
Double BD = 0;
n++;
}
else if (n > 1)
{
Double AD = 0;
Double BD = 0;
n++;
}
using (var g = Graphics.FromImage(pictureBox1.Image))
{
int L = Convert.ToInt32(numericUpDown1.Value);
int T = Convert.ToInt32(numericUpDown2.Value);
Double TH = System.Convert.ToDouble(T);
Double LD = System.Convert.ToDouble(L);
float AF = System.Convert.ToSingle(AD);
float BF = System.Convert.ToSingle(BD);
float CF = System.Convert.ToSingle(CD);
float DF = System.Convert.ToSingle(DD);
double THP = (TH / 180) * (Math.PI);
DD = Math.Sin(THP) * LD + AF;
CD = Math.Cos(THP) * LD + BF;
g.DrawLine(Pens.Blue, AF, BF, CF, DF);
pictureBox1.Refresh();
}
}
Aucun commentaire:
Enregistrer un commentaire