Skip to content

Commit

Permalink
Compliance with gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
joweich committed Jun 15, 2023
1 parent 6c68c2d commit 48470bd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion customTypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ type ImageConfig struct {
HueOffset float64
Mixing bool
InsideBlack bool
RndGlobal uint64
RndGlobal uint64
}
28 changes: 16 additions & 12 deletions hsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ import (
// https://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c

func hueToRGB(p, q, t float64) float64 {
if t < 0 { t += 1 }
if t > 1 { t -= 1 }
if t < 0 {
t += 1
}
if t > 1 {
t -= 1
}
switch {
case t < 1.0 / 6.0:
return p + (q - p) * 6 * t
case t < 1.0 / 2.0:
case t < 1.0/6.0:
return p + (q-p)*6*t
case t < 1.0/2.0:
return q
case t < 2.0 / 3.0:
return p + (q - p) * (2.0 / 3.0 - t) * 6
case t < 2.0/3.0:
return p + (q-p)*(2.0/3.0-t)*6
default:
return p
}
Expand All @@ -32,12 +36,12 @@ func hslToRGB(h, s, l float64) color.RGBA {
if l < 0.5 {
q = l * (1 + s)
} else {
q = l + s - l * s
q = l + s - l*s
}
p = 2 * l - q
r = hueToRGB(p, q, h + 1.0 / 3.0)
p = 2*l - q
r = hueToRGB(p, q, h+1.0/3.0)
g = hueToRGB(p, q, h)
b = hueToRGB(p, q, h - 1.0 / 3.0)
b = hueToRGB(p, q, h-1.0/3.0)
}
return color.RGBA{ R: uint8(r * 255), G: uint8(g * 255), B: uint8(b * 255), A: 255 }
return color.RGBA{R: uint8(r * 255), G: uint8(g * 255), B: uint8(b * 255), A: 255}
}
5 changes: 2 additions & 3 deletions linear.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func LinearToRGB(lin uint16) uint8 {
div := uint32(mul >> 32)
l := uint32(lin2rgb[uint8(div)])

return uint8((uint64(257 * l + uint32(uint64(uint32(mul)) * 257 >> 32) *
(uint32(lin2rgb[uint8(div + 1)]) - l ) + 0x8100) * 0x1fc05f9) >> 41)
return uint8((uint64(257*l+uint32(uint64(uint32(mul))*257>>32)*
(uint32(lin2rgb[uint8(div+1)])-l)+0x8100) * 0x1fc05f9) >> 41)
}

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func parseImageConfigArgs() {
HueOffset: *hueOffsetPtr,
Mixing: *mixingPtr,
InsideBlack: *insideBlackPtr,
RndGlobal: uint64(time.Now().UnixNano()),
RndGlobal: uint64(time.Now().UnixNano()),
}
}

Expand Down
2 changes: 1 addition & 1 deletion rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ func RandUint64(rng *uint64) uint64 {

func RandFloat64(rng *uint64) float64 {
return float64(RandUint64(rng)/2) / (1 << 63)
}
}

0 comments on commit 48470bd

Please sign in to comment.