Exemple #1
0
        private Path buildWavePath(int width, int height)
        {
            int DP = Dp2Px.dp2px(1);//一个dp在当前设备表示的像素量(水波的绘制精度设为一个dp单位)

            if (DP < 1)
            {
                DP = 1;
            }

            int wave = (int)(scaleY * this.wave);//计算拉伸之后的波幅

            Path path = new Path();

            path.MoveTo(0, 0);
            path.LineTo(0, height - wave);

            for (int x = DP; x < width; x += DP)
            {
                path.LineTo(x, height - wave - wave * (float)Math.Sin(4.0 * Math.PI * x / width));
            }

            path.LineTo(width, height - wave);
            path.LineTo(width, 0);
            path.Close();
            return(path);
        }
Exemple #2
0
        private void Init()
        {
            mPaint.AntiAlias = true;
            mWaveHeight      = Dp2Px.dp2px(50);
            Random random   = new Random();
            int    ranColor = Color.Red | random.Next(0x00ffffff);

            mStartColor    = ranColor;
            mCloseColor    = ranColor - 500;
            mColorAlpha    = 0.4f;
            mProgress      = 1f;
            mVelocity      = 1f;
            mGradientAngle = 45;
            mIsRunning     = true;

            Tag = "70,25,1.4,1.4,-26\n" +
                  "100,5,1.4,1.2,15\n" +
                  "420,0,1.15,1,-10\n" +
                  "520,10,1.7,1.5,20\n" +
                  "220,0,1,1,-15";
        }
Exemple #3
0
        private void updateWavePath(int w, int h)
        {
            mltWave.Clear();
            string[] waves = Tag.ToString().Split("\n");
            if ("-1".Equals(Tag))
            {
                waves = "70,25,1.4,1.4,-26\n100,5,1.4,1.2,15\n420,0,1.15,1,-10\n520,10,1.7,1.5,20\n220,0,1,1,-15".Split("\n");
            }
            else if ("-2".Equals(Tag))
            {
                waves = "0,0,1,0.5,90\n90,0,1,0.5,90".Split("\n");
            }

            foreach (string wave in waves)
            {
                string[] args = wave.Split(",");
                if (args.Length == 5)
                {
                    mltWave.Add(new Wave(Dp2Px.dp2px(Float.ParseFloat(args[0])), Dp2Px.dp2px(Float.ParseFloat(args[1])), Dp2Px.dp2px(Float.ParseFloat(args[4])), Float.ParseFloat(args[2]), Float.ParseFloat(args[3]), w, h, mWaveHeight / 2));
                }
            }
        }