コード例 #1
0
        public override void Render(Graphics g, float[] samples)
        {
            float[] heights = FFT.SampleToFreq(samples, Settings.SampleCount);
            GetLastIndex(heights);

            DrawCircle(g, heights);
        }
コード例 #2
0
        public override void Render(Graphics g, float[] samples)
        {
            float[] heights = FFT.SampleToFreq(samples, Settings.SampleCount);

            List <PointF> points = new List <PointF>();

            points.Add(new PointF(0, g.VisibleClipBounds.Height));

            for (int i = 0; i < heights.Length; i++)
            {
                float height = Smooth(heights, i, Settings.Smoothing);
                points.Add(new PointF(i / (float)heights.Length * g.VisibleClipBounds.Width * Settings.XScale, (float)(g.VisibleClipBounds.Height - 20.0f - height * Settings.YScale)));

                if (i / (float)heights.Length * g.VisibleClipBounds.Width * Settings.XScale > g.VisibleClipBounds.Width)
                {
                    break;
                }
            }

            points.Add(new PointF(g.VisibleClipBounds.Width, g.VisibleClipBounds.Height));

            LinearGradientBrush b = new LinearGradientBrush(new PointF(0, 0), new PointF(g.VisibleClipBounds.Width, 0), Settings.GetColor("Left"), Settings.GetColor("Right"));

            g.FillPolygon(b, points.ToArray());

            b = new LinearGradientBrush(new PointF(0, 0), new PointF(0, g.VisibleClipBounds.Height), Settings.GetColor("Top"), Color.FromArgb(0, Settings.GetColor("Top")));

            g.FillPolygon(b, points.ToArray());
        }
コード例 #3
0
        public override void Render(Graphics g, float[] samples)
        {
            float[] heights = FFT.SampleToFreq(samples, Settings.SampleCount);

            List <PointF> points          = new List <PointF>();
            List <PointF> pointsReflected = new List <PointF>();

            points.Add(new PointF(0, g.VisibleClipBounds.Height / 2));
            pointsReflected.Add(new PointF(0, g.VisibleClipBounds.Height / 2));

            for (int i = 0; i < heights.Length; i++)
            {
                float height = Smooth(heights, i, Settings.Smoothing);

                points.Add(new PointF(i / (float)heights.Length * g.VisibleClipBounds.Width * Settings.XScale, (float)(g.VisibleClipBounds.Height / 2 - height * Settings.YScale)));
                pointsReflected.Add(new PointF(i / (float)heights.Length * g.VisibleClipBounds.Width * Settings.XScale, (float)(g.VisibleClipBounds.Height / 2 + height * Settings.YScale)));


                if (i / (float)heights.Length * g.VisibleClipBounds.Width * Settings.XScale > g.VisibleClipBounds.Width)
                {
                    break;
                }
            }

            points.Add(new PointF(g.VisibleClipBounds.Width, g.VisibleClipBounds.Height / 2));
            pointsReflected.Add(new PointF(g.VisibleClipBounds.Width, g.VisibleClipBounds.Height / 2));

            LinearGradientBrush b = new LinearGradientBrush(new PointF(0, 0), new PointF(g.VisibleClipBounds.Width, 0), Settings.GetColor("Left"), Settings.GetColor("Right"));

            List <PointF> totalShape = new List <PointF>();

            totalShape.AddRange(points);
            totalShape.AddRange(pointsReflected);

            g.FillPolygon(b, totalShape.ToArray());

            //Draw top

            b          = new LinearGradientBrush(new PointF(0, 0), new PointF(0, g.VisibleClipBounds.Height / 2 + 5), Settings.GetColor("Top"), Color.FromArgb(0, Settings.GetColor("Top")));
            b.WrapMode = WrapMode.TileFlipY;

            g.FillPolygon(b, points.ToArray());

            //Draw bottom

            b          = new LinearGradientBrush(new PointF(0, g.VisibleClipBounds.Height / 2 - 1), new PointF(0, g.VisibleClipBounds.Height), Color.FromArgb(0, Settings.GetColor("Bottom")), Settings.GetColor("Bottom"));
            b.WrapMode = WrapMode.TileFlipY;

            g.FillPolygon(b, pointsReflected.ToArray());
        }
コード例 #4
0
        public override void Render(Graphics g, float[] samples)
        {
            float[] heights = FFT.SampleToFreq(samples, Settings.SampleCount);
            GetLastIndex(heights);

            float minX = g.VisibleClipBounds.Width;
            float maxX = 0;

            List <PointF> points = new List <PointF>();
            int           i;

            for (i = 0; i < lastIndex; i++)
            {
                double angle = (double)i / heights.Length * Math.PI * Settings.XScale;

                float height = Smooth(heights, i, Settings.Smoothing);

                double x = Math.Cos(angle - Math.PI / 2) * (height * Settings.YScale + 100) + g.VisibleClipBounds.Width / 2;
                double y = Math.Sin(angle - Math.PI / 2) * (height * Settings.YScale + 100) + g.VisibleClipBounds.Height / 2;
                points.Add(new PointF((float)x, (float)y));

                minX = (float)Math.Min(minX, x);
                maxX = (float)Math.Max(maxX, x);
            }
            i--;
            for (  ; i > 0; i--)
            {
                double angle = (double)-i / heights.Length * Math.PI * Settings.XScale;

                float height = Smooth(heights, i, Settings.Smoothing);

                double x = Math.Cos(angle - Math.PI / 2) * (height * Settings.YScale + 100) + g.VisibleClipBounds.Width / 2;
                double y = Math.Sin(angle - Math.PI / 2) * (height * Settings.YScale + 100) + g.VisibleClipBounds.Height / 2;
                points.Add(new PointF((float)x, (float)y));

                minX = (float)Math.Min(minX, x);
                maxX = (float)Math.Max(maxX, x);
            }

            LinearGradientBrush b = new LinearGradientBrush(new PointF(minX, 0), new PointF(maxX, 0), Settings.GetColor("Left"), Settings.GetColor("Right"));

            g.FillPolygon(b, points.ToArray());
        }
コード例 #5
0
        public override void Render(Graphics g, float[] samples)
        {
            float[] heights = FFT.SampleToFreq(samples, Settings.SampleCount);
            GetLastIndex(heights);
            List <PointF> points = new List <PointF>();

            points.Add(new PointF(0, g.VisibleClipBounds.Height / 2));

            for (int i = 0; i < lastIndex; i++)
            {
                float height = Smooth(heights, i, Settings.Smoothing);
                float x      = i / (float)heights.Length * g.VisibleClipBounds.Width * Settings.XScale;
                float y      = (float)(g.VisibleClipBounds.Height / 2 - height * Settings.YScale * ((i % 2) * 2 - 1));

                points.Add(new PointF(x, y));
            }

            points.Add(new PointF(g.VisibleClipBounds.Width, g.VisibleClipBounds.Height / 2));

            Pen p = new Pen(Settings.GetColor("Color"), 2.0f);

            g.DrawLines(p, points.ToArray());
        }