Skip to content

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

License

Notifications You must be signed in to change notification settings

stanipetrosyan/p5go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages