Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Black = &Color{
red: 0,
green: 0,
blue: 0,
}
var White = &Color{
red: 1,
green: 1,
blue: 1,
}
Functions ¶
This section is empty.
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Canvas represents a grid of pixels for displaying an image.
func (*Canvas) WritePixel ¶
WritePixel sets a Canvas's pixel to a color.
func (*Canvas) WriteToFile ¶
WriteToFile writes the canvas ppm to a file.
type CheckerPattern ¶
type CheckerPattern struct {
*PatternObject
}
CheckerPattern represents a 3D checker pattern.
func NewCheckerPattern ¶
func NewCheckerPattern(color1, color2 *Color) *CheckerPattern
NewCheckerPattern returns a new CheckerPattern object.
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
Color is a tuple representing an rgb value.
func (*Color) MultiplyColor ¶
MultiplyColor multiplies two colors by each other and returns the result.
type GradientPattern ¶
type GradientPattern struct {
*PatternObject
}
GradientPattern represents a gradient color pattern.
func NewGradientPattern ¶
func NewGradientPattern(color1, color2 *Color) *GradientPattern
NewGradientPattern returns a new GradientPattern object.
type MockPattern ¶
type MockPattern struct {
*PatternObject
}
MockPattern is a mock pattern object for unit testing.
func NewMockPattern ¶
func NewMockPattern() *MockPattern
NewMockPattern returns a new MockPattern object.
type Pattern ¶
type Pattern interface { GetColors() []*Color GetTransform() *base.Matrix SetTransform(...*base.Matrix) PatternAt(*base.Tuple) *Color }
Pattern represents a color pattern.
type PatternObject ¶
type PatternObject struct {
// contains filtered or unexported fields
}
PatternObject is the base implementation of the pattern interface.
func NewPattern ¶
func NewPattern( color1, color2 *Color, patternFunc func(*base.Tuple, *PatternObject) *Color, ) *PatternObject
NewPattern returns a new pattern object.
func (*PatternObject) GetColors ¶
func (p *PatternObject) GetColors() []*Color
GetColors returns a list of colors for the pattern.
func (*PatternObject) GetTransform ¶
func (p *PatternObject) GetTransform() *base.Matrix
GetTransform returns the pattern's transform matrix.
func (*PatternObject) PatternAt ¶
func (p *PatternObject) PatternAt(point *base.Tuple) *Color
PatternAt returns the color at a specific point, based on the pattern.
func (*PatternObject) SetTransform ¶
func (p *PatternObject) SetTransform(matrix ...*base.Matrix)
SetTransform sets the pattern's transform matrix.
type RingPattern ¶
type RingPattern struct {
*PatternObject
}
RingPattern represents a ring color pattern.
func NewRingPattern ¶
func NewRingPattern(color1, color2 *Color) *RingPattern
NewRingPattern returns a new RingPattern object.
type StripePattern ¶
type StripePattern struct {
*PatternObject
}
StripePattern represents a striped color pattern.
func NewStripePattern ¶
func NewStripePattern(color1, color2 *Color) *StripePattern
NewStripePattern returns a new StripePattern object.