Documentation
¶
Index ¶
- func AddWidth(img *image.RGBA, dist int, c color.RGBA) *image.RGBA
- func Blur(img *image.RGBA, size int, kernal []float64) *image.RGBA
- func Clamp(f, min, max float64) float64
- func Clamp01(f float64) float64
- func ConsolePrompt(text string) string
- func Convolution(img *image.RGBA, x, y, size int) []color.RGBA
- func DistanceTolerance(a, b f64.Vec2, epsilon float64) bool
- func DrawRect(w, h, t, edge int, c color.RGBA) *image.RGBA
- func EqualFloat(a, b, tolerance float64) bool
- func G(x, y, sigma float64) float64
- func InvertMatrix(m []float64) ([]float64, bool)
- func Kernal(size int, sigma float64) []float64
- func Lerp(f1, f2, t float64) float64
- func LerpConst(f1, f2, d float64) float64
- func LoadPNG(name string) *image.RGBA
- func MatrixMultiplication(a, b []float64) []float64
- func MatrixVectorMultiplication(a, b []float64) []float64
- func Neon(img *image.RGBA, light, blur int, sigma float64, c color.RGBA, ...) *image.RGBA
- func Paint(img *image.RGBA, x, y, radius int, c color.RGBA)
- func PosToUint(p uint) uint
- func SegmentsIntersect(x1, y1, x2, y2, x3, y3, x4, y4 float64) (float64, float64, error)
- func SimpleAlphaComposite(s, b color.RGBA) color.RGBA
- func Tolerance(a, b, epsilon float64) bool
- func WritePNG(path string, img image.Image) error
- type Bits
- type Camera
- func (c *Camera) GeoM() ebiten.GeoM
- func (c *Camera) GetPosition() (float64, float64)
- func (c *Camera) IsPointInViewport(wx, wy float64) bool
- func (c *Camera) Matrix() ebiten.GeoM
- func (c *Camera) Pan(x, y float64)
- func (c *Camera) Render(screen, world *ebiten.Image)
- func (c *Camera) Reset()
- func (c *Camera) Rotate(a float64)
- func (c *Camera) Scale() float64
- func (c *Camera) ScreenToWorld(posX, posY int) (float64, float64)
- func (c *Camera) SetPosition(x, y float64)
- func (c *Camera) SetViewPort(w, h int)
- func (c *Camera) SpriteGeoMConcat(sprite ebiten.GeoM) ebiten.GeoM
- func (c *Camera) String() string
- func (c *Camera) Update()
- func (c *Camera) WorldToScreen(wx, wy float64) (float64, float64)
- func (c *Camera) WorldToScreen32(wx, wy float64) (float32, float32)
- func (c *Camera) ZoomIn(n int)
- func (c *Camera) ZoomOut(n int)
- type Camera3D
- func (cam *Camera3D) FOV(delta float64)
- func (cam *Camera3D) LineToScreen(a Vector3, b Vector3) ([]float32, bool)
- func (cam *Camera3D) Move(dir Vector3)
- func (cam *Camera3D) Pitch(rad float64)
- func (cam *Camera3D) PosToScreen(p Vector3) []float32
- func (cam *Camera3D) PrintCombineMatrix() string
- func (cam *Camera3D) PrintMatrix(m []float64) string
- func (cam *Camera3D) PrintProjectionMatrix() string
- func (cam *Camera3D) PrintVector(m []float64) string
- func (cam *Camera3D) PrintViewMatrix() string
- func (cam *Camera3D) PrintViewportMatrix() string
- func (cam *Camera3D) Update()
- func (cam *Camera3D) UpdateCamera3D(pos, lookAt Vector3, fov, w, h float64)
- func (cam *Camera3D) WorldToScreen(p []float64) []float64
- func (cam *Camera3D) Yaw(rad float64)
- type EmbedFS
- type FS
- func (f *FS) GetFontFace(path string, size, dpi float64) (font.Face, error)
- func (f *FS) GetGoTextFaceSource(path string) *text.GoTextFaceSource
- func (f *FS) GetImage(path string) (*ebiten.Image, error)
- func (f *FS) GetRGBA(path string) (*image.RGBA, error)
- func (f *FS) MustGetFontFace(path string, size, dpi float64) font.Face
- func (f *FS) MustGetImage(path string) *ebiten.Image
- func (f *FS) MustReadCSV(path string) [][]string
- func (f *FS) MustReadFile(path string) []byte
- func (f *FS) Open(path string) (fs.File, error)
- func (f *FS) ReadCSV(path string) ([][]string, error)
- func (f *FS) ReadDir(path string) ([]fs.DirEntry, error)
- func (f *FS) ReadFile(path string) ([]byte, error)
- type ID
- type Scene
- type SceneManager
- type Vector
- func (v Vector) Add(other Vector) Vector
- func (v Vector) CheckAxis(v1, p, n Vector) bool
- func (v Vector) Clamp(length float64) Vector
- func (v Vector) Clone() Vector
- func (v Vector) ClosestDist(v1 Vector) float64
- func (v Vector) ClosestPointOnSegment(a, b Vector) Vector
- func (v Vector) ClosestT(b Vector) float64
- func (v Vector) Cross(other Vector) float64
- func (v Vector) Distance(other Vector) float64
- func (v Vector) DistanceSq(other Vector) float64
- func (v Vector) Dot(other Vector) float64
- func (v Vector) Equal(other Vector) bool
- func (v Vector) Length() float64
- func (v Vector) LengthSq() float64
- func (v Vector) Lerp(other Vector, t float64) Vector
- func (v Vector) LerpConst(other Vector, d float64) Vector
- func (v Vector) LerpT(b Vector, t float64) Vector
- func (v Vector) Mult(s float64) Vector
- func (v Vector) Near(other Vector, d float64) bool
- func (v Vector) Neg() Vector
- func (v Vector) Normalize() Vector
- func (v Vector) Perp() Vector
- func (v Vector) PointGreater(b, c Vector) bool
- func (v Vector) Project(other Vector) Vector
- func (v Vector) ReversePerp() Vector
- func (v Vector) Rotate(other Vector) Vector
- func (v Vector) SLerp(other Vector, t float64) Vector
- func (v Vector) SlerpConst(other Vector, a float64) Vector
- func (v Vector) String() string
- func (v Vector) Sub(other Vector) Vector
- func (v Vector) ToAngle() float64
- func (v Vector) Unrotate(other Vector) Vector
- type Vector3
- func (a Vector3) Add(b Vector3) Vector3
- func (a Vector3) Angle(b Vector3) float64
- func (a Vector3) Cross(b Vector3) Vector3
- func (a Vector3) DistanceSq(b Vector3) float64
- func (a Vector3) Dot(b Vector3) float64
- func (v Vector3) Length() float64
- func (v Vector3) LengthSq() float64
- func (a Vector3) Lerp(b Vector3, t float64) Vector3
- func (a Vector3) Mult(t float64) Vector3
- func (v Vector3) Negate() Vector3
- func (v Vector3) Normalize() Vector3
- func (a Vector3) Slerp(b Vector3, t float64) Vector3
- func (a Vector3) Sub(b Vector3) Vector3
- func (a Vector3) ToSlice() []float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddWidth ¶
AddWidth light effect to any pixel with 255 in alpha channle within `dist` from the pixels
func Blur ¶
Return a new image applying Gaussian Blur Note, for my purpose, the reutrn image size is larger by the size of the kernal, to capture the entire bluring effect
func ConsolePrompt ¶
ConsolePrompt takes a text prompt, wait for and return user input
func Convolution ¶
Return the RGBA values of kernal with `size` x `size` in a list
func DistanceTolerance ¶
DistanceTolerance check if two 2D positions are close enough
func EqualFloat ¶
func InvertMatrix ¶
InvertMatrix computes the inverse of a 4x4 matrix.
func MatrixMultiplication ¶
func Neon ¶
func Neon(img *image.RGBA, light, blur int, sigma float64, c color.RGBA, origin, resize bool) *image.RGBA
Neon add neon light effect of an image, Neon adds color `c` within `light` pixels away from any pixels with 255 for alpha channel. Gaussian blur is applied with sqaure of width `blur`, and `sigma` as Gaussian standard deviation If `origin`, original image is draw on top of new image If `resize`, new image will be larger due to Gaussian effect on the edge
func SegmentsIntersect ¶
SegmentsIntersect find intersection point between line pt1 to pt2 and pt3 and pt4 return error if no intersection
func SimpleAlphaComposite ¶
Simple Alpha Composite source with background pixel https://www.w3.org/TR/compositing-1/#simplealphacompositing
Types ¶
type Camera ¶
type Camera struct {
ViewPort f64.Vec2 // viewport should be the same as the window size/resolution
Position f64.Vec2 // points camera to `Position` in the world
ZoomFactor int
Rotation float64
// contains filtered or unexported fields
}
Camera projects world to Screen
func (*Camera) GetPosition ¶
GetPosition return x, y
func (*Camera) IsPointInViewport ¶
IsPointInViewport check is a point in on screen
func (*Camera) SetPosition ¶
SetPosition moves camera to location x, y
func (*Camera) SetViewPort ¶
SetViewPort set the size of the window
func (*Camera) SpriteGeoMConcat ¶
DEPRECATED, Concat camera's matrix with m
func (*Camera) WorldToScreen32 ¶
WorldToScreen32 return x, y in float32, ebiten screen drawing use float32
type Camera3D ¶
type Camera3D struct {
// contains filtered or unexported fields
}
func NewCamera3D ¶
func (*Camera3D) LineToScreen ¶
give screen coordinates of 2 points {x1 y1 z1 w1 x2 y2 z2 w2}, i.e. point1 [0] v[1], and point2 v[4] v[5] if one point is behind the Camera3D, it will return move that point to where the line intersect with the clip plan if both points are behind, it will return both points as { 0, 0, 0, -1} return boolean indicates if the line is in front of the Camera3D
func (*Camera3D) PosToScreen ¶
convert world position to screen coordinate
func (*Camera3D) PrintCombineMatrix ¶
func (*Camera3D) PrintMatrix ¶
print a 4 x 4 matrix
func (*Camera3D) PrintProjectionMatrix ¶
func (*Camera3D) PrintVector ¶
print a 4 x 1 vector
func (*Camera3D) PrintViewMatrix ¶
func (*Camera3D) PrintViewportMatrix ¶
func (*Camera3D) UpdateCamera3D ¶
func (*Camera3D) WorldToScreen ¶
convert world position to screen coordinate
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
func (*FS) GetFontFace ¶
func (*FS) GetGoTextFaceSource ¶
func (f *FS) GetGoTextFaceSource(path string) *text.GoTextFaceSource
func (*FS) MustReadCSV ¶
func (*FS) MustReadFile ¶
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
func NewIDGenerator ¶
func NewIDGenerator() *ID
func (*ID) SetCurrent ¶
Up to the caller to ensure id is still unique
type SceneManager ¶
type SceneManager struct {
// contains filtered or unexported fields
}
func NewSceneManager ¶
func NewSceneManager(w, h, transitionFrames int) *SceneManager
Create new scene manager, where w - screen width, h - screen height, transitionFrames - number of frames to transit between scenes
func (*SceneManager) Draw ¶
func (s *SceneManager) Draw(r *ebiten.Image)
func (*SceneManager) GoTo ¶
func (s *SceneManager) GoTo(scene Scene)
func (*SceneManager) Update ¶
func (s *SceneManager) Update() error
type Vector ¶
type Vector struct {
X, Y float64
}
func (Vector) ClosestDist ¶
func (Vector) ClosestPointOnSegment ¶
func (Vector) Cross ¶
Cross calculates the 2D vector cross product analog. The cross product of 2D vectors results in a 3D vector with only a z component. This function returns the magnitude of the z value.
func (Vector) DistanceSq ¶
func (Vector) PointGreater ¶
func (Vector) ReversePerp ¶
type Vector3 ¶
type Vector3 struct {
X, Y, Z float64
}
Result image: