From a89f80f4007e8609b5c8d24d3e2ca3a0c394ba2a Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Fri, 13 Apr 2018 07:19:43 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20minor=20multi-identicon=20improv?= =?UTF-8?q?ements/fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/ch/dissem/apps/abit/Identicon.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ch/dissem/apps/abit/Identicon.kt b/app/src/main/java/ch/dissem/apps/abit/Identicon.kt index 6cfd56b..3dd417f 100644 --- a/app/src/main/java/ch/dissem/apps/abit/Identicon.kt +++ b/app/src/main/java/ch/dissem/apps/abit/Identicon.kt @@ -124,7 +124,7 @@ class MultiIdenticon(input: List, @ColorInt private val backg color = backgroundColor } - private val identicons = input.map { Identicon(it) }.take(4) + private val identicons = input.sortedBy { it.isChan }.map { Identicon(it) }.take(4) override fun draw(canvas: Canvas) { val width = canvas.width.toFloat() @@ -145,17 +145,18 @@ class MultiIdenticon(input: List, @ColorInt private val backg } } 3 -> { - val scale = 1f / (1f + 2f * sqrt(3f)) + val scale = 2f / (1f + 2f * sqrt(3f)) val w = width * scale val h = height * scale + canvas.drawCircle(width / 2, height / 2, width / 2, paint) identicons[0].draw(canvas, (width - w) / 2, 0f, w, h) identicons[1].draw(canvas, (width - 2 * w) / 2, h * sqrt(3f) / 2, w, h) identicons[2].draw(canvas, width / 2, h * sqrt(3f) / 2, w, h) } 4 -> { canvas.drawCircle(width / 2, height / 2, width / 2, paint) - val scale = 1f / (1f + sqrt(2f)) + val scale = 2f / (1f + sqrt(2f)) val borderScale = 0.5f - scale val w = width * scale val h = height * scale