Implimentation

Key:

Many of the global methods had to be added to CanvasClass. For example, in the normal p5, rectMode is global which is fine when there is only one canvas. But in a multi-canvas page, each canvas needs to have its own rectMode.

Surprisingly, very few of the "_xxxxxxx" elements had to be implimented.

elementImplemented in p5 canvasImplemented in CanvasClass
strings
_textFontx
_textStylex
_textAlignx
_textBaselinex
_rectModex
_ellipseModex
_colorModeg
_imageModexx
_cachedStrokeStylex
_cachedFillStylex
_cachedBlendModex
_id
numbers
widthxx
heightxx
_textSizex
_textLeadingx
_curveTightnessx
_strokeWeight
_textWeight
_textStrokeWeight
mouseXgx (when mouse over canvas)
mouseYgx (when mouse over canvas)
pmouseXgx (when mouse over canvas)
pmouseYgx (when mouse over canvas)
winMouseXgx (same as p5 winmouseX over canvas when the mouse is over the canvas. )
winMouseYgx (same as p5 winmouseY over canvas when the mouse is over the canvas. )
pwinMouseXgx (when mouse over canvas. It appears the p5 pwinMouseX gets updated more frequently that CanvasClass pwinMouseX)
pwinMouseYgx (when mouse over canvas. It appears the p5 pwinMouseY gets updated more frequently that CanvasClass pwinMouseY)
movedXgx (when mouse over canvas)
movedYgx (when mouse over canvas)
functions
_applyDefaultsx
resizeCanvasxx
backgroundxx
clearxx
fillxx
strokexx
erasexx
noErasexx
imagexx
_getTintedImageCanvasx
blendModexx
blend xx
_getPixel x
loadPixelsxx
set xx
updatePixels xx
_acuteArcToBezierx
arcxx
ellipsexx
linexx
pointxx
quadxx
rectxx
trianglexx
endShapexx
strokeCapxx
strokeJoinxx
strokeWeightxx
_getFill x
_setFill x
_getStrokex
_setStrokex
bezierxx
curvexx
_doFillStrokeClosex
applyMatrix xx P5 canvases apply resetMatrix() every time a new frame is drawn.When needed, add resetMatrix() at the beginning of draw().
resetMatrixxx
rotatexx (See applyMatrix).
scalexx (See applyMatrix).
translatexx (See applyMatrix).
textxx
_renderTextx
textWidthxx
_applyTextPropertiesx
pushxx
popxx
getxx The two argument version seems to work correctly. But the no argument and 4 argument versions have problems. First, it is not really known how they should work because there are no examples. Second, the image they produce may be "obsolete" not the final one.
textLeadingxx
textSize xx
textStylexx
textAscent xx
textDescentxx
textAlignxx
_isOpenTypex
_updateTextMetricsx
parent xx
id xx
classxx
mousePressedxx
doubleClicked xx
mouseWheelxx
mouseReleasedxx
mouseClickedxx
mouseMovedxx
mouseOverxx
mouseOutxx
touchStartedxx
touchMovedxx
touchEndedxx
dragOverxx
dragLeave xx
_setPropertyx
changedx(Apppears to be useless for canvases.)
input x(Apppears to be useless for canvases.)
addClass xx
removeClassxx
hasClass xx
toggleClassxx
childxx
centerxx Works well if parent is a div. May be a little off if no parent.
htmlxx
positionxx
_translatex
_rotate x
stylexx
attributexx
removeAttributexx
value x(Apppears to be useless for canvases.)
showxx Has an optional extra parameter: show(true) displays inline
hidexx
sizexx No arguments: returns size. Arguments seem useless.
removexx
dropxx
colorgx
colorModegx
loadImagegx
noFillgx
noStrokegx
rectModegx
ellipseModegx
textFontgx
squaregx
circlegx
bezierPointgx
bezierTangentgx
_decrementPreloadg
beginShapegx
vertexgx
keyDownx An event listener like mousePressed
keyUpx An event listener like moiseReleased
bluegx
greengx
redgx
brightnessgx
huegx
saturationgx
lerpgx
smoothgx
noSmoothgx
beginContourgx
endContourgx
curveVertexgx
bezierVertexgx
bezierDetailgx
curveDetailgx
curveTightnessgx
curvePointgx
curveTangentgx
loadFontgx
shearXgx
shearYgx
imageModegx
saveg(Use saveCanvas instead)
saveCanvasgx
pixelDensitygx
WebGL
These functions have been tested mostly in a static situation. Some do not work correctly in put in motion and some material and lights seem to turn white after several draws. See testRotation.html for some examples of rotations and translations that work.
boxgx Works but problems with "in-motion" rotations.
spheregx Works but problems with "in-motion" rotations.
conegx Works but problems with "in-motion" rotations.
cylindergx Works but problems with "in-motion" rotations.
torusgx Works but problems with "in-motion" rotations.
planegx Works but problems with "in-motion" rotations.
rotateXgx Works in static sketches but problems with "in-motion" rotations.
rotateYgx Works in static sketches but problems with "in-motion" rotations.
rotateZgx Works in static and some simple in-motion sketches but some problems with more complicated "in-motion" rotations.
normalMaterialgx
ambientMaterialgx (not tested "in-motion")
specularMaterialgx (not tested "in-motion")
emissiveMaterialgx (not tested "in-motion")
ambientLightgx (only tested with 1 and 3 arguments)
pointLightgx (only tested with 6 arguments)
directionalLightgx (only tested with 6 arguments
spotLightgx (only tested with 10 arguments
specularColorgx (only tested with 3 arguments)
shininessgx
objects
elt xx
_pixelsStatex
_pInstxx
_eventsxx
canvas xx
_textAscentx (null)
_textDescentx (null)
_tint x (null)
drawingContextx
_backgoundColor
_fillColor
_strokeColor
touchesgx
_colorMaxesg
rendererx
boolean
_isMainCanvasx
_doStrokex
_doFillx
_strokeSetx
_fillSetx
_dragDisabledx
mouseIsPressedgx
keyIsPressedgx if keyDown() and keyUp() are declared
isOverx True if the mouse is over the canvas.
_strokeText
_dragStarted
Extras not part of the class
globalMouseIf one wants to be able to follow the mouse even when it is outside of the canvas. Set globalMouse equal to the canvas name and use gMouseX and gMouseY. This works for only one canvas at a time.

James Brink, 7/31/2020