We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
大神,你好,我今天在使用贵控件时,当把星星前景和背景颜色分别设置为如下颜色值时starForegroundColor=0xffff5400,starBackgroundColor = 0x99333333,出现空星星中间圆部分出现黑色边线,初步认为绘制星星中部算法可能有问题: private void drawSolidStar(StarModel star, Canvas canvas, int fillColor) { paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setColor(fillColor); paint.setPathEffect(pathEffect); VertexF prev = star.getVertex(1); Path path = new Path(); for (int i = 0; i < 5; i++) { path.rewind(); path.moveTo(prev.x, prev.y); VertexF next = prev.next; path.lineTo(next.x, next.y); path.lineTo(next.next.x, next.next.y); path.lineTo(next.next.x, next.next.y); canvas.drawPath(path, paint); prev = next.next; } // fill the middle hole. use +1.0 +1.5 because the path-API will leave 1px gap. path.rewind(); prev = star.getVertex(1); path.moveTo(prev.x - 1f, prev.y - 1f); prev = prev.next.next; path.lineTo(prev.x + 1.5f, prev.y - 0.5f); prev = prev.next.next; path.lineTo(prev.x + 1.5f, prev.y + 1f); prev = prev.next.next; path.lineTo(prev.x, prev.y + 1f); prev = prev.next.next; path.lineTo(prev.x - 1f, prev.y + 1f); paint.setPathEffect(null); canvas.drawPath(path, paint); }
private void drawSolidStar(StarModel star, Canvas canvas, int fillColor) { paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setColor(fillColor); paint.setPathEffect(pathEffect); VertexF prev = star.getVertex(1); Path path = new Path(); for (int i = 0; i < 5; i++) { path.rewind(); path.moveTo(prev.x, prev.y); VertexF next = prev.next; path.lineTo(next.x, next.y); path.lineTo(next.next.x, next.next.y); path.lineTo(next.next.x, next.next.y); canvas.drawPath(path, paint); prev = next.next; } // fill the middle hole. use +1.0 +1.5 because the path-API will leave 1px gap. path.rewind(); prev = star.getVertex(1); path.moveTo(prev.x - 1f, prev.y - 1f); prev = prev.next.next; path.lineTo(prev.x + 1.5f, prev.y - 0.5f); prev = prev.next.next; path.lineTo(prev.x + 1.5f, prev.y + 1f); prev = prev.next.next; path.lineTo(prev.x, prev.y + 1f); prev = prev.next.next; path.lineTo(prev.x - 1f, prev.y + 1f); paint.setPathEffect(null); canvas.drawPath(path, paint); }
在细看代码时,收获很大,也有点疑惑,就是为什么需要分两次画填充满星星?我考虑改为一次path填充画完时,发现没有了该现象,分两次画填充时,绘制星星中部路径算法是否存在问题?代码如下所示: private void drawSolidStar(StarModel star, Canvas canvas, int fillColor) { paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setColor(fillColor); paint.setPathEffect(pathEffect); VertexF prev = star.getVertex(1); Path path = new Path(); path.moveTo(prev.x, prev.y); for (int i = 0; i < 5; i++) { VertexF next = prev.next; path.lineTo(next.x, next.y); path.lineTo(next.next.x, next.next.y); path.lineTo(next.next.x, next.next.y); prev = next.next; } canvas.drawPath(path, paint); }
private void drawSolidStar(StarModel star, Canvas canvas, int fillColor) { paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setColor(fillColor); paint.setPathEffect(pathEffect); VertexF prev = star.getVertex(1); Path path = new Path(); path.moveTo(prev.x, prev.y); for (int i = 0; i < 5; i++) { VertexF next = prev.next; path.lineTo(next.x, next.y); path.lineTo(next.next.x, next.next.y); path.lineTo(next.next.x, next.next.y); prev = next.next; } canvas.drawPath(path, paint); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
大神,你好,我今天在使用贵控件时,当把星星前景和背景颜色分别设置为如下颜色值时starForegroundColor=0xffff5400,starBackgroundColor = 0x99333333,出现空星星中间圆部分出现黑色边线,初步认为绘制星星中部算法可能有问题:
private void drawSolidStar(StarModel star, Canvas canvas, int fillColor) { paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setColor(fillColor); paint.setPathEffect(pathEffect); VertexF prev = star.getVertex(1); Path path = new Path(); for (int i = 0; i < 5; i++) { path.rewind(); path.moveTo(prev.x, prev.y); VertexF next = prev.next; path.lineTo(next.x, next.y); path.lineTo(next.next.x, next.next.y); path.lineTo(next.next.x, next.next.y); canvas.drawPath(path, paint); prev = next.next; } // fill the middle hole. use +1.0 +1.5 because the path-API will leave 1px gap. path.rewind(); prev = star.getVertex(1); path.moveTo(prev.x - 1f, prev.y - 1f); prev = prev.next.next; path.lineTo(prev.x + 1.5f, prev.y - 0.5f); prev = prev.next.next; path.lineTo(prev.x + 1.5f, prev.y + 1f); prev = prev.next.next; path.lineTo(prev.x, prev.y + 1f); prev = prev.next.next; path.lineTo(prev.x - 1f, prev.y + 1f); paint.setPathEffect(null); canvas.drawPath(path, paint); }
在细看代码时,收获很大,也有点疑惑,就是为什么需要分两次画填充满星星?我考虑改为一次path填充画完时,发现没有了该现象,分两次画填充时,绘制星星中部路径算法是否存在问题?代码如下所示:
private void drawSolidStar(StarModel star, Canvas canvas, int fillColor) { paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setColor(fillColor); paint.setPathEffect(pathEffect); VertexF prev = star.getVertex(1); Path path = new Path(); path.moveTo(prev.x, prev.y); for (int i = 0; i < 5; i++) { VertexF next = prev.next; path.lineTo(next.x, next.y); path.lineTo(next.next.x, next.next.y); path.lineTo(next.next.x, next.next.y); prev = next.next; } canvas.drawPath(path, paint); }
The text was updated successfully, but these errors were encountered: