-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvertex.go
More file actions
34 lines (28 loc) · 641 Bytes
/
vertex.go
File metadata and controls
34 lines (28 loc) · 641 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package gfx
import "image/color"
// Vertex holds Position, Color, Picture and Intensity.
type Vertex struct {
Position Vec
Color color.NRGBA
Picture Vec
Intensity float64
}
// NewVertex returns a new vertex with the given position.
func NewVertex(pos Vec, args ...interface{}) Vertex {
vx := Vertex{Position: pos}
for _, a := range args {
switch v := a.(type) {
case color.NRGBA:
vx.Color = v
case Vec:
vx.Picture = v
case float64:
vx.Intensity = v
}
}
return vx
}
// Vx returns a new vertex with the given coordinates.
func Vx(pos Vec, args ...interface{}) Vertex {
return NewVertex(pos, args...)
}