|
@@ -1,13 +1,14 @@
|
|
|
// Copyright 2016 The G3N Authors. All rights reserved.
|
|
// Copyright 2016 The G3N Authors. All rights reserved.
|
|
|
// Use of this source code is governed by a BSD-style
|
|
// Use of this source code is governed by a BSD-style
|
|
|
// license that can be found in the LICENSE file.
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
+
|
|
|
package math32
|
|
package math32
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"strings"
|
|
"strings"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-// Type Color4 describes an RGBA color
|
|
|
|
|
|
|
+// Color4 describes an RGBA color
|
|
|
type Color4 struct {
|
|
type Color4 struct {
|
|
|
R float32
|
|
R float32
|
|
|
G float32
|
|
G float32
|
|
@@ -45,6 +46,7 @@ func Color4Name(name string, alpha ...float32) Color4 {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Set sets this color individual R,G,B,A components
|
|
// Set sets this color individual R,G,B,A components
|
|
|
|
|
+// Returns pointer to this updated color
|
|
|
func (c *Color4) Set(r, g, b, a float32) *Color4 {
|
|
func (c *Color4) Set(r, g, b, a float32) *Color4 {
|
|
|
|
|
|
|
|
c.R = r
|
|
c.R = r
|
|
@@ -57,6 +59,7 @@ func (c *Color4) Set(r, g, b, a float32) *Color4 {
|
|
|
// SetHex sets the color RGB components from the
|
|
// SetHex sets the color RGB components from the
|
|
|
// specified integer interpreted as a color hex number
|
|
// specified integer interpreted as a color hex number
|
|
|
// Alpha component is not modified
|
|
// Alpha component is not modified
|
|
|
|
|
+// Returns pointer to this updated color
|
|
|
func (c *Color4) SetHex(value uint) *Color4 {
|
|
func (c *Color4) SetHex(value uint) *Color4 {
|
|
|
|
|
|
|
|
c.R = float32((value >> 16 & 255)) / 255
|
|
c.R = float32((value >> 16 & 255)) / 255
|
|
@@ -67,12 +70,15 @@ func (c *Color4) SetHex(value uint) *Color4 {
|
|
|
|
|
|
|
|
// SetName sets the color RGB components from the
|
|
// SetName sets the color RGB components from the
|
|
|
// specified standard web color name
|
|
// specified standard web color name
|
|
|
|
|
+// Returns pointer to this updated color
|
|
|
func (c *Color4) SetName(name string) *Color4 {
|
|
func (c *Color4) SetName(name string) *Color4 {
|
|
|
|
|
|
|
|
*c = Color4Name(name, 1)
|
|
*c = Color4Name(name, 1)
|
|
|
return c
|
|
return c
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Add adds to each RGBA component of this color the correspondent component of other color
|
|
|
|
|
+// Returns pointer to this updated color
|
|
|
func (c *Color4) Add(other *Color4) *Color4 {
|
|
func (c *Color4) Add(other *Color4) *Color4 {
|
|
|
|
|
|
|
|
c.R += other.R
|
|
c.R += other.R
|
|
@@ -82,6 +88,8 @@ func (c *Color4) Add(other *Color4) *Color4 {
|
|
|
return c
|
|
return c
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// MultiplyScalar multiplies each RGBA component of this color by the specified scalar.
|
|
|
|
|
+// Returns pointer to this updated color
|
|
|
func (c *Color4) MultiplyScalar(v float32) *Color4 {
|
|
func (c *Color4) MultiplyScalar(v float32) *Color4 {
|
|
|
|
|
|
|
|
c.R *= v
|
|
c.R *= v
|