Documentation ¶
Index ¶
- Variables
- func Arc(x, y, width, height, start, stop float64, mode ...js.Value) error
- func BackgroundGray(color int, alpha ...int)
- func BackgroundHex(code string)
- func BackgroundRGBA(r, g, b int, alpha ...int)
- func Clear()
- func CreateCanvas(width, height int)
- func Draw(draw func() interface{})
- func Ellipse(x, y, width, height float64)
- func FillGray(color int, alpha ...int)
- func FillHex(code string)
- func FillRGBA(r, g, b int, alpha ...int)
- func MouseButton() string
- func MouseClicked(clicked func() interface{})
- func MouseIsPressed() bool
- func MousePressed(pressed func() interface{})
- func MouseReleased(released func() interface{})
- func MouseWheel(wheel func(delta float64) interface{})
- func MouseX() int
- func MouseY() int
- func NoFill()
- func NoStroke()
- func Rect(x, y, width, height float64, cornerRadius ...float64) error
- func ResizeCanvas(width, height int)
- func Setup(setup func() interface{})
- func StrokeGray(color int, alpha ...int)
- func StrokeHex(code string)
- func StrokeRGBA(r, g, b int, alpha ...int)
- func StrokeWeight(weight float64)
- func WindowHeight() int
- func WindowResized(resized func() interface{})
- func WindowWidth() int
Constants ¶
This section is empty.
Variables ¶
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 )
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 ¶
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 BackgroundHex ¶
func BackgroundHex(code string)
func BackgroundRGBA ¶
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 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 Rect ¶
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 StrokeRGBA ¶
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.