Hi!
Is anybody remember basic? I am a beginner and cant understand how to make this program in Smalltalk. I found it in old magazine from 80-th years :) So, this is the program. It makes interest graphics. 10 INPUT "Enter a number"; N 20 DIM X(N), Y(N) 30 R = 120 40 DT = 2 * 3,1416 /N 50 T = 0 60 FOR I = 1 TO N 70 T = T + DT 80 X(I) = 160 + R*COS (T): Y(I) = 125 - R*SIN (T) 90 NEXT I 95 CLSZ 100 FOR I = 1 TO N-1 110 FOR J= I+1 TO N 120 PLOT X(I), Y(I), 3 130 LINE X(J), Y(J) 140 NEXT J 150 NEXT I 160 STOP Some remarks can help. PLOT+LINE is BitBlt>>drawFrom:to:. DIM X(N), Y(N) is PointArray instance. If anobody make it pls give me a code to see how. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
kirand <kirandev <at> ukr.net> writes:
> > Hi! > > Is anybody remember basic? > > I am a beginner and cant understand how to make this program in Smalltalk. I > found it in old magazine from 80-th years :) > So, this is the program. It makes interest graphics. > > 10 INPUT "Enter a number"; N > 20 DIM X(N), Y(N) > 30 R = 120 > 40 DT = 2 * 3,1416 /N > 50 T = 0 > 60 FOR I = 1 TO N > 70 T = T + DT > 80 X(I) = 160 + R*COS (T): Y(I) = 125 - R*SIN (T) > 90 NEXT I > 95 CLSZ > 100 FOR I = 1 TO N-1 > 110 FOR J= I+1 TO N > 120 PLOT X(I), Y(I), 3 > 130 LINE X(J), Y(J) > 140 NEXT J > 150 NEXT I > 160 STOP > > Some remarks can help. PLOT+LINE is BitBlt>>drawFrom:to:. DIM X(N), Y(N) is > PointArray instance. > > If anobody make it pls give me a code to see how. > First attempt: draw directly on Display | n xy r dt brush | n := FillInTheBlank request: 'Enter a number' initialAnswer: ''. n := Number readFrom: n. "Transform the String into a Number" xy := Array new: n. dt := Float twoPi / n. r := 120. 1 to: n do: [:i | "Mind the order or operations here, Smalltalk interprets left to right" xy at: i put: ((i*dt) cos * r +160) @ ((i*dt) sin negated * r + 125)]. brush := Form extent: 3 @ 3. brush fillBlack. 1 to: n-1 do: [:i | i+1 to: n do: [:j | Display drawLine: brush from: (xy at: i) to: (xy at: j) clippingBox: Display boundingBox rule: Form paint fillColor: nil]]. Second attempt: draw on a Form, copy the Form on Display, restore the Display after 10 seconds. | n xy r dt form brush | n := (FillInTheBlank request: 'Enter a number' initialAnswer: '') asNumber. dt := Float twoPi / n. r := 120. xy := (1 to: n) collect: [:i | ((i*dt) cos * r +160) @ ((i*dt) sin negated * r + 125)]. form := Form extent: 300@300. brush := Form extent: 1 @ 1. brush fillBlack. 1 to: n-1 do: [:i | i+1 to: n do: [:j | form drawLine: brush from: (xy at: i) to: (xy at: j) clippingBox: form boundingBox rule: Form paint fillColor: nil]]. form displayOn: Display. [(Delay forSeconds: 10) wait. Display restore] fork Nicolas _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by kirand
On 04.07.2010, at 11:36, kirand wrote:
> Hi! > > Is anybody remember basic? > > I am a beginner and cant understand how to make this program in Smalltalk. I found it in old magazine from 80-th years :) > So, this is the program. It makes interest graphics. > > 10 INPUT "Enter a number"; N > 20 DIM X(N), Y(N) > 30 R = 120 > 40 DT = 2 * 3,1416 /N > 50 T = 0 > 60 FOR I = 1 TO N > 70 T = T + DT > 80 X(I) = 160 + R*COS (T): Y(I) = 125 - R*SIN (T) > 90 NEXT I > 95 CLSZ > 100 FOR I = 1 TO N-1 > 110 FOR J= I+1 TO N > 120 PLOT X(I), Y(I), 3 > 130 LINE X(J), Y(J) > 140 NEXT J > 150 NEXT I > 160 STOP > > Some remarks can help. PLOT+LINE is BitBlt>>drawFrom:to:. DIM X(N), Y(N) is PointArray instance. > > If anobody make it pls give me a code to see how. Display restoreAfter: [Pen new mandala: (FillInTheBlank request: 'Enter a Number') asInteger] - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Nicolas Cellier
"nicolas cellier" <[hidden email]> сообщил/сообщила в новостях следующее: news:[hidden email]... > First attempt: draw directly on Display Maybe I choose wrong method (drawFrom:to:) or there is a mistake in a BASIC program, but a picture looks different. See here: http://s1.bild.me/bilder/210510/4182103pattern.JPG _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
kirand <kirandev <at> ukr.net> writes:
> > > "nicolas cellier" <nicolas.cellier.aka.nice <at> gmail.com> сообщил/сообщила в > новостях следующее: news:loom.20100704T192902-992 <at> post.gmane.org... > > > First attempt: draw directly on Display > > Maybe I choose wrong method (drawFrom:to:) or there is a mistake in a BASIC > program, but a picture looks different. See here: > > http://s1.bild.me/bilder/210510/4182103pattern.JPG > Oh, then I would say try to draw from: (xy at: i) to: (xy at: i) + (xy at: j). Nicolas _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |