Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How Can You Create Pen Rounded Rectangles?
- -Jkoot4-
- Scratcher
8 posts
How Can You Create Pen Rounded Rectangles?
Heyo!
I'm a beginner when it comes to pen, however I understand the basics of it.
I know there is a way to create circles, lines and rectangles, but is there any pen algorithms for rounded rectangles?
If not, how do you create parts of circles?
Thank you!
I'm a beginner when it comes to pen, however I understand the basics of it.
I know there is a way to create circles, lines and rectangles, but is there any pen algorithms for rounded rectangles?
If not, how do you create parts of circles?
Thank you!
- BKFighter
- Scratcher
1000+ posts
How Can You Create Pen Rounded Rectangles?
Do you mean like a rectangle with rounded edges? You could make the pen size larger, and since the pen is a circle, it will be rounded, though it would have to be big to make it more effective. Maybe try using the search bar as that seems like someone would have answered that question.
- -Jkoot4-
- Scratcher
8 posts
How Can You Create Pen Rounded Rectangles?
I have searched but not many answers, however I managed to edit some code:
This helps, but can only create a curve from 0 to 90 degrees, and 180 to 270 degrees
when green flag clicked
forever
draw circle
end
define draw circle (x) (y) (radius) (angle)
pen up
set [dir v] to [0 ]
repeat (((angle) / (2)) + (1))
go to x: ((([sin v] of (dir)) * (radius)) + (x)) y: ((([cos v] of (dir)) * (radius)) + (y))
end
This helps, but can only create a curve from 0 to 90 degrees, and 180 to 270 degrees
Last edited by -Jkoot4- (Jan. 5, 2016 21:00:09)
- lederniersamourai
- Scratcher
500+ posts
How Can You Create Pen Rounded Rectangles?
You should use “relative” moves instead of “absolute” go to x,y
I tried the following code and it is nice. The “circle” is made by moving a small step, then turning 10, …, doing that again, again, … to turn 90 degrees.
I tried the following code and it is nice. The “circle” is made by moving a small step, then turning 10, …, doing that again, again, … to turn 90 degrees.
when green flag clicked
go to x: (0) y: (0)
turn cw (15) degrees
clear
set pen color to [#ff0000]
set pen size to (4)
pen down
repeat (4)
move (100) steps
repeat (9)
move (1) steps
turn cw (10) degrees
end
end
Last edited by lederniersamourai (Jan. 5, 2016 21:36:20)
- footsocktoe
- Scratcher
1000+ posts
How Can You Create Pen Rounded Rectangles?
however I managed to edit some code:I have searched but not many answers,when green flag clicked
forever
draw circle
end
define draw circle (x) (y) (radius) (angle)
pen up
set [dir v] to [0 ]
repeat (((angle) / (2)) + (1))
go to x: ((([sin v] of (dir)) * (radius)) + (x)) y: ((([cos v] of (dir)) * (radius)) + (y))
end
This helps, but can only create a curve from 0 to 90 degrees, and 180 to 270 degrees
Maybe using a minus sign on radius will give you the other two arcs.
- -Jkoot4-
- Scratcher
8 posts
How Can You Create Pen Rounded Rectangles?
No, that only gives an arc of 180 to 270 . If it is positive it gives a arc from 0 to 90however I managed to edit some code:I have searched but not many answers,when green flag clicked
forever
draw circle
end
define draw circle (x) (y) (radius) (angle)
pen up
set [dir v] to [0 ]
repeat (((angle) / (2)) + (1))
go to x: ((([sin v] of (dir)) * (radius)) + (x)) y: ((([cos v] of (dir)) * (radius)) + (y))
end
This helps, but can only create a curve from 0 to 90 degrees, and 180 to 270 degrees
Maybe using a minus sign on radius will give you the other two arcs.
- footsocktoe
- Scratcher
1000+ posts
How Can You Create Pen Rounded Rectangles?
No, that only gives an arc of 180 to 270 . If it is positive it gives a arc from 0 to 90however I managed to edit some code:I have searched but not many answers,when green flag clicked
forever
draw circle
end
define draw circle (x) (y) (radius) (angle)
pen up
set [dir v] to [0 ]
repeat (((angle) / (2)) + (1))
go to x: ((([sin v] of (dir)) * (radius)) + (x)) y: ((([cos v] of (dir)) * (radius)) + (y))
end
This helps, but can only create a curve from 0 to 90 degrees, and 180 to 270 degrees
Maybe using a minus sign on radius will give you the other two arcs.
Then I am guessing that if one radius is minus and the other positive, that will be the other arc.
- lederniersamourai
- Scratcher
500+ posts
How Can You Create Pen Rounded Rectangles?
no need to play with the sign of the radius.
Just initalise your variable dir as follows:
Then you can try with cornerid=1, or 2, or 3, or 4
Your “dir” is the angle, and you just add 90, 180, 270 to rotate your circle.
You could add an arugment to your special block.
Just initalise your variable dir as follows:
set [cornerid v] to [1]
set [dir v] to ((90) * (cornerid))
Then you can try with cornerid=1, or 2, or 3, or 4
Your “dir” is the angle, and you just add 90, 180, 270 to rotate your circle.
You could add an arugment to your special block.
- -Jkoot4-
- Scratcher
8 posts
How Can You Create Pen Rounded Rectangles?
Thanks! That works great! Now to create a super complex algorithm! no need to play with the sign of the radius.
Just initalise your variable dir as follows:set [cornerid v] to [1]
set [dir v] to ((90) * (cornerid))
Then you can try with cornerid=1, or 2, or 3, or 4
Your “dir” is the angle, and you just add 90, 180, 270 to rotate your circle.
You could add an arugment to your special block.
- NopeNotMe10
- Scratcher
1 post
How Can You Create Pen Rounded Rectangles?
Try this one I slightly modified @lederniersamourai script:
when green flag clicked
point towards [180]
move (100) steps
repeat (9)
move (1) steps
turn cw (10) degrees
end
point in direction (-90)
move (10) steps
repeat (9)
move (1) steps
turn cw (10) degrees
end
move (100) steps
repeat (9)
move (1) steps
turn cw (10) degrees
end
move (10) steps
repeat (9)
move (1) steps
turn cw (10) degrees
end
Last edited by NopeNotMe10 (March 12, 2021 19:43:40)
- ayyyyes10135
- Scratcher
100+ posts
How Can You Create Pen Rounded Rectangles?
Try this one I slightly modified @lederniersamourai script:when green flag clicked
point towards [180]move (100) steps
repeat (9)
move (1) steps
turn cw (10) degrees
endpoint in direction (-90)
move (10) steps
repeat (9)
move (1) steps
turn cw (10) degrees
end
move (100) steps
repeat (9)
move (1) steps
turn cw (10) degrees
end
move (10) steps
repeat (9)
move (1) steps
turn cw (10) degrees
end
This is from 2016. dont necropost. I suggest pressing the new post since last visit button to help others. it gives new topics right at your disposal.
- Discussion Forums
- » Help with Scripts
- » How Can You Create Pen Rounded Rectangles?