pigowa

package module
v0.0.0-...-af601db Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

README

pigowa

pigowa is a Go interface for using p5.js in the browser, exploiting the power of WebAssembly.

The implementation is ongoing, and things may change. The syscall/js package is itself considered experimental.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HALF_PI    float64
	PI         float64
	QUARTER_PI float64
	TAU        float64
	TWO_PI     float64
	DEGREES    js.Value
	RADIANS    js.Value

	CHORD js.Value
	OPEN  js.Value
	PIE   js.Value
)
View Source
var (
	// Width of the drawing canvas. Defaults to 100. Updates upon use.
	Width = 100

	// Height of the drawing canvas. Defaults to 100. Updates upon use.
	Height = 100
)

Functions

func Arc

func Arc(x, y, width, height, start, stop float64, mode ...js.Value) error

Arc draws an arc on the canvas.

If called with only x, y, width, height, start and stop, the arc will be drawn and filled as an open pie segment. If a mode parameter is provided, the arc will be filled like an open semi-circle (OPEN), a closed semi-circle (CHORD), or as a closed pie segment (PIE).

func BackgroundGray

func BackgroundGray(color int, alpha ...int)

func BackgroundHex

func BackgroundHex(code string)

func BackgroundRGBA

func BackgroundRGBA(r, g, b int, alpha ...int)

func Clear

func Clear()

func CreateCanvas

func CreateCanvas(width, height int)

CreateCanvas creates a canvas element in the document, and sets the dimensions of it. The origin (0,0) is positioned at the top left of the screen.

This method should be called only once at the start of setup. Calling CreateCanvas more than once will result in very unpredictable behavior.

func Draw

func Draw(draw func() interface{})

Draw continuously executes the given function until the program is stopped. It must be called only once, after Setup.

func Ellipse

func Ellipse(x, y, width, height float64)

Ellipse draws an ellipse (oval) to the canvas.

The first two parameters set the location of the center of the ellipse, and the third and fourth parameters set the shape's width and height.

func FillGray

func FillGray(color int, alpha ...int)

func FillHex

func FillHex(code string)

func FillRGBA

func FillRGBA(r, g, b int, alpha ...int)

func MouseButton

func MouseButton() string

func MouseClicked

func MouseClicked(clicked func() interface{})

func MouseIsPressed

func MouseIsPressed() bool

func MousePressed

func MousePressed(pressed func() interface{})

func MouseReleased

func MouseReleased(released func() interface{})

func MouseWheel

func MouseWheel(wheel func(delta float64) interface{})

func MouseX

func MouseX() int

func MouseY

func MouseY() int

func NoFill

func NoFill()

func NoStroke

func NoStroke()

func Rect

func Rect(x, y, width, height float64, cornerRadius ...float64) error

Rect draws a rectangle on the canvas.

The first two parameters set the location of the upper-left corner, the third sets the width, and the fourth sets the height. The optional parameter specifies the corner radius for the top-left, top-right, lower-right and lower-left corners, respectively. An omitted corner radius parameter is set to the value of the previously specified radius value in the parameter list.

func ResizeCanvas

func ResizeCanvas(width, height int)

ResizeCanvas resizes the canvas to given width and height. The canvas will be cleared and draw will be called immediately, allowing the sketch to re-render itself in the resized canvas.

func Setup

func Setup(setup func() interface{})

Setup executes the given function. It must be called only once, usually at the start of the program.

It should be used to define initial environment properties such as screen size and background color.

func StrokeGray

func StrokeGray(color int, alpha ...int)

func StrokeHex

func StrokeHex(code string)

func StrokeRGBA

func StrokeRGBA(r, g, b int, alpha ...int)

func StrokeWeight

func StrokeWeight(weight float64)

StrokeWeight sets the width of the stroke used for lines, points and the border around shapes.

func WindowHeight

func WindowHeight() int

WindowHeight returns the height of the inner window, it maps to `window.innerHeight`.

func WindowResized

func WindowResized(resized func() interface{})

WindowResized executes the given function once every time the browser window is resized.

This is a good place to resize the canvas or do any other adjustments to accommodate the new window size.

func WindowWidth

func WindowWidth() int

WindowWidth returns the width of the inner window, it maps to `window.innerWidth`.

Types

This section is empty.

Directories

Path Synopsis
examples
A basic HTTP server.
A basic HTTP server.

Jump to

Keyboard shortcuts

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