home *** CD-ROM | disk | FTP | other *** search
- From: MX%"BJ06@C53000.PETROBRAS.ANRJ.BR" 10-NOV-1994 13:59:13.00
-
- To: MX%"noel@erich.triumf.ca"
-
- CC:
-
- Subj: CLOUDS.CPP for spanky... THANKS!!!!!
-
-
-
- Return-Path: <BJ06@C53000.PETROBRAS.ANRJ.BR>
-
- Received: from fpsp.fapesp.br by Erich.Triumf.CA (MX V4.0-1 VAX) with SMTP;
-
- Thu, 10 Nov 1994 13:59:03 PST
-
- Received: from DECNET-MAIL by fpsp.fapesp.br with PMDF#10108; Thu, 10 Nov 1994
-
- 19:57 BDB (-0200 C)
-
- Date: Thu, 10 Nov 1994 19:57 BDB (-0200 C)
-
- From: "FAUSTO Arinos de Almeida Barbuto (Totxo)"
-
- <BJ06@C53000.PETROBRAS.ANRJ.BR>
-
- Subject: CLOUDS.CPP for spanky... THANKS!!!!!
-
- To: noel@erich.triumf.ca
-
- Message-ID: <5DC38B8160001186@fpsp.fapesp.br>
-
- X-Envelope-to: noel@erich.triumf.ca
-
- X-VMS-To: @NOEL
-
- References: ANSP network HEPnet SPAN Bitnet Internet gateway
-
- Comments: @FPSP.FAPESP.BR - @FPSP.HEPNET - @BRFAPESP.BITNET - .BR gateway
-
-
-
- //+-------------------------------------------------------------------------+
-
- //+ Program CLOUDS.CPP - November 10, 1994 +
-
- //+ +
-
- //+ By Fausto Arinos de Almeida Barbuto, Rio de Janeiro, RJ, BRAZIL +
-
- //+ E-mails: BJ06@C53000.PETROBRAS.ANRJ.BR and barbuto@ax.ibase.org.br +
-
- //+ +
-
- //+ Plots clouds-like fractals (or burnt paper if you plot it with iopt=1) +
-
- //+ The plots are sequential with a delimiting delay of 1.5 seconds. +
-
- //+ Press ESC at any time to fade the screen out and quit. +
-
- //+ +
-
- //+ This program is no more than a PROTOTYPE; please improve it at your own +
-
- //+ taste. ;-) +
-
- //+ REFERENCE: Pickover, Clifford A. "Computers, Pattern, Chaos and Beauty" +
-
- //+ 1990, St.-Martin's Press, pg. 328 +
-
- //+ +
-
- //+ This program is dedicated to Dr. Martin Erdelen and his continuous an- +
-
- //+ xiety in relation to the cummulus-nimbus and stratus-cirrus (?!) :-) +
-
- //+ +
-
- //+ Uses SVGA256.BGI by Jordan Powell Hargrave plus Random Number Generator +
-
- //+ and fade-out routine by Michael E. Sargent and Quintessential Sophistry.+
-
- //+ +
-
- //+ Version for spanky.triumf.ca (142.90.112.1), Vancouver, B.C. Canada. +
-
- //+*************************************************************************+
-
- //+ Some interesting start-up combinations of random cycles (Cmax), radius +
-
- //+ (Rmax) and colouring scheme (iopt): +
-
- //+ +
-
- //+ Cmax = 500 Rmax = 30 iopt = 2 ### Cmax = 1000 Rmax = 5 iopt = 1 +
-
- //+ Cmax = 200 Rmax = 3 iopt = 1 ### Cmax = 250 Rmax = 3 iopt = 2 +
-
- //+ Cmax = 2000 Rmax = 1 iopt = 2 ### Cmax = 50 Rmax = 2 iopt = 2 +
-
- //+ (The last example seems more to be a crystal seen under polarized light)+
-
- //+-------------------------------------------------------------------------+
-
- #include <math.h>
-
- #include <graphics.h>
-
- #include <conio.h>
-
- #include <stdio.h>
-
- #include <stdlib.h>
-
- #include <dos.h>
-
- #include "svga256.h"
-
-
-
- double qsrandom(void);
-
- void fade(void);
-
-
-
- int Video;
-
-
-
- int huge DetectSVGA256()
-
- {
-
- printf("\n Which video mode would you like to use? \n\n");
-
- printf(" 0 - 320x200x256\n");
-
- printf(" 1 - 640x400x256\n");
-
- printf(" 2 - 640x480x256 (Suggested)\n");
-
- printf(" 3 - 800x600x256\n");
-
- printf(" 4 - 1024x768x256\n\n> ");
-
- scanf("%d",&Video);
-
- if ((Video>4) || (Video<0)) Video = 2;
-
- return(Video);
-
- }
-
-
-
- void main(void)
-
- {
-
- int Raio[5000], Cx[5000], Cy[5000], colour, npix, npiy, iopt;
-
- float Tcor, Cor[5000];
-
- int GraphDriver=DETECT, GraphMode;
-
- int xpix, ypix, Cmax, ic, index, dx, dy, Rmax;
-
-
-
- clrscr();
-
- printf("\n Program CLOUDS.CPP, by Fausto A. A. Barbuto");
-
- printf("\n\n Enter the number of random cycles");
-
- printf("\n (Suggested: 500, 1000, 1500, 2000 [Maximum = 5000])");
-
- printf("\n > ");
-
- scanf("%d",&Cmax);
-
- if (Cmax > 5000) Cmax = 2500;
-
-
-
- printf("\n\n Enter maximum length of the radius for a random circle");
-
- printf("\n (Suggested: > 5)");
-
- printf("\n > ");
-
- scanf("%d",&Rmax);
-
- if (Rmax > 640) Rmax = 25;
-
- printf("\n\n Scheme for colours:");
-
- printf("\n From Dark Black to White ---> Enter 1");
-
- printf("\n Covering all the 256 colours ---> Enter 2");
-
- printf("\n > ");
-
- scanf("%d",&iopt);
-
- clrscr();
-
-
-
- installuserdriver("Svga256",DetectSVGA256);
-
- initgraph(&GraphDriver,&GraphMode,"C:\\BORLANDC\\BGI");
-
-
-
- if (Video == 0) {npix = 320; npiy = 200;}
-
- if (Video == 1) {npix = 640; npiy = 400;}
-
- if (Video == 2) {npix = 640; npiy = 480;}
-
- if (Video == 3) {npix = 800; npiy = 600;}
-
- if (Video == 4) {npix =1024; npiy = 768;}
-
-
-
- do {
-
- cleardevice();
-
- //
-
- //--> Creating circles with random position, radius and inner colour.
-
- //
-
- for (ic=1; ic<=Cmax; ic++) {
-
- Cx[ic] = (int)(npix*qsrandom());
-
- Cy[ic] = (int)(npiy*qsrandom());
-
- Raio[ic] = (int)(Rmax*qsrandom());
-
- if (iopt == 1) Cor[ic] = 16.0*qsrandom() + 15.0;
-
- else Cor[ic] = 256.0*qsrandom();
-
- }
-
- //
-
- //--> Scanning all points on the screen.
-
- //
-
- for (xpix=0; xpix<=(npix-1); xpix++) {
-
- for (ypix=0; ypix<=(npiy-1); ypix++) {
-
- index = 0;
-
- Tcor = 0;
-
- //
-
- //------> Checking whether the point is inside a particular circle or not.
-
- //
-
- for (ic=1; ic<=Cmax; ic++) {
-
- dx = xpix - Cx[ic];
-
- dy = ypix - Cy[ic];
-
- if ((int)(dx*dx + dy*dy) <= Raio[ic]*Raio[ic]) {
-
- index++;
-
- Tcor = Tcor + Cor[ic];
-
- }
-
- }
-
- //
-
- //------> Calculating the average intensity of the point.
-
- //
-
- if (index > 0) colour = (int)(Tcor/index);
-
- else colour = 0;
-
- putpixel(xpix,ypix,colour);
-
- }
-
- if (kbhit()) break;
-
- }
-
- delay(1500);
-
- } while (!kbhit());
-
- fade();
-
- closegraph();
-
- }
-
-
-
- //+=================================================+//
-
- //+ Random number generator by Michael E. Sargent. +//
-
- //+=================================================+//
-
-
-
- double qsrandom(void)
-
- {
-
- int random_integer, temp_integer;
-
- double random_double, temp_double;
-
-
-
- random_integer = random(RAND_MAX);
-
- random_double = (double)random_integer / RAND_MAX;
-
- temp_integer = random(30519);
-
- temp_double = (double)temp_integer / 1000000000L;
-
- random_double += temp_double;
-
- return(random_double);
-
- }
-
-
-
- //+======================================================================+
-
- // Fade-out routine by Michael E. Sargent & The Quintessential Sophistry +
-
- //=======================================================================+
-
- #pragma warn -eff
-
- void fade(void)
-
- {
-
- int a, b, p1, p2, p3;
-
-
-
- for (a=0; a<64; a++)
-
- {
-
- for (b=0; b<256; b++)
-
- {
-
- outp(0x3C7, b);
-
- p1 = inp(0x3C9);
-
- p2 = inp(0x3C9);
-
- p3 = inp(0x3C9);
-
- outp (0x3C8, b);
-
- if (p1 > 0) outp(0x3C9, p1 - 1);
-
- else outp(0x3C9, 0);
-
- if (p2 > 0) outp(0x3C9, p2 - 1);
-
- else outp(0x3C9, 0);
-
- if (p3 > 0) outp(0x3C9, p3 - 1);
-
- else outp(0x3C9, 0);
-
- }
-
- delay(100);
-
- }
-
- }
-
- #pragma warn +eff
-
-