Skip to content

Latest commit

 

History

History
92 lines (65 loc) · 1.25 KB

README.md

File metadata and controls

92 lines (65 loc) · 1.25 KB

p5go

2D and 3D graphic development in Golang using Processing Design.

example

Requirements

Package required:

  • libgl1-mesa-dev
  • xorg-dev

Get Started

You need to initialize a struct that implements Setup and Draw methods:

type model struct {
	/*  */
}

func (m *model) Setup() *p5go.Window {
	return p5go.Canvas2D(500, 500)
}

func (m *model) Draw(window *p5go.Window) {
	/*  */
}

func init() { runtime.LockOSThread() }

func main() {
	p := p5go.NewProgram(&model{}, p5go.P2D)

	err := p.Run()
	if err != nil {
		log.Fatal(err)
	}
}

Pay attention to

func init() { runtime.LockOSThread() }

You need this to make open gl work properly.

At this point you can draw something:

func (m *model) Draw(window *p5go.Window) {
	window.Triangle(100, 100, 200, 200, 300, 300)
}

Features

Camera

  • camera()
  • rotateX()
  • rotateY()
  • rotateZ()
  • perspective()

Input

  • mouseX()
  • mouseY()

Canvas

  • background()
  • fill()

2D Primitives

  • arc()
  • circle()
  • ellipse()
  • line()
  • point()
  • quad()
  • rect()
  • square()
  • triangle()

3D Primitives

  • box()