grsys

package
v0.0.0-...-f8018e0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Implementation of Cohen-Sutherland line clipping.

Color primitives.

Line-drawing primitives.

Polygon fill function, using integers only.

GIF composition and encoding.

Initialization and output primitives.

Triangulation of polygons. Triangulation of a polygon with successive vertex numbers pol[0], ..., pol[n-1], in counter-clockwise order. With three given vertex numbers P, Q, R, function orienta must determine their orientation.

Negative = clockwise
Zero     = collinear
Positive = counter-clockwise

If triangulation is possible, the resulting triangles are successively stored in array 'nrs'. Triangle j has vertex numbers nrs[j].A, nrs[j].B, nrs[j].C. Memory space for slice 'nrs' must be supplied by the caller. Return value: the number of triangles found, or -1 if no proper polygon, or vertices are clockwise

Conversion from world coordinates to viewport coordinates.

Index

Constants

This section is empty.

Variables

View Source
var (
	NColors     int
	ForeGrColor int = 14
	BackGrColor int = 0
)
View Source
var (
	ImageWidth  int = 800 // X__max
	ImageHeight int = 600 // Y__max

)
View Source
var (
	XMin    float64 = 0
	XMax    float64 = 10
	YMin    float64 = 0
	YMax    float64
	XCenter float64
	YCenter float64
	RMax    float64
	Density float64
)

Functions

func AppendPlot

func AppendPlot(x, y float64, code int)

func ClipDraw

func ClipDraw(xP, yP, xQ, yQ float64)

func Draw

func Draw(x, y float64)

func DrawLine

func DrawLine(xP, yP, xQ, yQ int)

func EndGr

func EndGr()

func Error

func Error(err error)

func Fill

func Fill(X []int, Y []int)

func Frame

func Frame(delay int)

func GenPlot

func GenPlot()

func GetMaxColor

func GetMaxColor() int

func HorLine

func HorLine(xLeft, xRight, y int)

func IX

func IX(x float64) int

func IY

func IY(y float64) int

func InitGr

func InitGr(filename string)

func InitWindow

func InitWindow()

func Move

func Move(x, y float64)

func PutPix

func PutPix(x, y int)

func SetBackgroundColor

func SetBackgroundColor(c int)

func SetClipBoundaries

func SetClipBoundaries(x1, x2, y1, y2 float64)

func SetColor

func SetColor(c int)

func SetRGBPalette

func SetRGBPalette(index, r, g, b int)

func ShadedColors

func ShadedColors()

func Triangul

func Triangul(pol []int, n int, nrs []Trianrs,
	orienta func(int, int, int) int) int

func UpdateWindowBoundaries

func UpdateWindowBoundaries(x, y float64)

func ViewportBoundaries

func ViewportBoundaries(Xmin, Xmax, Ymin, Ymax, reductionFactor float64)

func XViewport

func XViewport(x float64) float64

func YViewport

func YViewport(y float64) float64

Types

type Trianrs

type Trianrs struct {
	A, B, C int
}

type Vec

type Vec struct {
	X, Y float64
}

func Rotate

func Rotate(p, c Vec, cosphi, sinphi float64) Vec

func (Vec) Add

func (v Vec) Add(u Vec) Vec

func (Vec) Draw

func (v Vec) Draw()

func (Vec) Move

func (v Vec) Move()

func (Vec) Mul

func (v Vec) Mul(c float64) Vec

func (Vec) Sub

func (v Vec) Sub(u Vec) Vec

Jump to

Keyboard shortcuts

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