# README
gop5js
Call p5.js from Go
To program something with p5.js is real fun, because it shows what happens. gop5js gives you the possibility to use p5.js together with go. You write your code in Go and you can see the results in your browser.
Installation
To install just use go get
go get github.com/as27/gop5js
How to use the package
- Create function of the type
func()
- Set the gop5js.Draw to the function
- Start the gop5js server:
gop5js.Serve()
Example
func main() {
gop5js.CanvasHeight = 400
gop5js.CanvasWidth = 400
gop5js.Draw = draw
gop5js.Serve()
}
func draw() {
gop5js.Background("127")
gop5js.Ellipse(20, 20, 30, 30)
gop5js.Rect(100, 100, 20, 20)
gop5js.Text("some text here", 20, 200)
}
# Packages
No description provided by the author
# Functions
Arc Draw an arc to the screen.
No description provided by the author
Bezier draws a cubic Bezier curve on the screen.
BezierDetail sets the resolution at which Beziers display.
Clear clears the pixels within a buffer.
No description provided by the author
No description provided by the author
DrawCmd takes a JavaScript command, which is added to draw().
Ellipse Draws an ellipse (oval) to the screen.
No description provided by the author
Image draws a image to the canvas.
Line Draws a line (a direct path between two points) to the screen.
LoadImage preloads the image.
No description provided by the author
No description provided by the author
Point Draws a point, a coordinate in space at the dimension of one pixel.
Quad Draw a quad.
Rect Draws a rectangle to the screen.
Serve starts the server for the communication with the browser.
No description provided by the author
Text draws the text onto the canvas.
TextSize sets the current font size.
Triangle draws a triangle.
# Variables
CanvasHeight defines the canvas which is generated inside the browser.
CanvasWidth defines the canvas which is generated inside the browser.
Draw is called every frame.
ErrorContainer collects all errors.
No description provided by the author
FilesPath is the path to a folder, which can contain additional files like for example images.
PathPrefix can be used to give all the urls a prefix.
ServerPort defines the port for the communication to the client.
SleepPerFrame makes the execution a litle slower, beccause the Go implementation is so extrem fast.