shape

package
v0.0.0-...-19fadcf Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 19 Imported by: 0

README

plane := shape.Plane{}

a, b := f32.Point(0, 100)}, f32.Point{0, 100}

line := shape.Line{a, b}

plane.Add(line)

text := shape.Text{}

plane.Add(text)

// 
plane.View(f32.Rect(0, 0, 400, 600), gtx)

Zoom in out


Pan though plane

offset := f32.Point{20, 30}
viewport.Add(offset)

Select Shape

Draw Polyline

Research

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arrow

type Arrow struct {
	FillColor   *color.RGBA
	StrokeColor *color.RGBA
	StrokeWidth color.RGBA
}

func (Arrow) Bounds

func (a Arrow) Bounds() f32.Rectangle

func (Arrow) Draw

func (a Arrow) Draw(gtx C)

func (Arrow) Hit

func (a Arrow) Hit(p f32.Point) bool

Hit test

func (Arrow) Offset

func (a Arrow) Offset(p f32.Point) Shape

type C

type C = layout.Context

type Circle

type Circle struct {
	Center      f32.Point
	Radius      float32
	FillColor   *color.NRGBA
	StrokeColor *color.NRGBA
	StrokeWidth float32
}

func (Circle) Bounds

func (c Circle) Bounds() f32.Rectangle

func (Circle) Draw

func (c Circle) Draw(gtx C)

func (Circle) Fill

func (cc Circle) Fill(col color.NRGBA, gtx layout.Context) f32.Rectangle

func (Circle) Hit

func (c Circle) Hit(p f32.Point) bool

Hit test

func (Circle) Move

func (c Circle) Move(delta f32.Point)

func (Circle) Offset

func (c Circle) Offset(p f32.Point) Shape

func (Circle) Stroke

func (cc Circle) Stroke(col color.NRGBA, width float32, gtx layout.Context) f32.Rectangle

type D

type D = layout.Dimensions

type Group

type Group struct {
	ID       string
	Elements []Shape
}

func (*Group) Append

func (g *Group) Append(s Shape)

func (Group) Bounds

func (g Group) Bounds() f32.Rectangle

func (Group) Draw

func (g Group) Draw(gtx C)

func (*Group) Eq

func (g *Group) Eq(s2 Shape) bool

func (Group) Hit

func (g Group) Hit(p f32.Point) bool

Hit test

func (*Group) Identity

func (g *Group) Identity() string

func (*Group) Move

func (g *Group) Move(delta f32.Point)

func (*Group) Offset

func (g *Group) Offset(p f32.Point) Shape

type Image

type Image struct {
	ID    string
	X, Y  float32
	Image *paint.ImageOp
}

func NewImage

func NewImage(x, y float32, img *paint.ImageOp) *Image

func (Image) Bounds

func (i Image) Bounds() f32.Rectangle

func (Image) Draw

func (i Image) Draw(gtx C)

func (*Image) Eq

func (i *Image) Eq(s Shape) bool

func (Image) Hit

func (i Image) Hit(p f32.Point) bool

Hit test

func (Image) Identity

func (i Image) Identity() string

func (*Image) Move

func (i *Image) Move(delta f32.Point)

func (Image) Offset

func (i Image) Offset(p f32.Point) Shape

type Label

type Label struct{}

func (Label) Bounds

func (l Label) Bounds() f32.Rectangle

func (Label) Draw

func (l Label) Draw(gtx C)

func (Label) Hit

func (l Label) Hit(p f32.Point) bool

Hit test

func (Label) Offset

func (l Label) Offset(p f32.Point) Shape

type Line

type Line struct {
	ID     string
	Points Path
	Color  color.NRGBA
	Width  float32
	// contains filtered or unexported fields
}

func NewPolyline

func NewPolyline(points []f32.Point, col color.NRGBA, width float32) *Line

func (*Line) Bounds

func (l *Line) Bounds() f32.Rectangle

func (Line) Draw

func (l Line) Draw(gtx C)

func (*Line) Eq

