android绘制多个圆交叉的地方,Android绘制立体风格的圆形旋涡

闲来无事玩起了PS

e47aa97d22aa

PS做得不咋滴

现在用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();

}

完成效果

e47aa97d22aa

会转动的哦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值