@@ -16,11 +16,11 @@ import (
16
16
"time"
17
17
18
18
"github.com/llgcode/draw2d"
19
- //"golang.org/x/image/math/fixed"
20
19
21
- //"golang.org/x/image/colornames"
22
- //"golang.org/x/image/font"
23
- //"golang.org/x/image/math/fixed"
20
+ "golang.org/x/image/math/fixed"
21
+
22
+ "golang.org/x/image/colornames"
23
+ "golang.org/x/image/font"
24
24
25
25
"github.com/bwiggs/go-nexrad/archive2"
26
26
"github.com/cheggaaa/pb/v3"
@@ -29,7 +29,7 @@ import (
29
29
"github.com/llgcode/draw2d/draw2dsvg"
30
30
"github.com/sirupsen/logrus"
31
31
"github.com/spf13/cobra"
32
- // "golang.org/x/image/font/inconsolata"
32
+ "golang.org/x/image/font/inconsolata"
33
33
)
34
34
35
35
var cmd = & cobra.Command {
@@ -282,9 +282,13 @@ func render(out string, radials []*archive2.Message31, label string) {
282
282
283
283
// fmt.Println(valueDist)
284
284
285
- //if renderLabel {
286
- // addLabel(canvas, int(width-495.0), int(height-10.0), label)
287
- //}
285
+ if renderLabel {
286
+ if vectorize == "png" {
287
+ addLabel (PNGcanvas , int (width - 495.0 ), int (height - 10.0 ), label )
288
+ } else if vectorize == "svg" {
289
+ logrus .Warn ("Labels cannot be drawn on an SVG image, ignoring -L flag" )
290
+ }
291
+ }
288
292
289
293
// Save to file
290
294
if vectorize == "png" {
@@ -294,17 +298,17 @@ func render(out string, radials []*archive2.Message31, label string) {
294
298
}
295
299
}
296
300
297
- // func addLabel(img *draw2dsvg.Svg , x, y int, label string) {
298
- // point := fixed.Point26_6{fixed.Int26_6(x * 64), fixed.Int26_6(y * 64)}
299
- //
300
- // d := &font.Drawer{
301
- // Dst: img,
302
- // Src: image.NewUniform(colornames.Gray),
303
- // Face: inconsolata.Bold8x16,
304
- // Dot: point,
305
- // }
306
- // d.DrawString(label)
307
- // }
301
+ func addLabel (img * image. RGBA , x , y int , label string ) {
302
+ point := fixed.Point26_6 {fixed .Int26_6 (x * 64 ), fixed .Int26_6 (y * 64 )}
303
+
304
+ d := & font.Drawer {
305
+ Dst : img ,
306
+ Src : image .NewUniform (colornames .Gray ),
307
+ Face : inconsolata .Bold8x16 ,
308
+ Dot : point ,
309
+ }
310
+ d .DrawString (label )
311
+ }
308
312
309
313
// scaleInt scales a number form one range to another range
310
314
func scaleInt (value , oldMax , oldMin , newMax , newMin int32 ) int32 {
0 commit comments