plot

package module
v0.0.0-...-17e5bb8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: GPL-3.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TERMINAL_CANVAS = 1
	TERMINAL_GIF    = 2
	TERMINAL_JPEG   = 3
	TERMINAL_PNG    = 4
	TERMINAL_SVG    = 5
)

terminals to generate a plot

View Source
const (
	X_MARGINS float64 = 30
	Y_MARGINS float64 = 30
)

margins in pixels for the plot

View Source
const (
	BOXES         uint8 = 1
	DOTS          uint8 = 2
	LINES         uint8 = 3
	LINES_POINTS  uint8 = 4
	POINTS        uint8 = 5
	FUNCTION_PATH uint8 = 6
)

styles for a plot of points

View Source
const (
	MIN_X_SCALE_DIVISIONS = 10
	MAX_X_SCALE_DIVISIONS = 20
	MIN_Y_SCALE_DIVISIONS = 10
	MAX_Y_SCALE_DIVISIONS = 20

	SCALE_WIDTH        = 6
	POINT_WIDTH        = 8
	COLOUR_TITLE_WIDTH = 10
	TITLE_MARGIN       = 10
)
View Source
const (
	DEFAULT_STYLE = "points"
)

Variables

View Source
var (
	BLACK = RGB_colour{/* contains filtered or unexported fields */}
	RED   = RGB_colour{/* contains filtered or unexported fields */}
	GREEN = RGB_colour{/* contains filtered or unexported fields */}
	BLUE  = RGB_colour{/* contains filtered or unexported fields */}
)

colour pallete for plots

View Source
var (
	Style = map[string]uint8{
		"boxes":       BOXES,
		"dots":        DOTS,
		"lines":       LINES,
		"linespoints": LINES_POINTS,
		"points":      POINTS,
	}
)

style descriptions for a plot of points

Functions

This section is empty.

Types

type Canvas_Driver

type Canvas_Driver struct {
	// contains filtered or unexported fields
}

func (*Canvas_Driver) BeginPath

func (driver *Canvas_Driver) BeginPath(colour RGB_colour) error

Begin a path to draw a connection between a set of points

func (*Canvas_Driver) Close

func (driver *Canvas_Driver) Close() error

Close finalize the Canvas graphic

func (*Canvas_Driver) Comment

func (driver *Canvas_Driver) Comment(text string)

Comment write a comment int the the SVG graphic

func (*Canvas_Driver) EndPath

func (driver *Canvas_Driver) EndPath() error

End the path

func (*Canvas_Driver) GetDimensions

func (driver *Canvas_Driver) GetDimensions() (width, heigth int64)

GetDimensions get the dimensions of the SVG graphic

func (*Canvas_Driver) GetFont

func (driver *Canvas_Driver) GetFont() (fontFamily string, fontSize uint8)

GetFont get information about the font

func (*Canvas_Driver) GetTextBox

func (driver *Canvas_Driver) GetTextBox(text string) (width, height int64)

GetTextBox evaluate the width and height of the rectangle required to draw the text string using a given font size

func (*Canvas_Driver) Line

func (driver *Canvas_Driver) Line(x1, y1, x2, y2 int64, colour RGB_colour) error

Line draws a line between two points in the SVG graphic

func (*Canvas_Driver) Point

func (driver *Canvas_Driver) Point(x, y int64, colour RGB_colour) error

Point draws a point in the SVG graphic

func (*Canvas_Driver) PointToPath

func (driver *Canvas_Driver) PointToPath(x, y int64) error

Add a point to a path

func (*Canvas_Driver) SetDimensions

func (driver *Canvas_Driver) SetDimensions(width int64, height int64) error

SetDimensions set the dimensions of the Canvas graphic

func (*Canvas_Driver) SetFont

func (driver *Canvas_Driver) SetFont(fontFamily string, fontSize uint8) error

SetFont set information about the font

func (*Canvas_Driver) Text

func (driver *Canvas_Driver) Text(x, y, angle int64, text string, colour RGB_colour) error

Text writes a string to the specified point in the SVG graphic

type DriverPoint

type DriverPoint struct {
	X int64
	Y int64
}

driver point coordinate

type Function_2d

type Function_2d struct {
	Title    string
	Style    uint8
	Function string
	Min_x    float64
	Max_x    float64
	// contains filtered or unexported fields
}

2D function

type GraphicsDriver

type GraphicsDriver interface {
	GetDimensions() (width, heigth int64)
	SetDimensions(width int64, height int64) error
	GetFont() (fontFamily string, fontSize uint8)
	SetFont(fontFamily string, fontSize uint8) error

	Comment(text string)
	Point(x, y int64, colour RGB_colour) error
	BeginPath(colour RGB_colour) error
	PointToPath(x, y int64) error
	EndPath() error
	Line(x1, y1, x2, y2 int64, colour RGB_colour) error
	GetTextBox(text string) (width, height int64)
	Text(x, y, angle int64, text string, colour RGB_colour) error
	Close() error
}

func NewCanvas_Driver

func NewCanvas_Driver(writer *bufio.Writer) GraphicsDriver

NewCanvas_Driver create a new Canvas_Driver

func NewGIF_Driver

func NewGIF_Driver(writer *bufio.Writer) GraphicsDriver

create a new GIF

func NewJPEG_Driver

func NewJPEG_Driver(writer *bufio.Writer) GraphicsDriver

create a new JPEG

func NewPNG_Driver

func NewPNG_Driver(writer *bufio.Writer) GraphicsDriver

create a new PNG_Driver

func NewSVG_Driver

func NewSVG_Driver(writer *bufio.Writer) GraphicsDriver

create a new SVG_Driver

type Image_Driver

