Discuss Scratch

-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!
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.

Need a reason to check out my profile?
How about things like:
Simulators?
Games?
Amazing Creations?

This siggy protected by: BKFighter Kumquataway Ltd
Created from processed Kumquat byproduct
Purchase for free* at this website! asdfasdfasdfasdfasdfasdfadfadfadadfasdfas;
-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:
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.
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?

-Jkoot4- wrote:

I have searched but not many answers, however I managed to edit some code:
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.


SHOOT THE SPACE MONSTERS! ….. A game everyone can play! Bright colors, bonky sounds!
THE 12 BALLS OF CRAZY AL ……. New scrolling adventure game!

-Jkoot4-
Scratcher
8 posts

How Can You Create Pen Rounded Rectangles?

footsocktoe wrote:

-Jkoot4- wrote:

I have searched but not many answers, however I managed to edit some code:
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.
No, that only gives an arc of 180 to 270 . If it is positive it gives a arc from 0 to 90
footsocktoe
Scratcher
1000+ posts

How Can You Create Pen Rounded Rectangles?

-Jkoot4- wrote:

footsocktoe wrote:

-Jkoot4- wrote:

I have searched but not many answers, however I managed to edit some code:
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.
No, that only gives an arc of 180 to 270 . If it is positive it gives a arc from 0 to 90

Then I am guessing that if one radius is minus and the other positive, that will be the other arc.


SHOOT THE SPACE MONSTERS! ….. A game everyone can play! Bright colors, bonky sounds!
THE 12 BALLS OF CRAZY AL ……. New scrolling adventure game!

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:
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?

lederniersamourai wrote:

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.
Thanks! That works great! Now to create a super complex algorithm!
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?

NopeNotMe10 wrote:

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


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.

YOOOOOOO 100 POSTS LETS GO

________________________________________

give me ideas on what to create. im so bored every day. yeah i should probably doing my project but NO IDEAS!!!

Powered by DjangoBB