Thank you so much for the information about the . instead of , and for the aPointPair first to aPointPair last. They look like they are going to be a big help.
When I made the changes, I received the following error message with either of the workspace instructions shown below. MyMorph(Object)>>doesNotUnderstand: [] in MyMorph>>drawOn: {[:aPointPair | self drawLineOn: aCanvas from: aPointPair first to: aPo...]}
This is my current code: In Workspace I type: (MyMorph faces: 2) openInWorld Or MyMorph new openInWorld
My messages are:
initialize super initialize. "taken directly from SBE" self extent: 50@50. self useGradientFill; borderWidth: 2; useRoundedCorners. self setBorderStyle: #complexRaised. self fillStyle direction: self extent. self color: Color green. dieValue := 1. faces := 6. isStopped := false.
and
drawOn: aCanvas super drawOn: aCanvas. (self perform: ('face', dieValue asString) asSymbol) perform: [:aPointPair | self drawLineOn: aCanvas from: aPointPair first to: aPointPair second]
and
drawLineOn: aCanvas from: aPoint to: anotherPoint aCanvas line: aPoint to: anotherPoint width: 2 color: Color black.
And
face1 {{2@2. 2@10}. {2@2. 10@2}. {10@10. 2@10}. {10@10. 10@2}}
And
face2 {{2@2. 2@10}. {2@2. 10@2}. {10@10. 2@10}. {10@10. 10@2}}
-----Original Message----- From: beginners-bounces@lists.squeakfoundation.org [mailto:beginners-bounces@lists.squeakfoundation.org] On Behalf Of Bert Freudenberg Sent: Friday, October 30, 2009 2:00 PM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] Drawing a line on a morph
On 30.10.2009, at 11:52, Christine Wolfe wrote:
drawOn: aCanvas super drawOn: aCanvas. (self perform: ('face', dieValue asString) asSymbol) do: [{:aPoint, anotherPoint} | self drawLineOn: aCanvas from: aPoint to: anotherPoint]
In my version of Squeak this won't even compile.
How did you accept that method?
The curly-bracket array notation can not be used to extract multiple arguments. Instead, you would have to do something like this:
[:aPointPair | self drawLineOn: aCanvas from: aPointPair first to: aPointPair second]
And secondly, this expression is valid syntactically but does not do what you might expect:
face1 ^{{2@2, 2@10}, {2@2, 10@2}, {10@10, 2@10}, {10@10, 10@2}}
In non-literal Array notation, expressions must be separated by periods, not commas:
{{2@2. 2@10}. {2@2. 10@2}. {10@10, 2@10}. {10@10. 10@2}}
The way you would verify a line like this or your's above is you simply select it and press cmd-p so it will print the result. You can do this in any browser or workspace.
- Bert -
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners