Click here to Skip to main content
15,914,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi 1 – I want to draw a sine and sawtooth wave…
2 – And use the timer to draw wave motion
3 - how i can clean chart
4 – and combined two-wave (modulation)? I use this code to draw a triangle wave
(textbox = amplitude – frequency – time) :

C#
GraphPane myPane = zgc.GraphPane;
            // Make up some data points from the Sine function
            PointPairList list1 = new PointPairList();
            double amplitude = double.Parse(textBox2.Text);
            double period = double.Parse(textBox3.Text);
            double y = 0;
            for (double x = 0; x <= double.Parse(textBox1.Text); x += .005)
            {
                double p = (x % (period)) / period;
                if (p >= 0 && p <= 0.25)
                    y = 4 * p * amplitude;
                if (p > 0.25 && p < 0.5)
                    y = amplitude - (p - 0.25) * 4 * amplitude;
                if (p > 0.5 && p <= 0.75)
                    y = -4 * (p - 0.5) * amplitude;
                if (p > 0.75 && p <= 1)
                    y = -(amplitude - (p - 0.75) * 4 * amplitude);
                list1.Add(x, y);
            }
            var line = zg1.MasterPane[0].AddCurve("", list1, Color.Goldenrod);
            line.Symbol.IsVisible = false;
            zg1.AxisChange();
            zg1.Refresh();
            zgc.AxisChange();
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900