Created
February 25, 2019 09:05
-
-
Save vorobeij/a980c1273610392342b2651fb6ef4874 to your computer and use it in GitHub Desktop.
squirqle bezier curve
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private inline fun drawBadgeSquirqle(canvas: Canvas) { | |
val badgeText = badge.toString() | |
badgeTextPaint.textScaleX = absCos(animFloat.value * Math.PI) | |
badgeTextPaint.getTextBounds(badgeText, 0, badgeText.length, badge.drawRect) | |
val cx = centerX + iconHalf | |
val cy = centerY - iconHalf | |
val w = badge.drawRect.width() * 0.9f | |
val h = badge.drawRect.height() * 0.9f | |
val left = cx - w | |
val right = cx + w | |
val top = cy - h | |
val bottom = cy + h | |
with(badgePath) { | |
reset() | |
moveTo(left, cy) | |
cubicTo( | |
left, top, | |
left, top, | |
cx, top | |
) | |
cubicTo( | |
right, top, | |
right, top, | |
right, cy | |
) | |
cubicTo( | |
right, bottom, | |
right, bottom, | |
cx, bottom | |
) | |
cubicTo( | |
left, bottom, | |
left, bottom, | |
left, cy | |
) | |
} | |
canvas.drawPath(badgePath, badgePaint) | |
canvas.drawTextCentered(badgeText, cx, cy, badgeTextPaint, badge.drawRect) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment