From 6441866c692b3f89c14e477f2e268a302073eab8 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 13 Oct 2017 23:51:55 -0400 Subject: [PATCH 1/2] correct logic on min..max size search --- besticon/besticon.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/besticon/besticon.go b/besticon/besticon.go index 9d9048c4..93bebe2e 100644 --- a/besticon/besticon.go +++ b/besticon/besticon.go @@ -109,10 +109,10 @@ func (f *IconFinder) IconInSizeRange(r SizeRange) *Icon { } } - // Try to return biggest in range perfect..min + // Try to return biggest in range min..max sortIcons(icons, true) for _, ico := range icons { - if ico.Width >= r.Min && ico.Height >= r.Min { + if (ico.Width >= r.Min && ico.Height >= r.Min) && (ico.Width <= r.Max && ico.Height <= r.Max) { return &ico } } From fde169bfd7100216783775ea691f7c266ed8797f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 14 Oct 2017 00:06:11 -0400 Subject: [PATCH 2/2] we want perfect..min, not max..min --- besticon/besticon.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/besticon/besticon.go b/besticon/besticon.go index 93bebe2e..a8d7f672 100644 --- a/besticon/besticon.go +++ b/besticon/besticon.go @@ -109,10 +109,10 @@ func (f *IconFinder) IconInSizeRange(r SizeRange) *Icon { } } - // Try to return biggest in range min..max + // Try to return biggest in range perfect..min sortIcons(icons, true) for _, ico := range icons { - if (ico.Width >= r.Min && ico.Height >= r.Min) && (ico.Width <= r.Max && ico.Height <= r.Max) { + if (ico.Width >= r.Min && ico.Height >= r.Min) && (ico.Width <= r.Perfect && ico.Height <= r.Perfect) { return &ico } }