Topic Information

pen blocks for the background by HTML-Fan in Suggestions

Posts: 28

1: HTML-Fan wrote at 2:36:29 PM 27/6/20204166448
Something that's for me as a C++ programmer really odd is the lack of a block to draw a line on the background. I would think that you just go to the background and add your pen code there, but you need a sprite to draw lines. Also blocks for circles/rings are missing and you can't draw rectangles or polygons either without long and slow code. That's a reason why I don't use scratch too much. The background is just more or less useless, because it's hard to just draw some stuff on it. I would like to see blocks like this which are only available as bg code:
draw line (x) (y) (x2) (y2) :: operator
fill rect(x) (y) (x2) (y2) :: operator
fill triangle (x) (y) (x2) (y2) (x3) (y3) :: operator
fill ring (x) (y) (rx) (ry) (rx2) (ry2) :: operator
What do you think about the idea?
And please don't say “That's confusing to a beginner!”. I think that it's more confusing to be not able to do so.
2: HTML-Fan wrote at 5:59:09 PM 27/6/20204166928
Of course the blocks for setting the color and so on are still needed.
A block like
set pen color to (r) (g) (b) :: pen
would also be nice.
3: HTML-Fan wrote at 3:48:01 PM 27/6/20204167244
Or
set pen color to (r) (g) (b) (a) :: pen
4: HTML-Fan wrote at 5:30:48 PM 27/6/20204167633
For filled shapes you also need
set fill color to something
so the normal pen color is used as a border color and the pen size is the border thickness.
5: fdreerf wrote at 5:35:17 PM 27/6/20204167649
I've learned more about lines and circles trying to do this on my own.
You can use hex codes for the pen color if you use a variable or the join block.
6: HTML-Fan wrote at 5:41:32 PM 27/6/20204167666
You may have learned a lot but it still runs like garbage because scratch is slow.
I know how to do things like rings with the Bresenham algorithm, it's pretty interesting, but, as I said, it's just too slow to be really useful.
7: fdreerf wrote at 5:46:27 PM 27/6/20204167675

HTML-Fan wrote:

You may have learned a lot but it still runs like garbage because scratch is slow.
I know how to do things like rings with the Bresenham algorithm, it's pretty interesting, but, as I said, it's just too slow to be really useful.
I've never had any problems with speed.
Maybe use forkphorus?
8: HTML-Fan wrote at 5:51:12 PM 27/6/20204167684
Forkphorus makes my snake project (signature) run smooth, but forkphorus has no support for cloud variables and it's a bit clunky to paste the link. And forkphorus also has its limits. It's about 10x faster, but it's still just a browser thing, so it's slow, only less extremely slow.
9: scratchastroLOL wrote at 5:53:19 PM 27/6/20204167692
You could do this:

define fill rectangle with color (colorcode), height (height), width (width)
pen up
set pen color to [#D32727]
set pen size to (10)
go to x: (0) y: (0)
repeat until <touching color [#D32727] ?>
change x by (-10)
change y by (-10)
end
set [x v] to (x position)
pen down
repeat ((height :: custom) / (10))
repeat until <touching color [#D32727] ?>
change x by (1)
end
pen up
change y by (1)
pen down
end
10: HTML-Fan wrote at 5:53:37 PM 27/6/20204167693
And a filled triangle is hard. And slow. Filled polygons are a problem.
My project also uses “circles”.
11: AnAccount_StopAsking wrote at 5:54:50 PM 27/6/20204167697
I think I remember a block like that! It's in a different programming language though.

But still, it uses block programming alongside JavaScript, Python, HTML and CSS.
12: HTML-Fan wrote at 5:56:14 PM 27/6/20204167702

AnAccount_StopAsking wrote:

I think I remember a block like that!
Like what?
13: HTML-Fan wrote at 9:56:33 AM 28/6/20204169864
*bump*
14: whiteandblackcat wrote at 2:05:36 AM 29/6/20204172275

HTML-Fan wrote:

You may have learned a lot but it still runs like garbage because scratch is slow.
I know how to do things like rings with the Bresenham algorithm, it's pretty interesting, but, as I said, it's just too slow to be really useful.
And yet people still manage to make 100% pen games that redraw every screen refresh….

These blocks are pretty advanced. Maybe they could be added as a plugin, so they wouldn't confuse new scratchers?
wait pen is a plugin now
I think it would be overkill to have two different pen plugins, but I still believe any blocks like this should be separate from other blocks as they frankly can be very confusing.

If anyone has any ideas on separation they'd be appreciated
15: HTML-Fan wrote at 9:16:09 AM 29/6/20204172882

whiteandblackcat wrote:

If anyone has any ideas on separation they'd be appreciated
My idea would just be that you have these pen blocks as the pen expansion but they're only available for the background, the motion blocks are also only available for sprites.
16: HTML-Fan wrote at 9:19:18 AM 29/6/20204172890

whiteandblackcat wrote:

And yet people still manage to make 100% pen games that redraw every screen refresh….
I already made one with 3d graphics (signature) and it runs with forkphorus with a redraw every frame and I have (12 + 12) * 20 = ~500 lines on screen at once. Other pen games like 3d platformers only draw about 50 lines at once. So they run more or less smooth, but the graphics aren't nice.
17: HTML-Fan wrote at 11:11:49 AM 29/6/20204173149
*bump*
18: whiteandblackcat wrote at 11:55:30 AM 29/6/20204173229

HTML-Fan wrote:

whiteandblackcat wrote:

If anyone has any ideas on separation they'd be appreciated
My idea would just be that you have these pen blocks as the pen expansion but they're only available for the background, the motion blocks are also only available for sprites.
That would work, I like that idea. But then where does the pen “start”? Or would there just not be pen down, pen up blocks?
Also I like the polygon list idea, that would be really cool! (Sorry quoting is hard on mobile )
19: HTML-Fan wrote at 11:58:18 AM 29/6/20204173236

whiteandblackcat wrote:

That would work, I like that idea. But then where does the pen “start”? Or would there just not be pen down, pen up blocks?
The pen up and down blocks don't exsist, since the background can't move. It's like in C++ or Java: You just change the variables where the screen pixels are stored. The pen up and down thing is pretty much just a way to explain that to beginners.
20: whiteandblackcat wrote at 12:33:08 PM 29/6/20204173326

HTML-Fan wrote:

whiteandblackcat wrote:

That would work, I like that idea. But then where does the pen “start”? Or would there just not be pen down, pen up blocks?
The pen up and down blocks don't exsist, since the background can't move. It's like in C++ or Java: You just change the variables where the screen pixels are stored. The pen up and down thing is pretty much just a way to explain that to beginners.
Oh, good point. Maybe it should be an extra plugin then…
Anyway, lets continue this tomorrow as it's quite late here and I'm tired.