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 InterpolateFloats(v1, v2, v3 float64, b VectorW) float64
- 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
- func SaveSTL(path string, mesh *Mesh) 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 (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 (c 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(color Color)
- func (dc *Context) ClearDepthBuffer()
- func (dc *Context) ClearDepthBufferWith(value float64)
- func (dc *Context) DrawLine(t *Line) RasterizeInfo
- func (dc *Context) DrawLines(lines []*Line) RasterizeInfo
- func (dc *Context) DrawMesh(mesh *Mesh) RasterizeInfo
- func (dc *Context) DrawTriangle(t *Triangle) RasterizeInfo
- func (dc *Context) DrawTriangles(triangles []*Triangle) RasterizeInfo
- func (dc *Context) Image() image.Image
- type Cull
- type Face
- type ImageTexture
- type Line
- type Matrix
- func Frustum(l, r, b, t, n, f 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 (m Matrix) Frustum(l, r, b, t, n, f float64) Matrix
- func (a Matrix) Inverse() Matrix
- func (m 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 (m Matrix) Orthographic(l, r, b, t, n, f float64) Matrix
- func (m Matrix) Perspective(fovy, aspect, near, far float64) Matrix
- func (m Matrix) Rotate(v Vector, a float64) Matrix
- func (m Matrix) RotateTo(a, b Vector) Matrix
- func (m Matrix) Scale(v Vector) Matrix
- func (m Matrix) Translate(v Vector) Matrix
- func (a Matrix) Transpose() Matrix
- func (m Matrix) Viewport(x, y, w, h float64) Matrix
- type Mesh
- func Load3DS(filename string) (*Mesh, error)
- func LoadMesh(path string) (*Mesh, error)
- func LoadOBJ(path string) (*Mesh, error)
- func LoadPLY(path string) (*Mesh, error)
- func LoadSTL(path string) (*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 NewVoxelMesh(voxels []Voxel) *Mesh
- func (a *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) SaveSTL(path string) error
- func (m *Mesh) SetColor(c Color)
- func (m *Mesh) Silhouette(eye Vector, offset float64) *Mesh
- func (m *Mesh) Simplify(factor float64)
- func (m *Mesh) SmoothNormals()
- func (m *Mesh) SmoothNormalsThreshold(radians float64)
- func (m *Mesh) SplitTriangles(maxEdgeLength float64)
- func (m *Mesh) SurfaceArea() float64
- func (m *Mesh) Transform(matrix Matrix)
- func (m *Mesh) UnitCube() Matrix
- func (m *Mesh) Volume() float64
- type PhongShader
- type RasterizeInfo
- type STLHeader
- type STLTriangle
- type Shader
- type SolidColorShader
- type Texture
- type TextureShader
- type Triangle
- type VOXChunk
- type VOXHeader
- type VOXVoxel
- 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 (i Vector) Reflect(n Vector) Vector
- func (a Vector) Round() Vector
- func (a Vector) RoundPlaces(n int) Vector
- func (p 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
- type Voxel
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Discard = Color{} Transparent = Color{} Black = Color{0, 0, 0, 1} White = Color{1, 1, 1, 1} )
View Source
var EmptyBox = Box{}
Functions ¶
func InterpolateFloats ¶
func ParseFloats ¶
func RoundPlaces ¶
Types ¶
type Box ¶
type Box struct {
Min, Max Vector
}
func BoxForBoxes ¶
func (Box) ContainsBox ¶
func (Box) Intersection ¶
func (Box) Intersects ¶
type Context ¶
type Context struct { Width int Height int ColorBuffer *image.NRGBA DepthBuffer []float64 ClearColor Color Shader Shader 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 ¶
func (*Context) ClearDepthBuffer ¶
func (dc *Context) ClearDepthBuffer()
func (*Context) ClearDepthBufferWith ¶
func (*Context) DrawLine ¶
func (dc *Context) DrawLine(t *Line) RasterizeInfo
func (*Context) DrawLines ¶
func (dc *Context) DrawLines(lines []*Line) RasterizeInfo
func (*Context) DrawMesh ¶
func (dc *Context) DrawMesh(mesh *Mesh) RasterizeInfo
func (*Context) DrawTriangle ¶
func (dc *Context) DrawTriangle(t *Triangle) RasterizeInfo
func (*Context) DrawTriangles ¶
func (dc *Context) DrawTriangles(triangles []*Triangle) RasterizeInfo
type ImageTexture ¶
func (*ImageTexture) BilinearSample ¶
func (t *ImageTexture) BilinearSample(u, v float64) Color
func (*ImageTexture) FastSample ¶
func (t *ImageTexture) FastSample(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
}
func LookAtDirection ¶
func Orthographic ¶
func Perspective ¶
func (Matrix) Determinant ¶
func (Matrix) MulDirection ¶
func (Matrix) MulPosition ¶
func (Matrix) MulPositionW ¶
func (Matrix) Orthographic ¶
func (Matrix) Perspective ¶
type Mesh ¶
func NewCubeForBox ¶
func NewCubeOutlineForBox ¶
func NewCylinder ¶
func NewEmptyMesh ¶
func NewEmptyMesh() *Mesh
func NewIcosahedron ¶
func NewIcosahedron() *Mesh
func NewLatLngSphere ¶
func NewLineMesh ¶
func NewTriangleMesh ¶
func NewVoxelMesh ¶
func (*Mesh) BiUnitCube ¶
func (*Mesh) BoundingBox ¶
func (*Mesh) ReverseWinding ¶
func (m *Mesh) ReverseWinding()
func (*Mesh) SmoothNormals ¶
func (m *Mesh) SmoothNormals()
func (*Mesh) SmoothNormalsThreshold ¶
func (*Mesh) SplitTriangles ¶
func (*Mesh) SurfaceArea ¶
type PhongShader ¶
type PhongShader struct { Matrix Matrix LightDirection Vector CameraPosition Vector ObjectColor Color AmbientColor Color DiffuseColor Color SpecularColor Color Texture Texture SpecularPower float64 }
PhongShader implements Phong shading with an optional texture.
func NewPhongShader ¶
func NewPhongShader(matrix Matrix, lightDirection, cameraPosition Vector) *PhongShader
func (*PhongShader) Fragment ¶
func (shader *PhongShader) Fragment(v Vertex) Color
func (*PhongShader) Vertex ¶
func (shader *PhongShader) Vertex(v Vertex) Vertex
type RasterizeInfo ¶
func (RasterizeInfo) Add ¶
func (info RasterizeInfo) Add(other RasterizeInfo) RasterizeInfo
type STLTriangle ¶
type STLTriangle struct {
N, V1, V2, V3 [3]float32
// contains filtered or unexported fields
}
type SolidColorShader ¶
SolidColorShader renders with a single, solid color.
func NewSolidColorShader ¶
func NewSolidColorShader(matrix Matrix, color Color) *SolidColorShader
func (*SolidColorShader) Fragment ¶
func (shader *SolidColorShader) Fragment(v Vertex) Color
func (*SolidColorShader) Vertex ¶
func (shader *SolidColorShader) Vertex(v Vertex) Vertex
type Texture ¶
type Texture interface { FastSample(u, v float64) Color Sample(u, v float64) Color BilinearSample(u, v float64) Color }
func LoadTexture ¶
func NewImageTexture ¶
type TextureShader ¶
TextureShader renders with a texture and no lighting.
func NewTextureShader ¶
func NewTextureShader(matrix Matrix, texture Texture) *TextureShader
func (*TextureShader) Fragment ¶
func (shader *TextureShader) Fragment(v Vertex) Color
func (*TextureShader) Vertex ¶
func (shader *TextureShader) Vertex(v Vertex) Vertex
type Triangle ¶
type Triangle struct {
V1, V2, V3 Vertex
}
func ClipTriangle ¶
func NewTriangle ¶
func NewTriangleForPoints ¶
func (*Triangle) BoundingBox ¶
func (*Triangle) FixNormals ¶
func (t *Triangle) FixNormals()
func (*Triangle) IsDegenerate ¶
func (*Triangle) ReverseWinding ¶
func (t *Triangle) ReverseWinding()
type Vector ¶
type Vector struct {
X, Y, Z float64
}
func InterpolateVectors ¶
func LatLngToXYZ ¶
func RandomUnitVector ¶
func RandomUnitVector() Vector
func (Vector) DistanceSquared ¶
func (Vector) IsDegenerate ¶
func (Vector) LengthSquared ¶
func (Vector) MaxComponent ¶
func (Vector) MinComponent ¶
func (Vector) Perpendicular ¶
func (Vector) RoundPlaces ¶
type VectorW ¶
type VectorW struct {
X, Y, Z, W float64
}
func Barycentric ¶
func InterpolateVectorWs ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.