Github地址:https://github.com/nuptboyzhb/WaterWaveView
欢迎Fork,欢迎Star
1.先看效果
2.再看关键代码
描绘函数y = Asin(wx+d)+offset
/** * 使用路径描绘绘制的区域 * * @return */ private Path getFristWavePath() { // 绘制区域1的路径 if (firstWavePath == null) { firstWavePath = new Path(); } firstWavePath.reset(); firstWavePath.moveTo(0, height);// 移动到左下角的点 for (float x = 0; x <= width; x += X_STEP) { float y = (float) (waveHeight * Math.sin(omega * x + moveWave) + waveHeight) + heightOffset; firstWavePath.lineTo(x, y); } firstWavePath.lineTo(width, 0); firstWavePath.lineTo(width, height); return firstWavePath; }
更多交流
Android开发联盟QQ群:272209595
时间: 2024-10-09 17:21:49