bezier

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: BSD-3-Clause Imports: 2 Imported by: 1

README

Bézier interpolation

This module calculates a set of Bézier splines that represent a continuous curve through a set of points. Both integer and floating point versions are provided. I use this to create curves in SVG files.

The algorithm was ported from the Javascript on this page. The page describing what the code does is here. This page also provides a little interactive demo.

If you pass in N + 1 knots (points to be interpolated), you will get N sets of control points back, one set for each part of the curve. Each set has four control points. The first control point (P0) is the starting knot, and the last control point (P3) is the ending knot. P1 and P2 are determined by the module. A sample image is shown below, with the knots in blue and the computed control points in green.

sample SVG

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ControlPointsToSvgI

func ControlPointsToSvgI(beziers []Bezier) []string

func SvgControlPointsI

func SvgControlPointsI(p []image.Point) []string

Types

type Bezier

type Bezier struct {
	P0, P1, P2, P3 image.Point
}

func GetControlPointsI

func GetControlPointsI(p []image.Point) []Bezier

type BezierF

type BezierF struct {
	P0, P1, P2, P3 PointF
}

type PointF

type PointF struct {
	X, Y float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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