Skip to content

Commit 908b89b

Browse files
authored
Merge pull request #8328 from dhowe/ticket8278
Resolves #8278
2 parents 209f8d1 + 0bf343a commit 908b89b

File tree

16 files changed

+352
-93
lines changed

16 files changed

+352
-93
lines changed

docs/parameterData.json

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@
305305
},
306306
"ellipseMode": {
307307
"overloads": [
308+
[],
308309
[
309310
"CENTER|RADIUS|CORNER|CORNERS"
310311
]
@@ -808,6 +809,7 @@
808809
},
809810
"rectMode": {
810811
"overloads": [
812+
[],
811813
[
812814
"CENTER|RADIUS|CORNER|CORNERS"
813815
]
@@ -878,7 +880,8 @@
878880
"ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String",
879881
"Number?",
880882
"Number?"
881-
]
883+
],
884+
[]
882885
]
883886
},
884887
"createElement": {
@@ -1086,7 +1089,8 @@
10861089
"overloads": [
10871090
[
10881091
"ROUND|SQUARE|PROJECT"
1089-
]
1092+
],
1093+
[]
10901094
]
10911095
},
10921096
"lerp": {
@@ -1292,7 +1296,8 @@
12921296
"overloads": [
12931297
[
12941298
"MITER|BEVEL|ROUND"
1295-
]
1299+
],
1300+
[]
12961301
]
12971302
},
12981303
"noCursor": {
@@ -1391,7 +1396,8 @@
13911396
"overloads": [
13921397
[
13931398
"Number"
1394-
]
1399+
],
1400+
[]
13951401
]
13961402
},
13971403
"degrees": {
@@ -2268,6 +2274,7 @@
22682274
},
22692275
"colorMode": {
22702276
"overloads": [
2277+
[],
22712278
[
22722279
"RGB|HSB|HSL|RGBHDR|HWB|LAB|LCH|OKLAB|OKLCH",
22732280
"Number?"
@@ -2492,6 +2499,7 @@
24922499
},
24932500
"tint": {
24942501
"overloads": [
2502+
[],
24952503
[
24962504
"Number",
24972505
"Number",
@@ -2631,6 +2639,7 @@
26312639
},
26322640
"fill": {
26332641
"overloads": [
2642+
[],
26342643
[
26352644
"Number",
26362645
"Number",
@@ -2680,7 +2689,8 @@
26802689
[
26812690
"LEFT|CENTER|RIGHT?",
26822691
"TOP|BOTTOM|CENTER|BASELINE?"
2683-
]
2692+
],
2693+
[]
26842694
]
26852695
},
26862696
"textAscent": {
@@ -2701,15 +2711,17 @@
27012711
"overloads": [
27022712
[
27032713
"Number?"
2704-
]
2714+
],
2715+
[]
27052716
]
27062717
},
27072718
"textFont": {
27082719
"overloads": [
27092720
[
27102721
"p5.Font|String|Object?",
27112722
"Number?"
2712-
]
2723+
],
2724+
[]
27132725
]
27142726
},
27152727
"textSize": {
@@ -2854,6 +2866,7 @@
28542866
},
28552867
"imageMode": {
28562868
"overloads": [
2869+
[],
28572870
[
28582871
"CORNER|CORNERS|CENTER"
28592872
]
@@ -2983,6 +2996,7 @@
29832996
},
29842997
"stroke": {
29852998
"overloads": [
2999+
[],
29863000
[
29873001
"Number",
29883002
"Number",
@@ -3227,6 +3241,7 @@
32273241
},
32283242
"blendMode": {
32293243
"overloads": [
3244+
[],
32303245
[
32313246
"BLEND|DARKEST|LIGHTEST|DIFFERENCE|MULTIPLY|EXCLUSION|SCREEN|REPLACE|OVERLAY|HARD_LIGHT|SOFT_LIGHT|DODGE|BURN|ADD|REMOVE|SUBTRACT"
32323247
]
@@ -3298,7 +3313,8 @@
32983313
"overloads": [
32993314
[
33003315
"Object"
3301-
]
3316+
],
3317+
[]
33023318
]
33033319
},
33043320
"linePerspective": {
@@ -3387,7 +3403,8 @@
33873403
"overloads": [
33883404
[
33893405
"IMAGE|NORMAL"
3390-
]
3406+
],
3407+
[]
33913408
]
33923409
},
33933410
"setCamera": {
@@ -3409,7 +3426,8 @@
34093426
[
34103427
"CLAMP|REPEAT|MIRROR",
34113428
"CLAMP|REPEAT|MIRROR?"
3412-
]
3429+
],
3430+
[]
34133431
]
34143432
},
34153433
"normalMaterial": {

src/color/p5.Color.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ class Color {
724724
if(!Array.isArray(v)){
725725
return [0, v];
726726
}else{
727-
return v
727+
return v;
728728
}
729729
});
730730

src/color/setting.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,7 @@ function setting(p5, fn){
580580
* @chainable
581581
*/
582582
fn.background = function(...args) {
583-
this._renderer.background(...args);
584-
return this;
583+
return this._renderer.background(...args);
585584
};
586585

587586
/**
@@ -1096,6 +1095,8 @@ function setting(p5, fn){
10961095
* or `HSLA` colors, depending on the current <a href="#/p5/colorMode">colorMode()</a>. The last parameter
10971096
* sets the alpha (transparency) value.
10981097
*
1098+
* Calling `fill()` without an argument returns the current fill as a <a href="#/p5.Color">p5.Color</a> object.
1099+
*
10991100
* @method fill
11001101
* @param {Number} v1 red value if color mode is RGB or hue value if color mode is HSB.
11011102
* @param {Number} v2 green value if color mode is RGB or saturation value if color mode is HSB.
@@ -1284,9 +1285,12 @@ function setting(p5, fn){
12841285
* @param {p5.Color} color the fill color.
12851286
* @chainable
12861287
*/
1288+
/**
1289+
* @method fill
1290+
* @return {p5.Color} the current fill color.
1291+
*/
12871292
fn.fill = function(...args) {
1288-
this._renderer.fill(...args);
1289-
return this;
1293+
return this._renderer.fill(...args);
12901294
};
12911295

12921296
/**
@@ -1415,6 +1419,8 @@ function setting(p5, fn){
14151419
* or HSLA colors, depending on the current `colorMode()`. The last parameter
14161420
* sets the alpha (transparency) value.
14171421
*
1422+
* Calling `stroke()` without an argument returns the current stroke as a <a href="#/p5.Color">p5.Color</a> object.
1423+
*
14181424
* @method stroke
14191425
* @param {Number} v1 red value if color mode is RGB or hue value if color mode is HSB.
14201426
* @param {Number} v2 green value if color mode is RGB or saturation value if color mode is HSB.
@@ -1601,9 +1607,12 @@ function setting(p5, fn){
16011607
* @param {p5.Color} color the stroke color.
16021608
* @chainable
16031609
*/
1610+
/**
1611+
* @method stroke
1612+
* @return {p5.Color} the current stroke color.
1613+
*/
16041614
fn.stroke = function(...args) {
1605-
this._renderer.stroke(...args);
1606-
return this;
1615+
return this._renderer.stroke(...args);
16071616
};
16081617

16091618
/**
@@ -1768,6 +1777,8 @@ function setting(p5, fn){
17681777
* EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,
17691778
* SOFT_LIGHT, DODGE, BURN, ADD, REMOVE or SUBTRACT
17701779
*
1780+
* Calling `blendMode()` without an argument returns the current blendMode.
1781+
*
17711782
* @example
17721783
* function setup() {
17731784
* createCanvas(100, 100);
@@ -2136,6 +2147,10 @@ function setting(p5, fn){
21362147
* describe('A yellow line and a turquoise line form an X on a gray background. The area where they overlap is green.');
21372148
* }
21382149
*/
2150+
/**
2151+
* @method blendMode
2152+
* @return {(BLEND|DARKEST|LIGHTEST|DIFFERENCE|MULTIPLY|EXCLUSION|SCREEN|REPLACE|OVERLAY|HARD_LIGHT|SOFT_LIGHT|DODGE|BURN|ADD|REMOVE|SUBTRACT)} the current blend mode.
2153+
*/
21392154
fn.blendMode = function (mode) {
21402155
// p5._validateParameters('blendMode', arguments);
21412156
if (mode === constants.NORMAL) {
@@ -2145,7 +2160,7 @@ function setting(p5, fn){
21452160
);
21462161
mode = constants.BLEND;
21472162
}
2148-
this._renderer.blendMode(mode);
2163+
return this._renderer.blendMode(mode);
21492164
};
21502165
}
21512166

src/core/environment.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ function environment(p5, fn, lifecycles){
215215
* cursor, `x` and `y` set the location pointed to within the image. They are
216216
* both 0 by default, so the cursor points to the image's top-left corner. `x`
217217
* and `y` must be less than the image's width and height, respectively.
218+
*
219+
* Calling `cursor()` without an argument returns the current cursor type as a string.
218220
*
219221
* @method cursor
220222
* @param {(ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String)} type Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT.
@@ -281,9 +283,17 @@ function environment(p5, fn, lifecycles){
281283
* }
282284
* }
283285
*/
286+
/**
287+
* @method cursor
288+
* @return {(ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String)} the current cursor type
289+
*/
284290
fn.cursor = function(type, x, y) {
285291
let cursor = 'auto';
286292
const canvas = this._curElement.elt;
293+
if (typeof type === 'undefined') {
294+
let curstr = canvas.style.cursor;
295+
return curstr.length ? curstr : 'default';
296+
}
287297
if (standardCursors.includes(type)) {
288298
// Standard css cursor
289299
cursor = type;

src/core/p5.Renderer.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,20 @@ class Renderer {
4545
rectMode: constants.CORNER,
4646
ellipseMode: constants.CENTER,
4747
strokeWeight: 1,
48+
bezierOrder: 3,
49+
splineProperties: new ClonableObject({
50+
ends: constants.INCLUDE,
51+
tightness: 0
52+
}),
4853

4954
textFont: { family: 'sans-serif' },
5055
textLeading: 15,
5156
leadingSet: false,
5257
textSize: 12,
5358
textAlign: constants.LEFT,
5459
textBaseline: constants.BASELINE,
55-
bezierOrder: 3,
56-
splineProperties: new ClonableObject({
57-
ends: constants.INCLUDE,
58-
tightness: 0
59-
}),
6060
textWrap: constants.WORD,
61-
62-
// added v2.0
63-
fontStyle: constants.NORMAL, // v1: textStyle
61+
fontStyle: constants.NORMAL, // v1: was textStyle
6462
fontStretch: constants.NORMAL,
6563
fontWeight: constants.NORMAL,
6664
lineHeight: constants.NORMAL,
@@ -330,24 +328,29 @@ class Renderer {
330328
}
331329

332330
fill(...args) {
333-
this.states.setValue('fillSet', true);
334-
this.states.setValue('fillColor', this._pInst.color(...args));
335-
this.updateShapeVertexProperties();
331+
if (args.length > 0) {
332+
this.states.setValue('fillSet', true);
333+
this.states.setValue('fillColor', this._pInst.color(...args));
334+
this.updateShapeVertexProperties();
335+
}
336+
return this.states.fillColor;
336337
}
337338

338339
noFill() {
339340
this.states.setValue('fillColor', null);
340341
}
341342

342343
strokeWeight(w) {
343-
if (w === undefined) {
344+
if (typeof w === 'undefined') {
344345
return this.states.strokeWeight;
345-
} else {
346-
this.states.setValue('strokeWeight', w);
347346
}
347+
this.states.setValue('strokeWeight', w);
348348
}
349349

350350
stroke(...args) {
351+
if (args.length === 0) {
352+
return this.states.strokeColor;
353+
}
351354
this.states.setValue('strokeSet', true);
352355
this.states.setValue('strokeColor', this._pInst.color(...args));
353356
this.updateShapeVertexProperties();

0 commit comments

Comments
 (0)