Thread View: net.micro.cbm
1 messages
1 total messages
Started by prindle
Tue, 21 Oct 1986 03:22
C-Power graphics package part 6 of 6 (gdriver.c) (sample application)
Author: prindle
Date: Tue, 21 Oct 1986 03:22
Date: Tue, 21 Oct 1986 03:22
135 lines
3389 bytes
3389 bytes
From: prindle@NADC
/* Graphics Driver
** Filename: gdriver.c
** Author: Mark R. Rinfret
** Date: 12/14/85
** Description:
**
** This package serves as a driver to demo the features implemented in the
** grafpak graphics routines package.
**
*/
#include <stdio.h>
#include <strings.h>
#include <math.h>
#define RADCON 57.2957795 /* degrees to radians factor */
main()
{
register unsigned base;
register unsigned i,j;
base = 40960; /* bitmap in upper 8k of bank 2 */
highmem(32768);
ginit(); /* initialize graphics package */
graphics(0,1);
puts("This is text mode - RETURN to continue.\n");
delay();
test1(); /* test hi-res graphics */
test2(); /* test multi-color mode */
graphics(0,0);
puts("Back to text mode.\n");
}
/* Test hi-res graphics */
test1()
{
register unsigned a,b,d,i,x,x1,y,r;
register char c,*p;
float r2,x2,incr;
graphics(1,1); /* hi-res w/clear */
spintext(160,100,"Hi-res");
graphics(1,1);
line(0,0,319,199,1); /* upper left to lower right */
line(0,199,319,0,1); /* lower left to upper right */
line(0,100,319,100,1); /* horizontal axis */
line(160,0,160,199,1); /* vertical axis */
/* Circles */
circle(160,100,80,1);
/* Diagonal lines through center */
line(0,0,319,199,1);
line(319,0,0,199,1);
/* Horizontal ellipse */
arc(160,100,100,50,0,360,0,1.0,1);
/* Vertical ellipse */
arc(160,100,50,100,0,360,0,1.0,1);
delay();
/* Polygons */
graphics(1,1);
colors(-1,-1,5,-1,-1);
drawtext(32,0,"Polygons using 'arc'",0,1);
colors(-1,-1,6,-1,-1);
arc(48,48,40,40,0,360,0,120.0,1); /* triangle */
drawtext(0,88,"Triangle",0,1);
colors(-1,-1,7,-1,-1); /* yellow */
arc(240,48,40,40,0,360,0,90.0,1); /* square */
drawtext(200,88,"Square",0,1);
colors(-1,-1,3,-1,-1); /* cyan */
arc(80,144,40,40,0,360,0,60.0,1); /* hexagon */
drawtext(20,192,"Hexagon",0,1);
colors(-1,-1,2,-1,-1); /* red */
arc(240,144,40,40,0,360,0,45.0,1); /* octagon */
drawtext(200,192,"Octagon",0,1);
delay();
}
test2()
{
register unsigned pen,x,y,xx,yy,s;
graphics(2,1);
colors(0,1,2,5,6);
spintext(80,100,"Multicolor");
graphics(2,1); /* clear screen */
pen = 1;
for (s=10;s<=80;s+=10) { /* boxes in boxes */
x=80-(s/2);
y=100-(s/2);
line(x,y,x+s,y,pen);
line(x+s,y,x+s,y+s,pen);
line(x+s,y+s,x,y+s,pen);
line(x,y+s,x,y,pen);
if (++pen == 4) pen=1;
}
circle(80,100,70,1);
delay();
}
delay()
{
for (;getchar() != '\n';);
}
/* Draw text rotated about an x,y coordinate */
spintext(x,y,s)
unsigned x,y; char *s;
{
float angle;
for (angle=0.0;angle < 360.0; angle += 45.0)
drawtext(x,y,s,angle,1);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads