Article View: net.micro.cbm
Article #2363C-Power graphics package part 5 of 6 (grafpak2.c)
From: prindle
Date: Tue, 21 Oct 1986 03:21
Date: Tue, 21 Oct 1986 03:21
60 lines
2103 bytes
2103 bytes
From: prindle@NADC
/* Graphics Package - Part 2
** Filename: grafpak2.c
** Author: Mark R. Rinfret
** Date: 12/14/85
** Description:
**
** This is part 2 of a multi-part graphics package, written in C (C-Power)
** for the Commodore 64. The routines contained in this segment are:
**
** arc - draws arcs, line segments, circles, ellipses, polygons
** circle - simplified call to arc
**
**
*/
#include <stdio.h>
#include <strings.h>
#include <math.h>
#include "grafpak.h"
/* Plot an arc.
** Parameters:
** xorigin,yorigin - center point
** xrad,yrad - x and y radii
** start,end - starting, ending point for arc, in degrees
** angl - degrees of rotation (not used yet)
** incr - degrees between steps (FLOAT!); 120.0 yields a triangle
** pen - (0-3) pen number to draw with
*/
arc(xorigin,yorigin,xrad,yrad,
start,end,angl,incr,pen)
unsigned xorigin,yorigin,xrad,yrad,start,end,angl; float incr; unsigned pen;
{
register unsigned cnt,x,y,px,py;
float arad,fstart,fend,fincr,fxrad,fyrad,xo,yo;
cnt = 0;
fincr = incr; /* copy to local */
fyrad = yrad;
fxrad = xrad * aspect; /* adjust to aspect ratio */
xo = xorigin; yo = yorigin;
for (fstart=start,fend=end;fstart<=fend;fstart += fincr) {
arad = fstart/RADCON;
x = xo + fxrad * cos(arad);
y = yo + fyrad * sin(arad);
if (!cnt) pset(x,y,pen);
else line(px,py,x,y,pen);
px=x; py=y;
cnt++;
}
}
/* Plot a circle */
circle(xorigin,yorigin,radius,pen)
unsigned xorigin,yorigin,radius,pen;
{
arc(xorigin,yorigin,radius,radius,
0,360,0,1.0,1);
}
Technical Details
Message-ID:
<3766@caip.RUTGERS.EDU>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!daemonShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!daemon From: prindle@nadc Newsgroups: net.micro.cbm Subject: C-Power graphics package part 5 of 6 (grafpak2.c) Message-ID: <3766@caip.RUTGERS.EDU> Date: Mon, 20-Oct-86 23:21:20 EDT Article-I.D.: caip.3766 Posted: Mon Oct 20 23:21:20 1986 Date-Received: Wed, 22-Oct-86 01:13:54 EDT Sender: daemon@caip.RUTGERS.EDU Organization: Rutgers Univ., New Brunswick, N.J. Lines: 60