Discuss Scratch
- Discussion Forums
- » Suggestions
- » New operator suggestion: Map operation
- Cat2437
-
Scratcher
500+ posts
New operator suggestion: Map operation
This is a suggestion for a new type of operation in the Scratch editor! I've seen this used in other applications (namely Nintendo's Game Builder Garage) and thought, “Why doesn't Scratch have this?” So, I'm suggesting it.
If anyone needs more info on the function, here's a helpful video for it here.
Edit: @The_Cool_Scratch_Guy already made this function. Guess there's no need for this block after all.
(map (Input::#c0c0c0)from range(Range 1...::#c0c0c0)|(Range 2...::#c0c0c0)to(Map to here...::#c0c0c0)|(And map to here...::#c0c0c0)::operators)The block ^
Block usageThis block will, as implied by its name, map values from one range to another. For instance:
(map (7)from range(1)|(10)to(1)|(20)::operators)This would be easy; the end result would be 14, as it's being mapped to a range that's twice the original.Same with 9 becoming 18, 4 becoming 8, and 5.5 becoming 11.
(map (17)to range(38)|(50)to(1)|(10)::operators)This is where it gets tricky. You'd have to do some tricky division and go through a lot of steps to get 17 to 13. This is pretty inefficient, and this block would save time. It's available to anyone that wants to use it, and new scratchers don't have to touch it. Somewhat easy to grasp, works well, and it's optional.
If anyone needs more info on the function, here's a helpful video for it here.
Edit: @The_Cool_Scratch_Guy already made this function. Guess there's no need for this block after all.
Ha, the funny thing is I've even made this a function and used it in my various python projects before with the same name (map). Though it is a rather weird-looking block, and I think making a custom block for this and backpacking it would be enough.define map (input) (startmin) (startmax) (endmin) (endmax)
set [startrange v] to ((startmax) - (startmin))
set [endrange v] to ((endmax) - (endmin))
set [output v] to ((input) - (startmin))
set [output v] to ((output) * ((endrange) / (startrange)))
set [output v] to ((output) + (endmin))
Last edited by Cat2437 (Sept. 21, 2025 02:06:44)
- c0der0928
-
Scratcher
100+ posts
New operator suggestion: Map operation
that might not be right, see, 1 -> 1 instead of 1 -> 2, what would be doubling would be mapping 1 - 10 to 2 - 20(map (7)from range(1)|(10)to(1)|(20)::operators)This would be easy; the end result would be 14, as it's being mapped to a range that's twice the original.Same with 9 becoming 18, 4 becoming 8, and 5.5 becoming 11.
- Cat2437
-
Scratcher
500+ posts
New operator suggestion: Map operation
I'n not the best at math…that might not be right, see, 1 -> 1 instead of 1 -> 2, what would be doubling would be mapping 1 - 10 to 2 - 20(map (7)from range(1)|(10)to(1)|(20)::operators)This would be easy; the end result would be 14, as it's being mapped to a range that's twice the original.Same with 9 becoming 18, 4 becoming 8, and 5.5 becoming 11.
Exactly the reason why this block should be included!
- Cat2437
-
Scratcher
500+ posts
New operator suggestion: Map operation
Bump (doing it again because the previous one didn't work for some reason)
- Quantum-Cat
-
Scratcher
1000+ posts
New operator suggestion: Map operation
I would like to know what are the use cases for this block. It honestly seems very specific.
And here is some maths based on what I understood from the description:
And here is some maths based on what I understood from the description:
(map (x)from range(a)|(A)to(b)|(B)::operators)Therefore, knowing that a maps to b and A maps to B, in general, the output y = m(x-a) + b, where m = (B-b)/(A-a).
m is just the scaling factor (i.e. whether you double, triple, x0.5, etc.), but in the case the start points are not 0, the -a and +b ensure that a maps to b: when x=a, y = m(a-a)+b = m*0+b = b
- Gamer_Logan819
-
Scratcher
1000+ posts
New operator suggestion: Map operation
this looks useful but I genuinely cannot understand what this is supposed to be so I would assume children wouldn't be able to understand it either. the thing with most other scratchblocks is that they can be understood with minimal practice. I do absolutely support this but I think you should have a better way to explain it within the block.
Last edited by Gamer_Logan819 (Sept. 18, 2025 17:59:50)
- Cat2437
-
Scratcher
500+ posts
New operator suggestion: Map operation
I would like to know what are the use cases for this block. It honestly seems very specific.
And here is some maths based on what I understood from the description:(map (x)from range(a)|(A)to(b)|(B)::operators)Therefore, knowing that a maps to b and A maps to B, in general, the output y = m(x-a) + b, where m = (B-b)/(A-a).
m is just the scaling factor (i.e. whether you double, triple, x0.5, etc.), but in the case the start points are not 0, the -a and +b ensure that a maps to b: when x=a, y = m(a-a)+b = m*0+b = b
this looks useful but I genuinely cannot understand what this is supposed to be so I would assume children wouldn't be able to understand it either. the thing with most other scratchblocks is that they can be understood with minimal practice. I do absolutely support this but I think you should have a better way to explain it within the block.Alright, lemme do my best to try to explain it better.
Variable ‘X’ is the input value. It starts on the range of ‘a’ to ‘A’, and is being mapped to range ‘b’ to ‘B’. Say range aA goes from -10 to 40, and range bB goes from -30 to 40. If you want to know where 12 (input ‘X’) lies when going from range aA to bB, the map block will ‘map’ out where it would be relative to bB. That would be useful in bisecting 2 lines with the same ratio between the cuts, for instance. Same with if you make a parallax sprite follow the mouse.
- FancyLongUsername
-
Scratcher
100+ posts
New operator suggestion: Map operation
nope… still not getting it…I would like to know what are the use cases for this block. It honestly seems very specific.
And here is some maths based on what I understood from the description:(map (x)from range(a)|(A)to(b)|(B)::operators)Therefore, knowing that a maps to b and A maps to B, in general, the output y = m(x-a) + b, where m = (B-b)/(A-a).
m is just the scaling factor (i.e. whether you double, triple, x0.5, etc.), but in the case the start points are not 0, the -a and +b ensure that a maps to b: when x=a, y = m(a-a)+b = m*0+b = bthis looks useful but I genuinely cannot understand what this is supposed to be so I would assume children wouldn't be able to understand it either. the thing with most other scratchblocks is that they can be understood with minimal practice. I do absolutely support this but I think you should have a better way to explain it within the block.Alright, lemme do my best to try to explain it better.
Variable ‘X’ is the input value. It starts on the range of ‘a’ to ‘A’, and is being mapped to range ‘b’ to ‘B’. Say range aA goes from -10 to 40, and range bB goes from -30 to 40. If you want to know where 12 (input ‘X’) lies when going from range aA to bB, the map block will ‘map’ out where it would be relative to bB. That would be useful in bisecting 2 lines with the same ratio between the cuts, for instance. Same with if you make a parallax sprite follow the mouse.

this seems very specific and complex and the main point of scratch is to be a coding platform for children where most of the material is easily understood and rudimentary so
i dont think this should be added
Last edited by FancyLongUsername (Sept. 19, 2025 15:52:23)
- not_electric_ajax
-
Scratcher
97 posts
New operator suggestion: Map operation
This is really specific and I don't know how this would be useful at all, let alone how it would be useful often enough to become a canon block
- Cat2437
-
Scratcher
500+ posts
New operator suggestion: Map operation
I can't explain it well enough. I'm linking a video to where I got the map idea from
- FancyLongUsername
-
Scratcher
100+ posts
New operator suggestion: Map operation
This is really specific and I don't know how this would be useful at all, let alone how it would be useful often enough to become a canon blockexactly!!!
- The_Cool_Scratch_Guy
-
Scratcher
100+ posts
New operator suggestion: Map operation
Ha, the funny thing is I've even made this a function and used it in my various python projects before with the same name (map). Though it is a rather weird-looking block, and I think making a custom block for this and backpacking it would be enough.
define map (input) (startmin) (startmax) (endmin) (endmax)
set [startrange v] to ((startmax) - (startmin))
set [endrange v] to ((endmax) - (endmin))
set [output v] to ((input) - (startmin))
set [output v] to ((output) * ((endrange) / (startrange)))
set [output v] to ((output) + (endmin))
- pippy2011eight
-
Scratcher
500+ posts
New operator suggestion: Map operation
No support, would be confusing to new scrunchers and they might use it and be confused
Last edited by pippy2011eight (Sept. 22, 2025 02:27:25)
- Cat2437
-
Scratcher
500+ posts
New operator suggestion: Map operation
Ha, the funny thing is I've even made this a function and used it in my various python projects before with the same name (map). Though it is a rather weird-looking block, and I think making a custom block for this and backpacking it would be enough.Oh! Looks like this can be put into the workarounds directory. Thank you!define map (input) (startmin) (startmax) (endmin) (endmax)
set [startrange v] to ((startmax) - (startmin))
set [endrange v] to ((endmax) - (endmin))
set [output v] to ((input) - (startmin))
set [output v] to ((output) * ((endrange) / (startrange)))
set [output v] to ((output) + (endmin))
I'll closed this topic soon
- Discussion Forums
- » Suggestions
-
» New operator suggestion: Map operation







