Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » fill area by pen
- brly
- Scratcher
100+ posts
fill area by pen
is there a way to fill a area with pen
Last edited by brly (Nov. 28, 2015 18:04:38)
try my projects like:
https://scratch.mit.edu/projects/75140402/
posts:
https://scratch.mit.edu/discuss/topic/206033/
brly
- little_kitten
- Scratcher
500+ posts
fill area by pen
Well, you would probably need to program the entire area of the space you're filling in to a list, and then do this
set [# v] to (0)
pen down
repeat (length of [positions v])
change [# v] by (1)
go to x: (item (#) of [x's v]) y: (item (#) of [y's v])
end
The above post was likely clear sass. 10 outta 10.
Unless it wasn't. Which happens from time to time. Sadly.
- footsocktoe
- Scratcher
1000+ posts
fill area by pen
If it's a simple shape like a rectangle or a circle, it will be easy.
If it's a complicated shape with nooks and crannies, it will be difficult.
But yes, it's possible to fill a shape with the pen.
If it's a complicated shape with nooks and crannies, it will be difficult.
But yes, it's possible to fill a shape with the pen.
SHOOT THE SPACE MONSTERS! ….. A game everyone can play! Bright colors, bonky sounds!
THE 12 BALLS OF CRAZY AL ……. New scrolling adventure game!
- TheLogFather
- Scratcher
1000+ posts
fill area by pen
It depends what you want to fill…
Is it like a drawing program where the user can click a point and ‘flood-fill’ everything that's the same colour from that point?
If so, there are two ways to do it, though it's quite hard and/or fairly slow in both cases, because Scratch has to either check every pixel to see how far the same colour goes, or you have to keep a list of the colour of every pixel on the screen when it gets drawn by the user so that you can work out the flood-fill for yourself.
However, I'll assume for now that's not what you want (since it'll be harder to explain/demonstrate if it is…)
Instead, if you just want to fill an object where you already know in the project exactly what the outline is, then it'll be somewhat simpler and faster.
In general, I think it's quickest to fill a polygon by splitting it into triangles, so that'd be the first thing you'd do.
Then here is a project which shows how to fill triangles very quickly: https://scratch.mit.edu/projects/55619918/
If you want to use semi-transparent pen, though, then you need to fill polygons using horizontal (or vertical) lines, and that'll be a bit slower than splitting into triangles and using the method above. Here's a project that does that (including an option for concave polygons, even with crossing edges): https://scratch.mit.edu/projects/62499800/
Hope that helps!
Is it like a drawing program where the user can click a point and ‘flood-fill’ everything that's the same colour from that point?
If so, there are two ways to do it, though it's quite hard and/or fairly slow in both cases, because Scratch has to either check every pixel to see how far the same colour goes, or you have to keep a list of the colour of every pixel on the screen when it gets drawn by the user so that you can work out the flood-fill for yourself.
However, I'll assume for now that's not what you want (since it'll be harder to explain/demonstrate if it is…)
Instead, if you just want to fill an object where you already know in the project exactly what the outline is, then it'll be somewhat simpler and faster.
In general, I think it's quickest to fill a polygon by splitting it into triangles, so that'd be the first thing you'd do.
Then here is a project which shows how to fill triangles very quickly: https://scratch.mit.edu/projects/55619918/
If you want to use semi-transparent pen, though, then you need to fill polygons using horizontal (or vertical) lines, and that'll be a bit slower than splitting into triangles and using the method above. Here's a project that does that (including an option for concave polygons, even with crossing edges): https://scratch.mit.edu/projects/62499800/
Hope that helps!
Last edited by TheLogFather (Nov. 29, 2015 00:26:19)
Siggy the Kumquat slayer:
Main account: DadOfMrLog –– Frameworks for basic pen-rendered 3D in scratch (see studio). Examples:
- - - - 3D Text - - - - - - Simple shapes - - - Controllable structures - - - On the ground - - - - - - In space - - - -
- - - - 3D Text - - - - - - Simple shapes - - - Controllable structures - - - On the ground - - - - - - In space - - - -
- CANSLP
- Scratcher
100+ posts
fill area by pen
It depends what you want to fill…
Is it like a drawing program where the user can click a point and ‘flood-fill’ everything that's the same colour from that point?
If so, there are two ways to do it, though it's quite hard and/or fairly slow in both cases, because Scratch has to either check every pixel to see how far the same colour goes, or you have to keep a list of the colour of every pixel on the screen when it gets drawn by the user so that you can work out the flood-fill for yourself.
However, I'll assume for now that's not what you want (since it'll be harder to explain/demonstrate if it is…)
Instead, if you just want to fill an object where you already know in the project exactly what the outline is, then it'll be somewhat simpler and faster.
In general, I think it's quickest to fill a polygon by splitting it into triangles, so that'd be the first thing you'd do.
Then here is a project which shows how to fill triangles very quickly: https://scratch.mit.edu/projects/55619918/
If you want to use semi-transparent pen, though, then you need to fill polygons using horizontal (or vertical) lines, and that'll be a bit slower than splitting into triangles and using the method above. Here's a project that does that (including an option for concave polygons, even with crossing edges): https://scratch.mit.edu/projects/62499800/
Hope that helps!
Do you have any references for good polygon splitters? Preferably for complex shapes~
– C A N S L P
Traveling Game Designer
- agmmes
- Scratcher
100+ posts
fill area by pen
Hm, let me see… P.S. The pen should be 1x1px, and should be colored not with scripts, because there is only stamp.
This is for square, triangle, even random-lined shape.
when green flag clickedBut! Notice, this is raw script with bugs. You should end it by: filling some parameters, fixing some bugs if you find one.
here you create perimeter of your shape :: grey
go to x: (highest point of your shape :: #000000) y: (highest point of your shape :: #000000)
repeat (some calibration :: #000000)
if <touching [color of your pen]> then
turn cw (90) degrees
else
move (1) steps
stamp
end
This is for square, triangle, even random-lined shape.
When <(Utils::list) = [1110]>, [but v], <(Costume name::looks) != [Easter]::operators> then{
Set costume to [Easter v] :: looks
Show [Dev.DebugConsole v] :: #C0F4AB
Send [Debug console unlocked!] to [Debug console v] :: #C0F4AB
}::control
- TheCodePro123
- Scratcher
100+ posts
fill area by pen
Please create your own topic for your own question.It depends what you want to fill…
Is it like a drawing program where the user can click a point and ‘flood-fill’ everything that's the same colour from that point?
If so, there are two ways to do it, though it's quite hard and/or fairly slow in both cases, because Scratch has to either check every pixel to see how far the same colour goes, or you have to keep a list of the colour of every pixel on the screen when it gets drawn by the user so that you can work out the flood-fill for yourself.
However, I'll assume for now that's not what you want (since it'll be harder to explain/demonstrate if it is…)
Instead, if you just want to fill an object where you already know in the project exactly what the outline is, then it'll be somewhat simpler and faster.
In general, I think it's quickest to fill a polygon by splitting it into triangles, so that'd be the first thing you'd do.
Then here is a project which shows how to fill triangles very quickly: https://scratch.mit.edu/projects/55619918/
If you want to use semi-transparent pen, though, then you need to fill polygons using horizontal (or vertical) lines, and that'll be a bit slower than splitting into triangles and using the method above. Here's a project that does that (including an option for concave polygons, even with crossing edges): https://scratch.mit.edu/projects/62499800/
Hope that helps!
Do you have any references for good polygon splitters? Preferably for complex shapes~
TheCodePro123
CODE LIKE A PRO
Leave a follow, love, or favorite! Even a view is fine!
Things to Check Out: Anything in Bold is a Link
Check out my Marvelous Art Maker (MAM)!
Check out the EpicCode Productions!
Check out the Translate to Morse Code!
CODE LIKE A PRO!
THE PRO WITH CODE
- arjunflamer
- Scratcher
3 posts
fill area by pen
move (ggg) steps
when this sprite clicked
stamp
stamp
stamp
pen down
pen up
set pen color to [#6afe65]
- awesome-llama
- Scratcher
1000+ posts
fill area by pen
Please don't spam and necropost on old topics and bump them up to the top.
Also, the only place to test scratchblocks is here: https://scratch.mit.edu/discuss/topic/374997/ Don't blockspam here.
Reporting this topic to be closed.
Also, the only place to test scratchblocks is here: https://scratch.mit.edu/discuss/topic/374997/ Don't blockspam here.
Reporting this topic to be closed.
- Discussion Forums
- » Help with Scripts
- » fill area by pen