Beispiel #1
0
        private void RenderArea_Click(object sender, EventArgs e)
        {
            MouseEventArgs mevent = e as MouseEventArgs;

            if (mevent.Button == MouseButtons.Left)
            {
                image.SetPixel(mevent.X, mevent.Y, Color.White);
            }

            RenderArea.Refresh();
        }
Beispiel #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            stopwatch.Restart();


            switch (flavor)
            {
            case Flavors.CPUpar:
                BoidCalculations.CalcBoidsCPUPAR();     // this is the CPU parallel version
                break;

            case Flavors.CPUseq:
            default:
                BoidCalculations.CalcBoidsCPUSEQ();     // this is the CPU sequential version // comment this out if you want to validate parallel calculations
                // BoidCalculations.ValidateParCPU(); // uncomment this if you want to validate parallel calculations
                break;
            }

            foreach (BoidObject Boid in BoidCalculations.BoidArray)
            {
                image.SetPixel(Boid.OldIntPosX, Boid.OldIntPosY, Color.Black);
                image.SetPixel(Boid.IntPosX, Boid.IntPosY, Color.White);
            }

            RenderArea.Refresh();
            double fps = (double)stopwatch.ElapsedTicks / Stopwatch.Frequency;

            FPSLabel.Text = $"FPS: {1 / fps:0.00} ";

            BoidCountLabel.Text = $"Boids on screen: {BoidCalculations.BoidArray.Length:0}";

            if (Recording)
            {
                file.WriteLine($"{flavor}, {fps}, {1/fps}, {BoidCalculations.BoidArray.Length}"); // Flavour, Time since last tick, Framerate, Boids on screen
            }
        }