Discuss Scratch

Scratch-Minion
Scratcher
1000+ posts

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

My browser / operating system: Windows NT 10.0, Chrome 76.0.3809.132, No Flash version detected

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

ie. color 0 = color 101 = color 202 = color 303 … rather than color 0 = color 100 = color 200 = color 300 …

Example Scratch 3.0 project that displays lines of color 0, 100, 200, 300 … https://scratch.mit.edu/projects/327014325/

laughingKittens
New Scratcher
7 posts

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

hey can someone tell me the bug in this project i watched the project and it looked fine.
Flowermanvista
Scratcher
1000+ posts

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

The problem is explained in the OP - the pen color should cycle every 100 numbers, instead of every 101 numbers as it does in Scratch 3.0. If this project were written out in Scratch 2.0, the project would produce a solid color on the screen.
heldlaw
Scratcher
100+ posts

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

Scratch-Minion wrote:

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0
By pure coincidence I noticed the same bug today.

So I looked up the relevant wiki article:
https://en.scratch-wiki.info/wiki/Pen_Color_(value)

It claims:
There are 100 possible hues, with values from 0 to 99.
That may have been the intention, but as your project proves, it is not correct. (It may have been correct in Scratch 2.0.)

But hurray for the wiki article: it directs us straight to the bug!
https://github.com/LLK/scratch-vm/blob/develop/src/extensions/scratch3_pen/index.js#L200
return MathUtil.wrapClamp(value, 0, 100);
That should be:
return MathUtil.wrapClamp(value, 0, 99);
You can verify this by looking at the implementation of wrapClamp:
https://github.com/LLK/scratch-vm/blob/develop/src/util/math-util.js#L32

Last edited by heldlaw (Sept. 8, 2019 19:27:40)

heldlaw
Scratcher
100+ posts

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

heldlaw wrote:

But hurray for the wiki article: it directs us straight to the bug!
I took the liberty of opening an issue (referring to this thread) and creating a pull request.
https://github.com/LLK/scratch-vm/issues/2273
https://github.com/LLK/scratch-vm/pull/2274
Scratch-Minion
Scratcher
1000+ posts

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

heldlaw wrote:

heldlaw wrote:

But hurray for the wiki article: it directs us straight to the bug!
I took the liberty of opening an issue (referring to this thread) and creating a pull request.
https://github.com/LLK/scratch-vm/issues/2273
https://github.com/LLK/scratch-vm/pull/2274

Thank-you heldlaw!

(I don't know much about github and have never programmed in javascript or anything similar).
laughingKittens
New Scratcher
7 posts

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

oh now i get it i dont have scratch 3.0 and i dont use pen but i think i have an answer to that, what block did you use if you used the normal one you
could try looking at the code for the block if you dont see a bug in that then ethier scratch has a bug or you havent typed the right amount.
iamdominic
Scratcher
36 posts

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

change pen color by (100)

LOLOLOL

Scratch team fix this bug
laughingKittens
New Scratcher
7 posts

Pen Colors repeat each 101 numbers rather than each 100 numbers in Scratch 3.0

change pen color by 100)

Powered by DjangoBB