rt2

package module
v0.0.0-...-6ac44a9 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 2 Imported by: 0

README

rt2

2D raytracer.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Light

type Light struct {
	Point Vec
}

type Ray

type Ray struct {
	Origin    Vec
	Direction Vec
}

type Shape

type Shape interface {
	Hit(r Ray) bool
}

type Vec

type Vec struct {
	X, Y float64
}

func NewVec

func NewVec(x, y float64) Vec

NewVec returns a new vector <x, y>.

func (*Vec) Add

func (v *Vec) Add(a, b *Vec) *Vec

Add sets v to a+b and returns v.

func (*Vec) Dist

func (v *Vec) Dist(a *Vec) float64

Dist returns the distance between v and a.

func (*Vec) Div

func (v *Vec) Div(a *Vec, f float64) *Vec

Div sets v to a/f and returns v.

func (*Vec) Mul

func (v *Vec) Mul(a *Vec, f float64) *Vec

Mul sets v to a*f and returns v.

func (*Vec) Neg

func (v *Vec) Neg(a *Vec) *Vec

Neg sets v to -a and returns v.

func (*Vec) Sub

func (v *Vec) Sub(a, b *Vec) *Vec

Sub sets v to a-b and returns v.

type World

type World struct {
	Color  color.RGBA
	Lights []Light
	Shapes []Shape
}

func NewWorld

func NewWorld(c color.RGBA) World

func (*World) AddLight

func (w *World) AddLight(l Light)

func (*World) AddShape

func (w *World) AddShape(s Shape)

func (*World) At

func (w *World) At(v Vec) color.RGBA

Directories

Path Synopsis
cmd
rt2

Jump to

Keyboard shortcuts

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