type Image_Driver struct {
	// contains filtered or unexported fields
}

func (*Image_Driver) BeginPath

func (driver *Image_Driver) BeginPath(colour RGB_colour) error

Begin a path to draw a connection between a set of points

func (*Image_Driver) Close

func (driver *Image_Driver) Close() error

Close finalize the Image graphic

func (*Image_Driver) Comment

func (driver *Image_Driver) Comment(text string)

Comment write a comment int the the Image graphic

func (*Image_Driver) EndPath

func (driver *Image_Driver) EndPath() error

End the path

func (*Image_Driver) GetDimensions

func (driver *Image_Driver) GetDimensions() (width, heigth int64)

GetDimensions get the dimensions of the Image graphic

func (*Image_Driver) GetFont

func (driver *Image_Driver) GetFont() (fontFamily string, fontSize uint8)

GetFont get information about the font

func (*Image_Driver) GetTextBox

func (driver *Image_Driver) GetTextBox(text string) (width, height int64)

GetTextBox evaluate the width and height of the rectangle required to draw the text string using a given font size

func (*Image_Driver) Line

func (driver *Image_Driver) Line(x1, y1, x2, y2 int64, colour RGB_colour) error

Line draws a line between two points in the Image graphic

func (*Image_Driver) Point

func (driver *Image_Driver) Point(x, y int64, colour RGB_colour) error

Point draws a point in the Image graphic

func (*Image_Driver) PointToPath

func (driver *Image_Driver) PointToPath(x, y int64) error

Add a point to a path

func (*Image_Driver) SetDimensions

func (driver *Image_Driver) SetDimensions(width int64, height int64) error

SetDimensions set the dimensions of the Image graphic

func (*Image_Driver) SetFont

func (driver *Image_Driver) SetFont(fontFamily string, fontSize uint8) error

SetFont set information about the font

func (*Image_Driver) Text

func (driver *Image_Driver) Text(x, y, angle int64, text string, colour RGB_colour) error

Text writes a string to the specified point in the Image graphic

type Plot

type Plot interface {
	GetOutputFileName() string
	GeneratePlot(plotWriter *bufio.Writer) error
}

func LoadPlotFile

func LoadPlotFile(reader *bufio.Reader) (Plot, error)

TODO: refactor this entire function LoadPlotFile load a plot file and return a Plot

type Plot_2D

type Plot_2D struct {
	X_label    string
	Y_label    string
	Set_points []Set_points_2d
	Function   []Function_2d
	Width      int64
	Height     int64
	Terminal   uint8
	// contains filtered or unexported fields
}

attributes used to describe a 2D plot

func (*Plot_2D) GeneratePlot

func (p *Plot_2D) GeneratePlot(plotWriter *bufio.Writer) error

GeneratePlot implementation of 2D Go_Plot generation

func (*Plot_2D) GetOutputFileName

func (p *Plot_2D) GetOutputFileName() string

GetOutputFileName return the plot's output file name

type Point_2d

type Point_2d struct {
	X float64
	Y float64
}

2D point coordinate

func LoadDataFile

func LoadDataFile(x_column uint8, y_column uint8, reader *bufio.Reader) ([]Point_2d, error)

LoadDataFile load a data file and return a Plot

type RGB_colour

type RGB_colour struct {
	// contains filtered or unexported fields
}

func (*RGB_colour) Hexa

func (c *RGB_colour) Hexa() string

Hexa return the colour as a hexadecimal value

type SVG_Driver

type SVG_Driver struct {
	// contains filtered or unexported fields
}

func (*SVG_Driver) BeginPath

func (driver *SVG_Driver) BeginPath(colour RGB_colour) error

Begin a path to draw a connection between a set of points

func (*SVG_Driver) Close

func (driver *SVG_Driver) Close() error

Close finalize the SVG graphic

func (*SVG_Driver) Comment

func (driver *SVG_Driver) Comment(text string)

Comment write a comment int the the SVG graphic

func (*SVG_Driver) EndPath

func (driver *SVG_Driver) EndPath() error

End the path

func (*SVG_Driver) GetDimensions

func (driver *SVG_Driver) GetDimensions() (width, heigth int64)

GetDimensions get the dimensions of the SVG graphic

func (*SVG_Driver) GetFont

func (driver *SVG_Driver) GetFont() (fontFamily string, fontSize uint8)

GetFont get information about the font

func (*SVG_Driver) GetTextBox

func (driver *SVG_Driver) GetTextBox(text string) (width, height int64)

GetTextBox evaluate the width and height of the rectangle required to draw the text string using a given font size

func (*SVG_Driver) Line

func (driver *SVG_Driver) Line(x1, y1, x2, y2 int64, colour RGB_colour) error

Line draws a line between two points in the SVG graphic

func (*SVG_Driver) Point

func (driver *SVG_Driver) Point(x, y int64, colour RGB_colour) error

Point draws a point in the SVG graphic

func (*SVG_Driver) PointToPath

func (driver *SVG_Driver) PointToPath(x, y int64) error

Add a point to a path

func (*SVG_Driver) SetDimensions

func (driver *SVG_Driver) SetDimensions(width int64, height int64) error

SetDimensions set the dimensions of the SVG graphic

func (*SVG_Driver) SetFont

func (driver *SVG_Driver) SetFont(fontFamily string, fontSize uint8) error

SetFont set information about the font

func (*SVG_Driver) Text

func (driver *SVG_Driver) Text(x, y, angle int64, text string, colour RGB_colour) error

Text writes a string to the specified point in the SVG graphic

type Set_points_2d

type Set_points_2d struct {
	Title string
	Style uint8
	Point []Point_2d
	// contains filtered or unexported fields
}

2D points list

Jump to

Keyboard shortcuts

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