@@ -24,6 +24,10 @@ import (
2424var googleLogo2BitBytes []byte
2525var googleLogo2Bit image.Image
2626
27+ //go:embed google1bit.png
28+ var googleLogo1BitBytes []byte
29+ var googleLogo1Bit image.Image
30+
2731var mapClient * gmaps.Client
2832
2933func init () {
@@ -37,6 +41,10 @@ func init() {
3741 if err != nil {
3842 panic (err )
3943 }
44+ googleLogo1Bit , err = png .Decode (bytes .NewReader (googleLogo1BitBytes ))
45+ if err != nil {
46+ panic (err )
47+ }
4048}
4149
4250type MapWidget struct {
@@ -53,6 +61,7 @@ func mapWidget(ctx context.Context, markerString, includeLocationString string)
5361 markers := make (map [string ]util.Coords )
5462 threadContext := query .ThreadContextFromContext (ctx )
5563 poiInfo := threadContext .ContextStorage .POIs
64+ // Sometimes the model decides to quote random parts of the string, I don't know.
5665 markerString = strings .ReplaceAll (markerString , "\" " , "" )
5766 for _ , marker := range strings .Split (markerString , "," ) {
5867 parts := strings .Split (marker , ":" )
@@ -191,6 +200,7 @@ func monochrome(img image.Image) image.Image {
191200 }
192201 }
193202 }
203+ stampLogo (newImg , googleLogo1Bit )
194204 return newImg
195205}
196206
@@ -207,13 +217,17 @@ func lowColour(img image.Image) image.Image {
207217 }
208218 }
209219 }
210- // slap the 2-bit version of the Google logo over the existing one
211- topCorner := image .Pt (8 , newImg .Bounds ().Max .Y - 16 )
212- targetImageRect := image .Rect (topCorner .X , topCorner .Y , topCorner .X + googleLogo2Bit .Bounds ().Dx (), topCorner .Y + googleLogo2Bit .Bounds ().Dy ())
213- draw .Draw (newImg , targetImageRect , googleLogo2Bit , image.Point {0 , 0 }, draw .Over )
220+ stampLogo (newImg , googleLogo2Bit )
214221 return newImg
215222}
216223
224+ func stampLogo (img * image.Paletted , logo image.Image ) {
225+ // slap the black and white version of the Google logo over the existing one
226+ topCorner := image .Pt (7 , img .Bounds ().Max .Y - 17 )
227+ targetImageRect := image .Rect (topCorner .X , topCorner .Y , topCorner .X + googleLogo2Bit .Bounds ().Dx (), topCorner .Y + googleLogo2Bit .Bounds ().Dy ())
228+ draw .Draw (img , targetImageRect , logo , image.Point {0 , 0 }, draw .Over )
229+ }
230+
217231func greyTo2BitGrey (c color.Color ) color.Color {
218232 y := color .GrayModel .Convert (c ).(color.Gray ).Y
219233 switch {
@@ -228,20 +242,6 @@ func greyTo2BitGrey(c color.Color) color.Color {
228242 }
229243}
230244
231- func colourToMonochrome (c color.Color ) color.Color {
232- isBlack := color .Gray16Model .Convert (c ).(color.Gray16 ).Y <= 0xEFFF
233- if isBlack {
234- return color .Black
235- } else {
236- return color .White
237- }
238- }
239-
240- func closeToWhite (c color.Color ) bool {
241- r , g , b , _ := c .RGBA ()
242- return r > 0x7FFF && g > 0x7FFF && b > 0x7FFF
243- }
244-
245245func closeToBlack (c color.Color ) bool {
246246 r , _ , _ , _ := c .RGBA ()
247247 return r <= 0x8FFF
@@ -251,8 +251,3 @@ func shouldDither(c color.Color) bool {
251251 r , g , b , _ := c .RGBA ()
252252 return r == 42148 && g == 43176 && b == 43690
253253}
254-
255- func isGrey (c color.Color ) bool {
256- r , g , b , _ := c .RGBA ()
257- return r == g && g == b
258- }
0 commit comments