Re: [BLACKBOX] Modula-2 LineDrawing source?

From: [at]} <CFB>
Date: Sun, 9 Mar 2008 13:31:03 +1030

----boundary-LibPST-iamunique-4894031_-_-
Content-type: text/plain

> -----Original Message-----
> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
> Bob Walkden
> Sent: Saturday, 8 March 2008 8:35 PM
> To: BLACKBOX{([at]})nowhere.xy
> Subject: [BLACKBOX] Modula-2 LineDrawing source?
>
> Hi,
>
> does anyone know where I can get a copy of the source code of the
> LineDrawing implementation module, as described in Prof. Wirth's
> 'Programming in Modula-2' and 'Algorithms and Data Structures'?
>
> I'd like to see how the line procedure is implemented. The interface
> from the definition module is:
>
> PROCEDURE line( d, n: INTEGER );
> (* draw a line of length n in direction d (angle = 45*d degrees ) *).
>

The following (*untested by me *) is from an implementation of Modula-2 for
the Amiga

http://aminet.net/package/dev/m2/Turbo_Part1

http://aminet.net/package/dev/m2/Turbo_Part2

(NOTE: The comment is not mine - it was in the original):

(* ***********************************************************************
*)
(* A really *sad* line drawing procedure by N. Wirth.
*)
(* ***********************************************************************
*)

VAR
  Px, Py : REAL; (* Stuff needed by line(). *)

PROCEDURE rad(deg: INTEGER): REAL;
CONST
  pi = 3.14159265;
BEGIN
  RETURN FLOAT(deg)*pi/180.0;
END rad;

PROCEDURE line(d, n: INTEGER);
(* draw a line of length n in direction d (angle = 45*d degrees) *)
VAR
  fd, fn : REAL;
  oldx, oldy : REAL;
BEGIN
  fd := rad(45*d+90);
  fn := FLOAT(n);
  oldx := Px;
  oldy := Py;
  Px := oldx + fn * MathIEEESingTrans.IEEESPCos(fd);
  Py := oldy - fn * MathIEEESingTrans.IEEESPSin(fd);
  DrawLine(TRUNC(oldx), TRUNC(oldy), TRUNC(Px), TRUNC(Py));
END line;

> I've googled till my fingers bleed (almost), but can't find it.
>

Next time do what guitarists do and soak your fingers in vinegar ;-)

Regards,
Chris

Chris Burrows
CFB Software
http://www.cfbsoftware.com/modula2


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-4894031_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwID4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS1c
cGFyDQo+IEZyb206IEJsYWNrQm94IFttYWlsdG86QkxBQ0tCT1hATElTVFMuT0JFUk9OLkNIXSBP
biBCZWhhbGYgT2YgXHBhcg0KPiBCb2IgV2Fsa2RlblxwYXINCj4gU2VudDogU2F0dXJkYXksIDgg
TWFyY2ggMjAwOCA4OjM1IFBNXHBhcg0KPiBUbzogQkxBQ0tCT1hATElTVFMuT0JFUk9OLkNIXHBh
cg0KPiBTdWJqZWN0OiBbQkxBQ0tCT1hdIE1vZHVsYS0yIExpbmVEcmF3aW5nIHNvdXJjZT9ccGFy
DQo+IFxwYXINCj4gSGksXHBhcg0KPiBccGFyDQo+IGRvZXMgYW55b25lIGtub3cgd2hlcmUgSSBj
YW4gZ2V0IGEgY29weSBvZiB0aGUgc291cmNlIGNvZGUgb2YgdGhlXHBhcg0KPiBMaW5lRHJhd2lu
ZyBpbXBsZW1lbnRhdGlvbiBtb2R1bGUsIGFzIGRlc2NyaWJlZCBpbiBQcm9mLiBXaXJ0aCdzXHBh
cg0KPiAnUHJvZ3JhbW1pbm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g0KTmV4
dCB0aW1lIGRvIHdoYXQgZ3VpdGFyaXN0cyBkbyBhbmQgc29hayB5b3VyIGZpbmdlcnMgaW4gdmlu
ZWdhciA7LSlccGFyDQpccGFyDQpSZWdhcmRzLFxwYXINCkNocmlzXHBhcg0KXHBhcg0KQ2hyaXMg
QnVycm93c1xwYXINCkNGQiBTb2Z0d2FyZVxwYXINCmh0dHA6Ly93d3cuY2Zic29mdHdhcmUuY29t
L21vZHVsYTJccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3JpYmUsIHNlbmQg
YSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNFUlZATElTVFMu
T0JFUk9OLkNIXH19AExpbg==
----boundary-LibPST-iamunique-4894031_-_---
Received on Sun Mar 09 2008 - 04:01:03 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:58 UTC