Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 37 additions & 15 deletions docs/parameterData.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
},
"background": {
"overloads": [
[],
[
"p5.Color"
],
Expand Down Expand Up @@ -201,6 +202,7 @@
},
"colorMode": {
"overloads": [
[],
[
"RGB|HSB|HSL|RGBHDR|HWB|LAB|LCH|OKLAB|OKLCH",
"Number?"
Expand All @@ -217,6 +219,7 @@
},
"fill": {
"overloads": [
[],
[
"Number",
"Number",
Expand Down Expand Up @@ -250,6 +253,7 @@
},
"stroke": {
"overloads": [
[],
[
"Number",
"Number",
Expand Down Expand Up @@ -286,6 +290,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 +308,7 @@
},
"cursor": {
"overloads": [
[],
[
"ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String",
"Number?",
Expand Down Expand Up @@ -528,28 +534,32 @@
[
"Number",
"p5.Vector|Number[]?"
]
],
[]
]
},
"rotateX": {
"overloads": [
[
"Number"
]
],
[]
]
},
"rotateY": {
"overloads": [
[
"Number"
]
],
[]
]
},
"rotateZ": {
"overloads": [
[
"Number"
]
],
[]
]
},
"scale": {
Expand All @@ -561,21 +571,24 @@
],
[
"p5.Vector|Number[]"
]
],
[]
]
},
"shearX": {
"overloads": [
[
"Number"
]
],
[]
]
},
"shearY": {
"overloads": [
[
"Number"
]
],
[]
]
},
"translate": {
Expand All @@ -587,7 +600,8 @@
],
[
"p5.Vector"
]
],
[]
]
},
"push": {
Expand Down Expand Up @@ -1014,7 +1028,8 @@
],
[
"p5.Color"
]
],
[]
]
},
"noTint": {
Expand All @@ -1026,7 +1041,8 @@
"overloads": [
[
"CORNER|CORNERS|CENTER"
]
],
[]
]
},
"blend": {
Expand Down Expand Up @@ -1748,7 +1764,8 @@
"overloads": [
[
"CENTER|RADIUS|CORNER|CORNERS"
]
],
[]
]
},
"noSmooth": {
Expand All @@ -1758,6 +1775,7 @@
},
"rectMode": {
"overloads": [
[],
[
"CENTER|RADIUS|CORNER|CORNERS"
]
Expand All @@ -1772,21 +1790,24 @@
"overloads": [
[
"ROUND|SQUARE|PROJECT"
]
],
[]
]
},
"strokeJoin": {
"overloads": [
[
"MITER|BEVEL|ROUND"
]
],
[]
]
},
"strokeWeight": {
"overloads": [
[
"Number"
]
],
[]
]
},
"bezier": {
Expand Down Expand Up @@ -2108,7 +2129,8 @@
[
"LEFT|CENTER|RIGHT?",
"TOP|BOTTOM|CENTER|BASELINE?"
]
],
[]
]
},
"textAscent": {
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