shape

package
v0.0.0-...-b80cc47 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BentTrapezoid

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

BentTrapezoid is a Trapezoid with a curve. The two parallel lines are orthogonal to the time axis and the other two lines are bent.

position    topWidth
         +-------------+          -
        /               \         |
       /                 \        | duration
      /                   \       |
     /                     \      |
    +-----------------------+     -
           bottomWidth
    |----|
    bottomOffset

func NewBentTrapezoid

func NewBentTrapezoid(topPosition vectorpath.Point, bottomPosition vectorpath.Point, topWidth float64, bottomWidth float64) *BentTrapezoid

NewBentTrapezoid returns a new BentTrapezoid

func NewEmptyBentTrapezoid

func NewEmptyBentTrapezoid() *BentTrapezoid

func (*BentTrapezoid) Bounds

func (b *BentTrapezoid) Bounds() vectorpath.Rect

Bounds returns the outer bounds of the shape

func (*BentTrapezoid) Copy

func (b *BentTrapezoid) Copy() Shape

func (*BentTrapezoid) Duration

func (b *BentTrapezoid) Duration() float64

Duration returns the duration that the shape takes up

func (*BentTrapezoid) Handles

func (b *BentTrapezoid) Handles() []vectorpath.Point

Handles returns the position of all handles

func (*BentTrapezoid) MarshalJSON

func (b *BentTrapezoid) MarshalJSON() ([]byte, error)

func (*BentTrapezoid) MirrorP

func (b *BentTrapezoid) MirrorP()

func (*BentTrapezoid) Move

func (b *BentTrapezoid) Move(offset vectorpath.Point)

Move the shape by some amount

func (*BentTrapezoid) Origin

func (b *BentTrapezoid) Origin() vectorpath.Point

Origin returns the top left point of the trapezoid

func (*BentTrapezoid) Path

func (b *BentTrapezoid) Path() vectorpath.Path

Path returns a path that describes the bent trapezoid

func (*BentTrapezoid) SetCreationBounds

func (b *BentTrapezoid) SetCreationBounds(origin vectorpath.Point, size vectorpath.Point)

func (*BentTrapezoid) SetHandle

func (b *BentTrapezoid) SetHandle(index int, absolutePoint vectorpath.Point)

SetHandle sets the handle 'index' to the new point

func (*BentTrapezoid) SetOrigin

func (b *BentTrapezoid) SetOrigin(point vectorpath.Point)

SetOrigin sets the position of the top left point

func (*BentTrapezoid) Time

func (b *BentTrapezoid) Time() float64

Time returns the point in time where the shape start

func (*BentTrapezoid) UnmarshalJSON

func (b *BentTrapezoid) UnmarshalJSON(raw []byte) error

func (*BentTrapezoid) Width

func (b *BentTrapezoid) Width() float64

Width returns the visual width of the shape

type OrthogonalRectangle

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

OrthogonalRectangle is a rectangle shape whose edges are orthogonal to the coordinate system

func NewEmptyOrthogonalRectangle

func NewEmptyOrthogonalRectangle() *OrthogonalRectangle

func NewOrthogonalRectangle

func NewOrthogonalRectangle(pos vectorpath.Point, width float64, height float64) *OrthogonalRectangle

NewOrthogonalRectangle creates a new shape with the top left position and width and height

func (*OrthogonalRectangle) Bounds

func (or *OrthogonalRectangle) Bounds() vectorpath.Rect

Bounds returns the underlying rectangle

func (*OrthogonalRectangle) Copy

func (or *OrthogonalRectangle) Copy() Shape

func (*OrthogonalRectangle) Duration

func (or *OrthogonalRectangle) Duration() float64

Duration returns the duration of the shape in seconds

func (*OrthogonalRectangle) Handles

func (or *OrthogonalRectangle) Handles() []vectorpath.Point

Handles returns all handles for this shape that the user can then use to manipulate the shape

func (*OrthogonalRectangle) MarshalJSON

func (or *OrthogonalRectangle) MarshalJSON() ([]byte, error)

func (*OrthogonalRectangle) MirrorP

func (or *OrthogonalRectangle) MirrorP()

func (*OrthogonalRectangle) Move

func (or *OrthogonalRectangle) Move(by vectorpath.Point)

Move the rectangle by some amount

func (*OrthogonalRectangle) Origin

func (or *OrthogonalRectangle) Origin() vectorpath.Point

Origin returns the top left point of the rectangle

func (*OrthogonalRectangle) Path

func (or *OrthogonalRectangle) Path() vectorpath.Path

Path returns the path of the shape that should be rendered

func (*OrthogonalRectangle) SetCreationBounds

func (or *OrthogonalRectangle) SetCreationBounds(origin vectorpath.Point, size vectorpath.Point)

func (*OrthogonalRectangle) SetHandle

func (or *OrthogonalRectangle) SetHandle(i int, absolutePoint vectorpath.Point)

SetHandle receives the index of the handle that should be changed and the new point value

func (*OrthogonalRectangle) SetOrigin

func (or *OrthogonalRectangle) SetOrigin(l vectorpath.Point)

SetOrigin sets the top left point of the rectangle to a new point

func (*OrthogonalRectangle) Time

func (or *OrthogonalRectangle) Time() float64

Time returns the temporal position of the rectangle in seconds

func (*OrthogonalRectangle) UnmarshalJSON

func (or *OrthogonalRectangle) UnmarshalJSON(raw []byte) error

func (*OrthogonalRectangle) Width

func (or *OrthogonalRectangle) Width() float64

Width returns the width of the shape

type Shape

type Shape interface {
	json.Marshaler

	Time() float64              // point in time when the shape start
	Duration() float64          // duration of time that the shape takes up
	Width() float64             // visual width of the shape
	Bounds() vectorpath.Rect    // outer rectangular bounds of the shape
	Move(vectorpath.Point)      // move the shape by some amount
	Origin() vectorpath.Point   // get the point where the path of the shape starts (does not have to be the same as Bounds().Location)
	SetOrigin(vectorpath.Point) // set the origin of the shape

	Path() vectorpath.Path
	Handles() []vectorpath.Point                          // returns all points where the user can manipulate the shape
	SetHandle(int, vectorpath.Point)                      // set new position of a handle
	SetCreationBounds(vectorpath.Point, vectorpath.Point) // sets the size of the shape in an intuitive way for the user
	MirrorP()                                             // mirrors the shape on the P axis

	Copy() Shape // creates a deep copy of the shape
}

Shape is the visual part of an element on the scene

func Unmarshal

func Unmarshal(raw []byte) (Shape, error)

Jump to

Keyboard shortcuts

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