Documentation
¶
Index ¶
- Variables
- func AbsInt(x int) int
- func Clamp(x, lo, hi float64) float64
- func ClampInt(x, lo, hi int) int
- func Degrees(radians float64) float64
- func GenerateScene(fit bool, path string, objects []*Object, eye Vector, center Vector, up Vector, ...)
- func GenerateSceneToWriter(writer io.Writer, objects []*Object, eye Vector, center Vector, up Vector, ...) error
- func InterpolateFloats(v1, v2, v3 float64, b VectorW) float64
- func LoadGLTF(path string) (*Mesh, Matrix, error)
- func LoadGLTFFromBytes(b []byte) (*Mesh, Matrix, error)
- func LoadGLTFFromReader(r io.Reader) (*Mesh, Matrix, error)
- func LoadImage(path string) (image.Image, error)
- func ParseFloats(items []string) []float64
- func Radians(degrees float64) float64
- func Round(a float64) int
- func RoundPlaces(a float64, places int) float64
- func SavePNG(path string, im image.Image) error
- type Box
- func (a Box) Anchor(anchor Vector) Vector
- func (a Box) Center() Vector
- func (a Box) Contains(b Vector) bool
- func (a Box) ContainsBox(b Box) bool
- func (b Box) Corners() []Vector
- func (a Box) Extend(b Box) Box
- func (a Box) Intersection(b Box) Box
- func (a Box) Intersects(b Box) bool
- func (a Box) Offset(x float64) Box
- func (a Box) Size() Vector
- func (a Box) Transform(m Matrix) Box
- func (a Box) Translate(v Vector) Box
- func (a Box) Volume() float64
- type Color
- func (a Color) Add(b Color) Color
- func (a Color) AddScalar(b float64) Color
- func (a Color) Alpha(alpha float64) Color
- func (a Color) Div(b Color) Color
- func (a Color) DivScalar(b float64) Color
- func (a Color) Lerp(b Color, t float64) Color
- func (a Color) Max(b Color) Color
- func (a Color) Min(b Color) Color
- func (a Color) Mul(b Color) Color
- func (a Color) MulScalar(b float64) Color
- func (a Color) NRGBA() color.NRGBA
- func (a Color) Opaque() Color
- func (a Color) Pow(b float64) Color
- func (a Color) Sub(b Color) Color
- func (a Color) SubScalar(b float64) Color
- type Context
- func (dc *Context) ClearColorBuffer()
- func (dc *Context) ClearColorBufferWith(c Color)
- func (dc *Context) ClearDepthBuffer()
- func (dc *Context) DrawLine(l *Line, fromObject *Object)
- func (dc *Context) DrawMesh(mesh *Mesh, fromObject *Object)
- func (dc *Context) DrawObject(o *Object)
- func (dc *Context) DrawTriangle(t *Triangle, fromObject *Object)
- func (dc *Context) Image() image.Image
- type Cull
- type Face
- type ImageTexture
- type Line
- type Matrix
- func Frustum(left, right, bottom, top, near, far float64) Matrix
- func Identity() Matrix
- func LookAt(eye, center, up Vector) Matrix
- func LookAtDirection(forward, up Vector) Matrix
- func Orient(position, size, up Vector, rotation float64) Matrix
- func Orthographic(l, r, b, t, n, f float64) Matrix
- func Perspective(fovy, aspect, near, far float64) Matrix
- func Rotate(v Vector, a float64) Matrix
- func RotateTo(a, b Vector) Matrix
- func Scale(v Vector) Matrix
- func Screen(w, h int) Matrix
- func Translate(v Vector) Matrix
- func Viewport(x, y, w, h float64) Matrix
- func (a Matrix) Determinant() float64
- func (a Matrix) Frustum(l, r, b, t, n, f float64) Matrix
- func (a Matrix) Inverse() Matrix
- func (a Matrix) LookAt(eye, center, up Vector) Matrix
- func (a Matrix) Mul(b Matrix) Matrix
- func (a Matrix) MulBox(box Box) Box
- func (a Matrix) MulDirection(b Vector) Vector
- func (a Matrix) MulPosition(b Vector) Vector
- func (a Matrix) MulPositionW(b Vector) VectorW
- func (a Matrix) MulScalar(b float64) Matrix
- func (a Matrix) Orthographic(l, r, b, t, n, f float64) Matrix
- func (a Matrix) Perspective(fovy, aspect, near, far float64) Matrix
- func (a Matrix) Rotate(v Vector, f float64) Matrix
- func (a Matrix) RotateTo(b, c Vector) Matrix
- func (a Matrix) Scale(v Vector) Matrix
- func (a Matrix) Translate(v Vector) Matrix
- func (a Matrix) Transpose() Matrix
- func (a Matrix) Viewport(x, y, w, h float64) Matrix
- type Mesh
- func LoadMesh(path string) (*Mesh, error)
- func LoadOBJ(path string) (*Mesh, error)
- func LoadOBJFromBytes(b []byte) (*Mesh, error)
- func LoadOBJFromReader(r io.Reader) (*Mesh, error)
- func NewCone(step int, capped bool) *Mesh
- func NewCube() *Mesh
- func NewCubeForBox(box Box) *Mesh
- func NewCubeOutlineForBox(box Box) *Mesh
- func NewCylinder(step int, capped bool) *Mesh
- func NewEmptyMesh() *Mesh
- func NewIcosahedron() *Mesh
- func NewLatLngSphere(latStep, lngStep int) *Mesh
- func NewLineMesh(lines []*Line) *Mesh
- func NewMesh(triangles []*Triangle, lines []*Line) *Mesh
- func NewPlane() *Mesh
- func NewSphere(detail int) *Mesh
- func NewTriangleMesh(triangles []*Triangle) *Mesh
- func (m *Mesh) Add(b *Mesh)
- func (m *Mesh) BiUnitCube() Matrix
- func (m *Mesh) BoundingBox() Box
- func (m *Mesh) Center() Matrix
- func (m *Mesh) Copy() *Mesh
- func (m *Mesh) FitInside(box Box, anchor Vector) Matrix
- func (m *Mesh) MoveTo(position, anchor Vector) Matrix
- func (m *Mesh) ReverseWinding()
- func (m *Mesh) Simplify(factor float64)
- func (m *Mesh) SmoothNormals()
- func (m *Mesh) SmoothNormalsThreshold(radians float64)
- func (m *Mesh) SurfaceArea() float64
- func (m *Mesh) Transform(matrix Matrix)
- func (m *Mesh) UnitCube() Matrix
- func (m *Mesh) Volume() float64
- type Object
- type PhongShader
- type Scene
- type Shader
- type SolidColorShader
- type Texture
- type ToonShader
- type Triangle
- type Vector
- func (a Vector) Abs() Vector
- func (a Vector) Add(b Vector) Vector
- func (a Vector) AddScalar(b float64) Vector
- func (a Vector) Ceil() Vector
- func (a Vector) Cross(b Vector) Vector
- func (a Vector) Distance(b Vector) float64
- func (a Vector) DistanceSquared(b Vector) float64
- func (a Vector) Div(b Vector) Vector
- func (a Vector) DivScalar(b float64) Vector
- func (a Vector) Dot(b Vector) float64
- func (a Vector) Floor() Vector
- func (a Vector) IsDegenerate() bool
- func (a Vector) Length() float64
- func (a Vector) LengthSquared() float64
- func (a Vector) Lerp(b Vector, t float64) Vector
- func (a Vector) LerpDistance(b Vector, d float64) Vector
- func (a Vector) Less(b Vector) bool
- func (a Vector) Max(b Vector) Vector
- func (a Vector) MaxComponent() float64
- func (a Vector) Min(b Vector) Vector
- func (a Vector) MinComponent() float64
- func (a Vector) Mod(b Vector) Vector
- func (a Vector) Mul(b Vector) Vector
- func (a Vector) MulScalar(b float64) Vector
- func (a Vector) Negate() Vector
- func (a Vector) Normalize() Vector
- func (a Vector) Perpendicular() Vector
- func (a Vector) PowScalar(b float64) Vector
- func (a Vector) Reflect(n Vector) Vector
- func (a Vector) Round() Vector
- func (a Vector) RoundPlaces(n int) Vector
- func (a Vector) SegmentDistance(v Vector, w Vector) float64
- func (a Vector) Sub(b Vector) Vector
- func (a Vector) SubScalar(b float64) Vector
- func (a Vector) VectorW() VectorW
- type VectorW
- type Vertex
Constants ¶
This section is empty.
Variables ¶
var ( // Discard empty color Discard = Color{} // Transparent transparent color Transparent = Color{} // Black black color Black = Color{0, 0, 0, 1} // White white color White = Color{1, 1, 1, 1} )
var EmptyBox = Box{}
EmptyBox f
Functions ¶
func GenerateScene ¶
func GenerateScene(fit bool, path string, objects []*Object, eye Vector, center Vector, up Vector, fovy float64, size int, scale int, light Vector, ambient string, diffuse string, near, far float64)
GenerateScene is a high-level helper
func GenerateSceneToWriter ¶
func InterpolateFloats ¶
InterpolateFloats f
Types ¶
type Color ¶
type Color struct {
R, G, B, A float64
}
Color color struct
func InterpolateColors ¶
InterpolateColors f
type Context ¶
type Context struct {
Width int
Height int
Shader Shader
ColorBuffer *image.NRGBA
DepthBuffer []float64
ClearColor Color
ReadDepth bool
WriteDepth bool
WriteColor bool
AlphaBlend bool
Wireframe bool
FrontFace Face
Cull Cull
LineWidth float64
DepthBias float64
// contains filtered or unexported fields
}
func NewContext ¶
func (*Context) ClearColorBuffer ¶
func (dc *Context) ClearColorBuffer()
func (*Context) ClearColorBufferWith ¶
ClearColorBufferWith uses fast memory copy to clear the buffer
func (*Context) ClearDepthBuffer ¶
func (dc *Context) ClearDepthBuffer()
func (*Context) DrawObject ¶
func (*Context) DrawTriangle ¶
type ImageTexture ¶
func (*ImageTexture) BilinearSample ¶
func (t *ImageTexture) BilinearSample(u, v float64) Color
func (*ImageTexture) Sample ¶
func (t *ImageTexture) Sample(u, v float64) Color
type Matrix ¶
type Matrix struct {
X00, X01, X02, X03 float64
X10, X11, X12, X13 float64
X20, X21, X22, X23 float64
X30, X31, X32, X33 float64
}
Matrix f
func (Matrix) Orthographic ¶
Orthographic f
func (Matrix) Perspective ¶
Perspective f
type Mesh ¶
Mesh f
func LoadOBJFromBytes ¶
func NewTriangleMesh ¶
NewTriangleMesh returns a mesh with given data
func (*Mesh) SmoothNormalsThreshold ¶
SmoothNormalsThreshold f
type PhongShader ¶
type PhongShader struct {
Matrix Matrix
LightDirection Vector
CameraPosition Vector
AmbientColor Color
DiffuseColor Color
SpecularColor Color
SpecularPower float64
EnableOutline bool // A switch to turn the effect on/off
OutlineColor Color // The color of the outline
OutlineFactor float64 // Controls line thickness (lower is thicker)
}
PhongShader implements Phong shading with an optional texture.
func NewPhongShader ¶
func NewPhongShader(matrix Matrix, lightDirection, cameraPosition Vector, ambient Color, diffuse Color) *PhongShader
NewPhongShader f
type Scene ¶
func (*Scene) FitObjectsToScene ¶
FitObjectsToScene automatically positions the eye to see all objects.
func (*Scene) GetSafetyClipping ¶
type SolidColorShader ¶
SolidColorShader is a simple shader that renders everything in one color.
func NewSolidColorShader ¶
func NewSolidColorShader(matrix Matrix, color Color, thickness float64) *SolidColorShader
func (*SolidColorShader) Fragment ¶
func (s *SolidColorShader) Fragment(v Vertex, fromObject *Object) Color
func (*SolidColorShader) Vertex ¶
func (s *SolidColorShader) Vertex(v Vertex) Vertex
type Texture ¶
func LoadTexture ¶
func LoadTextureFromURL ¶
func NewImageTexture ¶
func TexFromBytes ¶
type ToonShader ¶
type ToonShader struct {
Matrix Matrix
LightDirection Vector
CameraPosition Vector
AmbientColor Color
DiffuseColor Color
// Cel Shading
LightCutoff float64 // The point at which the light transitions to full shadow (0-1)
ShadowBands float64 // The number of distinct shadow bands (e.g., 1, 2, 3)
// Specular
SpecularColor Color
Glossiness float64 // Smoothness of the specular highlight (0-1)
// Rim Lighting
RimColor Color
RimSize float64 // How much of the edge the rim light should cover (0-1)
}
ToonShader implements cel shading with optional outlining.
func NewToonShader ¶
func NewToonShader(matrix Matrix, lightDir, cameraPosition Vector, ambient, diffuse Color) *ToonShader
func (*ToonShader) Vertex ¶
func (s *ToonShader) Vertex(v Vertex) Vertex
type Triangle ¶
type Triangle struct {
V1, V2, V3 Vertex
}
Triangle f
func ClipTriangle ¶
func NewTriangleForPoints ¶
NewTriangleForPoints f
type Vector ¶
type Vector struct {
X, Y, Z float64
}
Vector f
func InterpolateVectors ¶
InterpolateVectors f
func (Vector) LerpDistance ¶
LerpDistance f
func (Vector) SegmentDistance ¶
SegmentDistance f
type VectorW ¶
type VectorW struct {
X, Y, Z, W float64
}
VectorW f
func InterpolateVectorWs ¶
InterpolateVectorWs f

