coordin

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 3 Imported by: 0

README

Coordin

Coordin is a Golang library that helps you draw shapes in the terminal.
This library provide coordinates points for shapes such as circles and lines and so on.

Installation

go get github.com/yoshihicode/coordin

Examples

see examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Circle

func Circle(cx, cy, rx, ry int) (Points, Points)

Circle returns the coordinates of a circle. The First two parameters set the location, and the third and fourth parameters set radius of the x-axis and y-axis. Circle uses trigonometric functions to calculate coordinates. The First return value is perimeter points and the secound return value is fill points.

func Circle2

func Circle2(cx, cy, rx, ry int) (Points, Points)

Circle2 returns the coordinates of a circle. The First two parameters set the location, and the third and fourth parameters set radius of the x-axis and y-axis. Circle2 calculates the distance from the center point to the circumference without using trigonometric. The First return value is perimeter points and the secound return value is fill points.

func Polygon

func Polygon(ps Points) (Points, Points)

Polygon returns the coordinates connecting the given points and the line connecting the last point and the first point. The First return value is perimeter points, and the second is fill points.

func Rect

func Rect(p1 Point, p2 Point) (Points, Points)

Rect returns the coordinates of a rectangle. First return value is perimeter points, secound return value is fill points.

Types

type Point

type Point struct {
	// X coordinate
	X int
	// Y coordinate
	Y int
}

Point is a structure of XY coordinates. {X:0, Y:0} indicates the top left edge.

type Points

type Points []Point

Points is array of Point.

func Arc

func Arc(cx, cy, rx, ry, sd, ed int) Points

Arc returns the coordinates of a arc. The First two parameters set the location, and the third and fourth parameters set radius of the x-axis and y-axis and the fifth and sixth parameters set the start and end degree.

func BCurve

func BCurve(ps Points, t float64) Points

BCurve returns the coordinates of Bézier curve. The first and last indices of the first parameter(Points) are endpoints, and the others are control points. The second parameter(float64) is curvature.

func Circled

func Circled(cx, cy, rx, ry, s int) Points

Circled returns the coordinates of the dashed circle. The First two parameters set the location, and the third and fourth parameters set radius of the x-axis and y-axis and the fifth parameter set interval of the dash spacing. The calculation method is same as `Circle`.

func Line

func Line(p1 Point, p2 Point) Points

Line returns the coordinates of a line between two points.

func Polyline

func Polyline(ps Points) Points

Polyline returns coordinates connecting the given points with a line. There is no line connecting the last point and the first point.

Directories

Path Synopsis
examples
bcurve command
circle command
line command
poly command

Jump to

Keyboard shortcuts

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