Skip to content

Instantly share code, notes, and snippets.

View akexorcist's full-sized avatar
🔥

Akexorcist akexorcist

🔥
View GitHub Profile
val canvas: Canvas = /* ... */
val areaWidth = canvas.width
val areaHeight = canvas.height
val borderWidth = 2
val cornerRadius = 10
val semiCircleRadius = 20
val path = Path().apply {
/* ... */
// Right edge semi circle
x1 = area_width - ((semi_circle_radius / 2) + (border_width / 2))
y1 = (area_height / 2) - (semi_circle_radius / 2)
x2 = area_width + ((semi_circle_radius / 2) - (border_width / 2))
y2 = (area_height / 2) + (semi_circle_radius / 2)
start_angle = 270
sweep_angle = -180
start_angle = 270
sweep_angle = 90
x1 = area_width - ((corner_radius * 2) + (border_width / 2))
y1 = border_width / 2
x2 = area_width - (border_width / 2)
y2 = (corner_radius * 2) + (border_width / 2)
x = area_width - (corner_radius + (border_width / 2))
y = border_width / 2
val canvas: Canvas = /* ... */
val areaWidth = canvas.width
val areaHeight = canvas.height
val borderWidth = 2
val cornerRadius = 10
val semiCircleRadius = 20
val path = Path().apply {
/* ... */
// Top right corner
val canvas: Canvas = /* ... */
val areaWidth = canvas.width
val areaHeight = canvas.height
val borderWidth = 2
val cornerRadius = 10
val semiCircleRadius = 20
val path = Path().apply {
/* ... */
moveTo(
val canvas: Canvas = /* ... */
val paint: Paint = /* ... */
val path = Path().apply {
reset()
moveTo(/* Start point */)
arcTo(/* Top right corner */) // 1
arcTo(/* Right edge semi circle */) // 2
arcTo(/* Bottom right corner */) // 3
arcTo(/* Bottom edge semi circle */) // 4
arcTo(/* Bottom left corner */) // 5
class CouponLayout : FrameLayout {
/* ... */
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
// Draw something with `canvas`
}
}
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"