/p5

p5 is a simple package that provides primitives resembling the ones exposed by p5js.org

Primary LanguageGoBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

p5

GitHub release go.dev reference CI GoDoc License codecov

p5 is a simple package that provides primitives resembling the ones exposed by the p5/processing library.

License

p5 is released under the BSD-3 license.

Documentation

Documentation for p5 is served by GoDev.

Contributing

Guidelines for contributing to go-p5 the same than for the Go project.

Installation

This project relies on Gio for the graphics parts. As Gio uses system libraries to display graphics, you need to install those for your system/OS for p5 to work properly. See Gio/install for details.

Example

package main

import (
	"image/color"
	"math"

	"github.com/go-p5/p5"
)

func main() {
	p5.Run(setup, draw)
}

func setup() {
	p5.Canvas(400, 400)
	p5.Background(color.Gray{Y: 220})
}

func draw() {
	p5.StrokeWidth(2)
	p5.Fill(color.RGBA{R: 255, A: 208})
	p5.Ellipse(50, 50, 80, 80)

	p5.Fill(color.RGBA{B: 255, A: 208})
	p5.Quad(50, 50, 80, 50, 80, 120, 60, 120)

	p5.Fill(color.RGBA{G: 255, A: 208})
	p5.Rect(200, 200, 50, 100)

	p5.Fill(color.RGBA{G: 255, A: 208})
	p5.Triangle(100, 100, 120, 120, 80, 120)

	p5.TextSize(24)
	p5.Text("Hello, World!", 10, 300)

	p5.Stroke(color.Black)
	p5.StrokeWidth(5)
	p5.Arc(300, 100, 80, 20, 0, 1.5*math.Pi)
}

img-hello