Skip to content
36 changes: 26 additions & 10 deletions docs/parameterData.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
},
"colorMode": {
"overloads": [
[],
[
"RGB|HSB|HSL|RGBHDR|HWB|LAB|LCH|OKLAB|OKLCH",
"Number?"
Expand All @@ -217,6 +218,7 @@
},
"fill": {
"overloads": [
[],
[
"Number",
"Number",
Expand Down Expand Up @@ -250,6 +252,7 @@
},
"stroke": {
"overloads": [
[],
[
"Number",
"Number",
Expand Down Expand Up @@ -286,6 +289,7 @@
},
"blendMode": {
"overloads": [
[],
[
"BLEND|DARKEST|LIGHTEST|DIFFERENCE|MULTIPLY|EXCLUSION|SCREEN|REPLACE|OVERLAY|HARD_LIGHT|SOFT_LIGHT|DODGE|BURN|ADD|REMOVE|SUBTRACT"
]
Expand All @@ -303,6 +307,7 @@
},
"cursor": {
"overloads": [
[],
[
"ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String",
"Number?",
Expand Down Expand Up @@ -587,7 +592,8 @@
],
[
"p5.Vector"
]
],
[]
]
},
"push": {
Expand Down Expand Up @@ -1014,7 +1020,8 @@
],
[
"p5.Color"
]
],
[]
]
},
"noTint": {
Expand All @@ -1026,7 +1033,8 @@
"overloads": [
[
"CORNER|CORNERS|CENTER"
]
],
[]
]
},
"blend": {
Expand Down Expand Up @@ -1751,7 +1759,8 @@
"overloads": [
[
"CENTER|RADIUS|CORNER|CORNERS"
]
],
[]
]
},
"noSmooth": {
Expand All @@ -1761,6 +1770,7 @@
},
"rectMode": {
"overloads": [
[],
[
"CENTER|RADIUS|CORNER|CORNERS"
]
Expand All @@ -1775,21 +1785,24 @@
"overloads": [
[
"ROUND|SQUARE|PROJECT"
]
],
[]
]
},
"strokeJoin": {
"overloads": [
[
"MITER|BEVEL|ROUND"
]
],
[]
]
},
"strokeWeight": {
"overloads": [
[
"Number"
]
],
[]
]
},
"bezier": {
Expand Down Expand Up @@ -2103,7 +2116,8 @@
[
"LEFT|CENTER|RIGHT?",
"TOP|BOTTOM|CENTER|BASELINE?"
]
],
[]
]
},
"textAscent": {
Expand Down Expand Up @@ -3036,15 +3050,17 @@
"overloads": [
[
"IMAGE|NORMAL"
]
],
[]
]
},
"textureWrap": {
"overloads": [
[
"CLAMP|REPEAT|MIRROR",
"CLAMP|REPEAT|MIRROR?"
]
],
[]
]
},
"normalMaterial": {
Expand Down
2 changes: 1 addition & 1 deletion src/color/p5.Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ class Color {
if(!Array.isArray(v)){
return [0, v];
}else{
return v
return v;
}
});

Expand Down
11 changes: 4 additions & 7 deletions src/color/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,7 @@ function setting(p5, fn){
* @chainable
*/
fn.background = function(...args) {
this._renderer.background(...args);
return this;
return this._renderer.background(...args);
};

/**
Expand Down Expand Up @@ -1470,8 +1469,7 @@ function setting(p5, fn){
* @chainable
*/
fn.fill = function(...args) {
this._renderer.fill(...args);
return this;
return this._renderer.fill(...args);
};

/**
Expand Down Expand Up @@ -1839,8 +1837,7 @@ function setting(p5, fn){
* @chainable
*/
fn.stroke = function(...args) {
this._renderer.stroke(...args);
return this;
return this._renderer.stroke(...args);
};

/**
Expand Down Expand Up @@ -2443,7 +2440,7 @@ function setting(p5, fn){
);
mode = constants.BLEND;
}
this._renderer.blendMode(mode);
return this._renderer.blendMode(mode);
};
}

Expand Down
4 changes: 4 additions & 0 deletions src/core/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ function environment(p5, fn, lifecycles){
fn.cursor = function(type, x, y) {
let cursor = 'auto';
const canvas = this._curElement.elt;
if (typeof type === 'undefined') {
let curstr = canvas.style.cursor;
return curstr.length ? curstr : 'default';
}
if (standardCursors.includes(type)) {
// Standard css cursor
cursor = type;
Expand Down
32 changes: 18 additions & 14 deletions src/core/p5.Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ClonableObject {

class Renderer {
static states = {
background: null,
strokeColor: null,
strokeSet: false,
fillColor: null,
Expand All @@ -45,22 +46,20 @@ class Renderer {
rectMode: constants.CORNER,
ellipseMode: constants.CENTER,
strokeWeight: 1,
bezierOrder: 3,
splineProperties: new ClonableObject({
ends: constants.INCLUDE,
tightness: 0
}),

textFont: { family: 'sans-serif' },
textLeading: 15,
leadingSet: false,
textSize: 12,
textAlign: constants.LEFT,
textBaseline: constants.BASELINE,
bezierOrder: 3,
splineProperties: new ClonableObject({
ends: constants.INCLUDE,
tightness: 0
}),
textWrap: constants.WORD,

// added v2.0
fontStyle: constants.NORMAL, // v1: textStyle
fontStyle: constants.NORMAL, // v1: was textStyle
fontStretch: constants.NORMAL,
fontWeight: constants.NORMAL,
lineHeight: constants.NORMAL,
Expand Down Expand Up @@ -323,24 +322,29 @@ class Renderer {
}

fill(...args) {
this.states.setValue('fillSet', true);
this.states.setValue('fillColor', this._pInst.color(...args));
this.updateShapeVertexProperties();
if (args.length > 0) {
this.states.setValue('fillSet', true);
this.states.setValue('fillColor', this._pInst.color(...args));
this.updateShapeVertexProperties();
}
return this.states.fillColor;
}

noFill() {
this.states.setValue('fillColor', null);
}

strokeWeight(w) {
if (w === undefined) {
if (typeof w === 'undefined') {
return this.states.strokeWeight;
} else {
this.states.setValue('strokeWeight', w);
}
this.states.setValue('strokeWeight', w);
}

stroke(...args) {
if (args.length === 0) {
return this.states.strokeColor;
}
this.states.setValue('strokeSet', true);
this.states.setValue('strokeColor', this._pInst.color(...args));
this.updateShapeVertexProperties();
Expand Down
Loading
Loading