frame

package
v0.0.0-...-2b6bc3f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ASCIISF

func ASCIISF(L float64) (rune, bool)

The orginal SetFunc as described in the original implementation. Assumes L ranges from -sqrt(2) to +sqrt(2).

func Gray16Palette

func Gray16Palette() color.Palette

15 Gray16 colors plus a transparent color.

func Gray16SF

func Gray16SF(L float64) (color.Color, bool)

Assumes L ranges from -sqrt(2) to +sqrt(2).

func Render

func Render(frame Frame, t Torus, s Scene)

Renders the scene onto the frame. Assumes that the frame is sized correctly.

Types

type ASCII

type ASCII struct {
	SF SetFunc[rune]
	// contains filtered or unexported fields
}

ASCII implements the Frame interface.

func NewASCII

func NewASCII(width, height int, sf SetFunc[rune]) *ASCII

func (*ASCII) Print

func (a *ASCII) Print(w io.Writer)

func (*ASCII) Reset

func (a *ASCII) Reset()

func (*ASCII) Resize

func (a *ASCII) Resize(width int, height int)

func (*ASCII) Set

func (a *ASCII) Set(x, y int, L float64) bool

func (*ASCII) SetAll

func (a *ASCII) SetAll(r rune)

type Frame

type Frame interface {
	// Apply a luminance value to a point in the frame.
	// If the luminance value was applied, function returns true.
	Set(x, y int, L float64) bool

	// Return the frame to an initial state.
	Reset()

	Print(w io.Writer)
}

type GIF

type GIF struct {
	Image   *image.Paletted
	Options gif.Options
	SF      SetFunc[color.Color]
}

GIF implements the Frame interface.

func (*GIF) Print

func (g *GIF) Print(w io.Writer)

func (*GIF) Reset

func (g *GIF) Reset()

The reset color is the first item in the Palette.

func (*GIF) Set

func (g *GIF) Set(x, y int, L float64) bool

type Scene

type Scene struct {
	// Dimensions of the viewport.
	Width, Height int

	// Distance from camera to viewport.
	K1 float64

	// Distance from camera to torus. Essentially equal to TZ since camera is at origin.
	K2 float64

	// Light source vector. Technially should be normalized, but up to the implementation.
	LX, LY, LZ float64
}

Locations and properties of the scene.

func (*Scene) CalculateK1

func (s *Scene) CalculateK1(R1, R2 float64)

Optional. Automatically sets K1 such that the given torus stays within the screen.

type SetFunc

type SetFunc[T any] func(L float64) (T, bool)

func MonoSF

func MonoSF(c color.Color) SetFunc[color.Color]

type Torus

type Torus struct {
	// Controls the resolution of the cross-sectional circle.
	ThetaSpacing float64

	// Controls the resolution of the revolution of the circle.
	PhiSpacing float64

	// Radius of the cross-sectional circle.
	R1 float64

	// Distance from axis of revolution (Y) to the center of the cross-sectional circle.
	R2 float64

	// Rotation of the torus along the X and Z axes.
	A, B float64
}

Properties of the torus to be rendered.

func DefaultTorus

func DefaultTorus() Torus

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL