This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-09-27 21:13:30

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Smalltalk Circle

I would like to know how to draw a circle in a Morph's

Code:

drawOn: aCanvas

method. I don't really get how the drawing works, so I know absolutely nothing about rendering something on the screen. Thanks!  smile


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#2 2010-09-27 21:28:37

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Smalltalk Circle

I see a post by nXIII in the future of this thread.[/psychic]

I don't know. I'll look into it.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3 2010-09-27 22:12:41

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Smalltalk Circle

ScratchReallyROCKS wrote:

I see a post by nXIII in the future of this thread.[/psychic]

Ohhhhhhhhhhh yeaya!  big_smile

SRR wrote:

I don't know. I'll look into it.

Thanks!  smile


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#4 2010-09-27 22:55:59

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Smalltalk Circle

Jwosty wrote:

ScratchReallyROCKS wrote:

I see a post by nXIII in the future of this thread.[/psychic]

Ohhhhhhhhhhh yeaya!  big_smile
It's almost impossible for it not to happen.[/stupid]

SRR wrote:

I don't know. I'll look into it.

Thanks!  smile

Mwhaha!


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#5 2010-09-27 23:09:28

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Smalltalk Circle

bbbeb wrote:

Jwosty wrote:

ScratchReallyROCKS wrote:

I see a post by nXIII in the future of this thread.[/psychic]

Ohhhhhhhhhhh yeaya!  big_smile
It's almost impossible for it not to happen.[/stupid]

SRR wrote:

I don't know. I'll look into it.

Thanks!  smile

Mwhaha!

?!


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#6 2010-09-28 12:09:49

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Smalltalk Circle

well, i guess your psychic mind was wrong. there's me instead.  smile

the easy way is probably to create a new method (and call it through the draw on) to add an ellipseMorph to the morph you're drawing using something that looks like

| circle |
circle _ EllipseMorph new.
circle extent: X@Y.
circle position: self position.
circle color: aColor.
self addMorph: circle

get it?

Offline

 

#7 2010-09-28 15:15:05

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Smalltalk Circle

MUHUHAHAHA You were right!

Anyway, just use the #fillOval:color: method on any Canvas.
ex:
aCanvas fillOval: (self position extent: 20 asPoint) color: color. "This fills a 20x20 oval (circle in this case) at the morph's position with the morph's color."


nXIII

Offline

 

#8 2010-09-28 15:20:27

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Smalltalk Circle

MUHAHAHAHAHAHAHA! ScratchReallyROCKS is psychic!  lol
To save a few characters, 20@20 is quicker than 20 asPoint. But I don't know why you'd want to save a few characters' typing. And also, I'm probably wrong as usual.  big_smile


/* No comment */

Offline

 

#9 2010-09-28 15:55:09

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Smalltalk Circle

TheSuccessor wrote:

MUHAHAHAHAHAHAHA! ScratchReallyROCKS is psychic!  lol
To save a few characters, 20@20 is quicker than 20 asPoint. But I don't know why you'd want to save a few characters' typing. And also, I'm probably wrong as usual.  big_smile

well you know what? i don't think so! MUAHAHA nXIII will give the verdict  big_smile

Offline

 

#10 2010-09-28 19:14:00

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Smalltalk Circle

TheSuccessor wrote:

MUHAHAHAHAHAHAHA! ScratchReallyROCKS is psychic!  lol
To save a few characters, 20@20 is quicker than 20 asPoint. But I don't know why you'd want to save a few characters' typing. And also, I'm probably wrong as usual.  big_smile

No, I think you're right, it just might be easier to change the radius (one place instead of two)


nXIII

Offline

 

#11 2010-09-28 21:12:20

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Smalltalk Circle

nXIII wrote:

MUHUHAHAHA You were right!

Anyway, just use the #fillOval:color: method on any Canvas.
ex:
aCanvas fillOval: (self position extent: 20 asPoint) color: color. "This fills a 20x20 oval (circle in this case) at the morph's position with the morph's color."

Oh yay! Thanks!  lol


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#12 2010-09-28 22:22:14

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Smalltalk Circle

Uh oh... One more thing: It seems that the default bounds or whatever is called is something like 50@50... How do I change this?  hmm


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#13 2010-09-29 14:38:48

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Smalltalk Circle

Jwosty wrote:

Uh oh... One more thing: It seems that the default bounds or whatever is called is something like 50@50... How do I change this?  hmm

override #initialize to be something like this:

initialize
super initialize. "THIS LINE IS VERY IMPORTANT!"
self extent: 20@20. "Or something else."


nXIII

Offline

 

#14 2010-09-29 15:41:47

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Smalltalk Circle

nXIII wrote:

super initialize. "THIS LINE IS VERY IMPORTANT!"

What does that do?


You can now reach me on Twitter @johnnydean1_

Offline

 

#15 2010-09-29 17:22:45

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Smalltalk Circle

johnnydean1 wrote:

nXIII wrote:

super initialize. "THIS LINE IS VERY IMPORTANT!"

What does that do?

calls the #initialize method of the superclass.

Last edited by nXIII (2010-09-29 17:23:02)


nXIII

Offline

 

#16 2010-09-29 18:25:47

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Smalltalk Circle

nXIII wrote:

Jwosty wrote:

Uh oh... One more thing: It seems that the default bounds or whatever is called is something like 50@50... How do I change this?  hmm

override #initialize to be something like this:

initialize
super initialize. "THIS LINE IS VERY IMPORTANT!"
self extent: 20@20. "Or something else."

Thanks!  smile  In case you are wondering what this is for, I am making an iPhone app in Pharo Smalltalk.


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#17 2010-09-29 20:51:17

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Smalltalk Circle

Another thing: how do you clear all the pen trails in the world?


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#18 2010-09-30 15:06:41

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Smalltalk Circle

Jwosty wrote:

Another thing: how do you clear all the pen trails in the world?

in the World? What are you using to MAKE the pen drawings?


nXIII

Offline

 

#19 2010-09-30 19:05:05

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Smalltalk Circle

nXIII wrote:

Jwosty wrote:

Another thing: how do you clear all the pen trails in the world?

in the World? What are you using to MAKE the pen drawings?

Yes, and... wait a second. Dang! I almost forgot that the Smalltalk pen trails are different than it's Scratch counterpart...  hmm  hmm...

This is what I am using for the orbiting algorithm (I am making my Scratch project, WhirlyGigs into an iPhone app with Smalltalk):

Code:

xPos := theta sin * 50.
            yPos := theta cos * 50.
            self position: xPos @ yPos.
            theta := theta + anInteger.
            (Delay forMilliseconds: 100) wait

vs the my project's algorithm. You can see it here.


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#20 2010-09-30 20:26:52

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Smalltalk Circle

Jwosty wrote:

nXIII wrote:

Jwosty wrote:

Another thing: how do you clear all the pen trails in the world?

in the World? What are you using to MAKE the pen drawings?

Yes, and... wait a second. Dang! I almost forgot that the Smalltalk pen trails are different than it's Scratch counterpart...  hmm  hmm...

This is what I am using for the orbiting algorithm (I am making my Scratch project, WhirlyGigs into an iPhone app with Smalltalk):

Code:

xPos := theta sin * 50.
            yPos := theta cos * 50.
            self position: xPos @ yPos.
            theta := theta + anInteger.
            (Delay forMilliseconds: 100) wait

vs the my project's algorithm. You can see it here.

So what are you using for pen trails?


nXIII

Offline

 

#21 2010-09-30 21:40:48

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Smalltalk Circle

nXIII wrote:

Jwosty wrote:

nXIII wrote:

in the World? What are you using to MAKE the pen drawings?

Yes, and... wait a second. Dang! I almost forgot that the Smalltalk pen trails are different than it's Scratch counterpart...  hmm  hmm...

This is what I am using for the orbiting algorithm (I am making my Scratch project, WhirlyGigs into an iPhone app with Smalltalk):

Code:

xPos := theta sin * 50.
            yPos := theta cos * 50.
            self position: xPos @ yPos.
            theta := theta + anInteger.
            (Delay forMilliseconds: 100) wait

vs the my project's algorithm. You can see it here.

So what are you using for pen trails?

I don't know now... I'll figure it out though. Thanks for all your help!  smile


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#22 2010-10-01 14:52:12

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Smalltalk Circle

Jwosty wrote:

nXIII wrote:

Jwosty wrote:


Yes, and... wait a second. Dang! I almost forgot that the Smalltalk pen trails are different than it's Scratch counterpart...  hmm  hmm...

This is what I am using for the orbiting algorithm (I am making my Scratch project, WhirlyGigs into an iPhone app with Smalltalk):

Code:

xPos := theta sin * 50.
            yPos := theta cos * 50.
            self position: xPos @ yPos.
            theta := theta + anInteger.
            (Delay forMilliseconds: 100) wait

vs the my project's algorithm. You can see it here.

So what are you using for pen trails?

I don't know now... I'll figure it out though. Thanks for all your help!  smile

I think Squeak has a built-in pen mechanism, the Pen class in the Graphics categories. The class has some testing/example methods for using it. Good luck!  smile


nXIII

Offline

 

#23 2010-10-02 05:33:35

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Smalltalk Circle

Jwosty wrote:

Code:

xPos := theta sin * 50.
            yPos := theta cos * 50.
            self position: xPos @ yPos.
            theta := theta + anInteger.
            (Delay forMilliseconds: 100) wait

The Point class has something like this already built in:

Code:

tempPoint := Point r: (number) degrees: (number).
xPos := tempPoint x.
yPos := tempPoint y.
(Delay forMilliseconds: 100) wait

/* No comment */

Offline

 

Board footer