闲来无事玩起了PS
根据 Photoshop制作立体风格的圆形旋涡图形图标 制作了一个超好看的图片.
现在用Android代码写一个.
Paint circlePaint = new Paint();
int centerX = 0, centerY = 0;
int dark = 0xFF1A766A;//深色
int light = 0xFFABFEEE;//浅色
float sR = 100;//小圆半径
float bR = 300;//大圆半径
float mR = (sR + bR) / 2;//中圆半径
float degrees = 0;//旋转角度
private void drawLeaf(int degrees) {
Directer.canvas.save();
Directer.canvas.rotate(degrees, centerX, centerY);
Path path2 = new Path();
RectF oval1 = new RectF(centerX - mR, centerY + bR - mR - mR, centerX + mR, centerY + bR);
path2.addArc(oval1, 90, 180);//剪裁一个半圆
RectF oval2 = new RectF(centerX, centerY, centerX + mR, centerY + mR);
path2.addRect(oval2, Path.Direction.CCW);//剪裁剩余不需要的部分
Directer.canvas.clipPath(path2, Region.Op.DIFFERENCE);
LinearGradient lg = new LinearGradient(centerX - bR + mR + mR, centerY - mR,
centerX - bR + mR - mR * 0.7f, centerY + mR * 0.7f, light, dark, Shader.TileMode.MIRROR);
circlePaint.setShader(lg);//渐变色
Directer.canvas.drawCircle(centerX - bR + mR, centerY, mR, circlePaint);
Directer.canvas.restore();
}
public void update() {
degrees = (degrees + 400 * Time.deltaTime) % 360;
circlePaint.setShader(null);
circlePaint.setAntiAlias(true);
Directer.canvas.save();
Directer.canvas.rotate(degrees, centerX, centerY);
Path path = new Path();
path.addCircle(centerX, centerY, sR, Path.Direction.CCW);
Directer.canvas.clipPath(path, Region.Op.DIFFERENCE);//剪裁中间空心小圆
circlePaint.setColor(dark);
Directer.canvas.drawCircle(centerX, centerY, bR, circlePaint);//绘制大圆
drawLeaf(0);
drawLeaf(90);
drawLeaf(180);
drawLeaf(270);
Directer.canvas.restore();
}