func (l *Line) Eq(s2 Shape) bool

func (*Line) Hit

func (l *Line) Hit(p f32.Point) bool

func (*Line) Identity

func (l *Line) Identity() string

func (*Line) Move

func (l *Line) Move(delta f32.Point)

func (*Line) Offset

func (l *Line) Offset(p f32.Point) Shape

type Path

type Path []f32.Point

type Plane

type Plane struct {
	Elements *orderedmap.OrderedMap
	Index    *rtree.RTree
	Offset   f32.Point
	Scale    float32
	Width    float32
	Height   float32
}

A two-dimensional surface that extends infinitely far

func NewPlane

func NewPlane() *Plane

func (Plane) Center

func (p Plane) Center() f32.Point

func (Plane) GetTransform

func (p Plane) GetTransform() f32.Affine2D

func (Plane) GetTransform2

func (p Plane) GetTransform2() f32.Affine2D

func (Plane) Hits

func (p Plane) Hits(pos f32.Point) Shape

func (*Plane) Insert

func (p *Plane) Insert(s Shape)

func (*Plane) InsertAll

func (p *Plane) InsertAll(ss []Shape)

func (Plane) Intersects

func (p Plane) Intersects(r f32.Rectangle) []Shape

func (Plane) RelativePoint

func (p Plane) RelativePoint(point f32.Point, gtx C) f32.Point

func (*Plane) Remove

func (p *Plane) Remove(s Shape)

func (*Plane) RemoveAll

func (p *Plane) RemoveAll(ss []Shape)

func (*Plane) Update

func (p *Plane) Update(s Shape)

func (*Plane) UpdateAll

func (p *Plane) UpdateAll(ss []Shape)

func (*Plane) View

func (p *Plane) View(gtx C)

func (Plane) Within

func (p Plane) Within(r f32.Rectangle) Group

type Rectangle

type Rectangle struct {
	f32.Rectangle
	FillColor   *color.NRGBA
	StrokeColor *color.NRGBA
	StrokeWidth float32
}

func (Rectangle) Bounds

func (r Rectangle) Bounds() f32.Rectangle

func (Rectangle) Draw

func (r Rectangle) Draw(gtx layout.Context)

func (Rectangle) Hit

func (r Rectangle) Hit(p f32.Point) bool

func (Rectangle) Offset

func (r Rectangle) Offset(p f32.Point) Shape

type RegularPolygon

type RegularPolygon struct{}

type Shape

type Shape interface {
	// Axis aligned bounding box
	Bounds() f32.Rectangle

	// Hit test
	Hit(p f32.Point) bool

	//
	Offset(p f32.Point) Shape

	//
	Draw(gtx C)

	Eq(s2 Shape) bool

	Identity() string

	Move(p f32.Point)
}

type StarPolygon

type StarPolygon struct{}

type Text

type Text struct {
	ID          string
	X, Y        float32
	Text        string
	StrokeColor color.NRGBA
	FontWidth   float32
	// contains filtered or unexported fields
}

func NewText

func NewText(x, y float32, txt string, col color.NRGBA, width float32, sh text.Shaper) *Text

func (*Text) Bounds

func (t *Text) Bounds() f32.Rectangle

func (Text) Draw

func (t Text) Draw(gtx C)

func (*Text) Eq

func (t *Text) Eq(s Shape) bool

func (Text) Hit

func (t Text) Hit(p f32.Point) bool

Hit test

func (*Text) Identity

func (t *Text) Identity() string

func (*Text) Move

func (t *Text) Move(delta f32.Point)

func (Text) Offset

func (t Text) Offset(p f32.Point) Shape

type Triangle

type Triangle struct {
}

func (Triangle) Bounds

func (t Triangle) Bounds() f32.Rectangle

func (Triangle) Draw

func (t Triangle) Draw(gtx C)

func (Triangle) Hit

func (t Triangle) Hit(p f32.Point) bool

Hit test

func (Triangle) Offset

func (t Triangle) Offset(p f32.Point) Shape

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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