/
UnivGraphicsLib.h
227 lines (157 loc) · 5.77 KB
/
UnivGraphicsLib.h
1
//*******************************************************************************//* //* UnivGraphicsLib//* (C) by Mark Sproul//* //* This code is open source like the rest of the arduino source code//* //* UnivGraphicsLib is an attempt to unify the various graphics cards//* available for the Arduino platform.//* //* The intent of this library is to abstract the graphics routines from//* the hardware routines, In that end, it will require only a few routines//* to get a new graphics card up and running.//* //* This is the file that defines what the programmer should use//* //* //*******************************************************************************//#include "UnivGraphicsLib.h"#if !defined(_UNIV_GRAPHICS_H_) && !defined(_TOUCHSCREEN_H_)#define _UNIV_GRAPHICS_H_#ifdef __MWERKS__ //* these are for my test envitronment only#endif#ifndef Wiring_h #include "wiring.h"#endif#ifndef _UNIV_GRAPHICS_DEFS_H_ #include "UnivGraphicsHW_Defs.h"#endif//*******************************************************************************//* color definitions//*******************************************************************************#ifdef _UGL_HARDWARE_1BIT_ #define kCOLOR_White 0 #define kCOLOR_Black 1#endif#ifdef _UGL_HARDWARE_8BIT_ //* this is Picaso color format #define kCOLOR_White 0xff #define kCOLOR_Black 0x00#endif#ifdef __cplusplus extern "C" {#endifboolean UnivGraphicsLib_Init(void);short GetScreenWidth(void);short GetScreenHeight(void);void Set8bitForeColor(unsigned char the8bitColor);typedef struct{ short left; short top; short right; short bottom;} RECT; //* was RECT_T;typedef struct{ unsigned char red; unsigned char green; unsigned char blue;} RGBColor;#define COLOR RGBColortypedef struct{ short x; //* X coordinate short y; //* Y coordinate} POINT; //* Macintosh QuickDraw data typestypedef struct { short v; short h;} Point;//*******************************************************************************//* Global variables accessable to the userextern short gWidth; //* current screen width = processing "width"extern short gHeight; //* current screen height = processing "height"#ifdef __cplusplus} // extern "C"#endif#ifdef _ENABLE_PROCESSING_ROUTINES_typedef struct{ short width; short height; } SCREEN;extern SCREEN screen;//*******************************************************************************//* Processing Language functions//* http://www.processing.org/reference///* routines NOT defined in normal processingvoid setPixel(short xLoc, short yLoc, COLOR *theColor);void erasescreen(void);//* 2D Primitivesvoid point( short xLoc, short yLoc);void line( short x1, short y1, short x2, short y2);void rect(short xLeft, short yTop, short width, short height);void quad( short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4);void triangle( short x1, short y1, short x2, short y2, short x3, short y3);void ellipse( short xLoc, short yLoc, short radx, short rady);void arc(short xCenter, short yCenter, short xDiameter, short yDiameter, float startAngle, float stopAngle);void bezier(short x1, short y1, short cx1, short cy1, short cx2, short cy2, short x2, short y2);void text(char *textString, short xLoc, short yLoc);//* Attributesvoid strokeWeight(short newStrokeWeight);//* Setting//void fill(short fillColor);void fill(uint8_t redValue, uint8_t greenValue, uint8_t blueValue);void noFill(void);//void stroke(short newStrokeColor);void stroke(short redValue, short greenValue, short blueValue);void noStroke(void);void setbcolor(uint8_t redValue, uint8_t greenValue, uint8_t blueValue);void setfcolor(uint8_t redValue, uint8_t greenValue, uint8_t blueValue);//*******************************************************************************#endif#ifdef __cplusplus extern "C" {#endif#ifdef _ENABLE_QUICKDRAW_ROUTINES_//*******************************************************************************//* Macintosh QuickDraw functionstypedef boolean Boolean; void MoveTo(short xLoc, short yLoc); void LineTo(short xLoc, short yLoc); void Move(short deltaX, short deltaY); void Line(short deltaX, short deltaY); void SetCPixel(short xLoc, short yLoc, RGBColor *theColor); void SetCPixel16bit(short xLoc, short yLoc, unsigned short theColor); void FrameRect(RECT *theRect); //* uses foreground color void FillRect(RECT *theRect); //* uses foreground color void EraseRect(RECT *theRect); //* uses background color void FrameOval(RECT *theRect); //* uses foreground color void FillOval(RECT *theRect); //* uses foreground color void EraseOval(RECT *theRect); //* uses background color void SetRGBcolor(RGBColor *theColor, unsigned char redValue, unsigned char greenValue, unsigned char blueValue); void RGBForeColor(RGBColor *theColor); void RGBBackColor(RGBColor *theColor); void PlotIcon(short xLoc, short yLoc, unsigned char *iconDef); void FrameOval(RECT *theRect);//* these routines dont actually do any drawing boolean PtInRect(Point thePoint, const RECT *theRect); boolean POINTinRect(POINT thePoint, const RECT *theRect); void SetRect(RECT *theRect, short left, short top, short right, short bottom); void InsetRect(RECT *theRect, short insetX, short insetY); void OffsetRect(RECT *theRect, short deltaX, short deltaY);//* these are non standard Quickdraw routines in the Quickdraw fashion void DrawChar(short xloc, short yloc, char theChar); void DrawCString(short xloc, short yloc, char *theCstr); void FillOvalFromCenter(short xCenter, short yCenter, short xRadius, short yRadius); void FrameOvalFromCenter(short xCenter, short yCenter, short xRadius, short yRadius); void EraseScreen(void); #endif // _ENABLE_QUICKDRAW_ROUTINES_#ifdef __cplusplus} // extern "C"#endif#endif