Commit b833ae67 authored by santiaago's avatar santiaago
Browse files

move RGBToHex to tools file in draw pkg #67

parent 84352f16
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
package squares

import (
	"fmt"
	"image/color"
	"math"
	"net/http"
@@ -20,7 +19,7 @@ func RandomGradientSVG(w http.ResponseWriter, colors, gColors []color.RGBA, gv c

	step := uint8(100 / len(gColors))
	for i, c := range gColors {
		gradientColors[i] = svg.Offcolor{percentage, RGBToHex(c.R, c.G, c.B), 1}
		gradientColors[i] = svg.Offcolor{percentage, draw.RGBToHex(c.R, c.G, c.B), 1}
		percentage += step
	}

@@ -66,8 +65,3 @@ func RandomGradientSVG(w http.ResponseWriter, colors, gColors []color.RGBA, gv c
	}
	canvas.End()
}

// RGBToHex converts an RGB triple to an Hex string.
func RGBToHex(r, g, b uint8) string {
	return fmt.Sprintf("#%02X%02X%02X", r, g, b)
}
+5 −0
Original line number Diff line number Diff line
@@ -78,3 +78,8 @@ func PickIndex(key string, n int, index int) int {
	}
	return 0
}

// RGBToHex converts an RGB triple to an Hex string.
func RGBToHex(r, g, b uint8) string {
	return fmt.Sprintf("#%02X%02X%02X", r, g, b)
}