🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #1072

Re: Arcs in Interviews

#1072
From: Glenn P. Parker
Date: Mon, 06 May 1991 14:47
75 lines
2893 bytes
In article <9105031422.AA14732@applga.aa.cad.slb.com> applga!mcginnis@SHARKEY.CC.UMICH.EDU (Brian McGinnis) writes:
> Does Interviews have an easy way of drawing arcs or has anyone
> implemented arcs in intervies.

I was able to extend the Painter class (in InterViews 2.6) to handle arcs
rather cleanly.  That is, I didn't have to modify the base Painter class at
all (thanks to the rep classes).  The whole thing is small enough that I
might as well post it.

// Begin ArcPainter.H
#include <InterViews/painter.h>

class Canvas;

class ArcPainter : public Painter
{
  public:
    ArcPainter();
    ArcPainter(Painter*);
    ~ArcPainter();

    void Arc(Canvas*, Coord cx, Coord cy, unsigned int radius,
	     int angle, int delta);
    void Arc(Canvas*, Coord left, Coord bottom, Coord right, Coord top,
	     int angle, int delta);
};
// End ArcPainter.H

// Begin ArcPainter.C
#include "ArcPainter.H"
#include <InterViews/canvas.h>
#include <InterViews/painter.h>
#include <InterViews/X11/painterrep.h>
#include <InterViews/X11/worldrep.h>
#include <InterViews/X11/Xlib.h>

extern "C"
{
    int XDrawArc(Display*, Drawable, GC,
		 int x, int y, unsigned int w, unsigned int h, int a1, int a2);
}


ArcPainter::ArcPainter() {}

ArcPainter::~ArcPainter() {}

ArcPainter::ArcPainter(Painter* p) : Painter(p) {}

void ArcPainter::Arc(Canvas* c, Coord x, Coord y,
		     unsigned int radius, int angle, int delta)
{
    const int left = x - radius;
    const int xtop = c->Height() - 1 - (y + radius);
    const unsigned int width = 2 * radius;
    const unsigned int height = width;

    XDrawArc(_world->display(), (Drawable)c->Id(), Rep()->dashgc,
	     left, xtop, width, height, angle, delta);
}

void ArcPainter::Arc(Canvas* c, Coord left, Coord bottom,
		     Coord right, Coord top, int angle, int delta)
{
    int xtop = c->Height() - 1 - top;

    XDrawArc(_world->display(), (Drawable)c->Id(), Rep()->dashgc,
	     left, xtop, right - left + 1, top - bottom + 1, angle, delta);
}
// End ArcPainter.C

--
Glenn P. Parker       glenn@bitstream.com       Bitstream, Inc.
                      uunet!huxley!glenn        215 First Street
                      BIX: parker               Cambridge, MA 02142-1270
Technical Details
Message-ID: <GLENN.91May6104721@huxley.huxley.bitstream.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!huxley!glenn
References: <9105031422.AA14732@applga.aa.cad.slb.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!huxley!glenn
From: glenn@huxley.huxley.bitstream.com (Glenn P. Parker)
Newsgroups: comp.windows.interviews
Subject: Re: Arcs in Interviews
Message-ID: <GLENN.91May6104721@huxley.huxley.bitstream.com>
Date: 6 May 91 14:47:21 GMT
References: <9105031422.AA14732@applga.aa.cad.slb.com>
Sender: glenn@huxley.UUCP
Reply-To: <glenn@bitstream.com> (Glenn Parker)
Distribution: comp
Organization: Bitstream, Inc.
Lines: 75
In-reply-to: applga!mcginnis@SHARKEY.CC.UMICH.EDU's message of 3 May 91 14:22:35 GMT