2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
7 #include <intuition/intuition.h>
8 #include <graphics/gfx.h>
9 #include <graphics/rpattr.h>
10 #include <cybergraphx/cybergraphics.h>
11 #include <gadgets/colorwheel.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
14 #include <proto/graphics.h>
15 #include <proto/cybergraphics.h>
16 #include <proto/colorwheel.h>
17 #include <proto/intuition.h>
23 #define SCREENWIDTH 300
24 #define SCREENHEIGHT 200
25 #define SCREENCY (SCREENHEIGHT / 2)
28 /***********************************************************************************/
30 struct IntuitionBase
*IntuitionBase
;
31 struct GfxBase
*GfxBase
;
32 struct Library
*CyberGfxBase
;
33 struct Library
*ColorWheelBase
;
38 ULONG cgfx_coltab
[256];
41 /***********************************************************************************/
43 static void cleanup(char *msg
)
47 printf("TrueColorPens: %s\n",msg
);
50 if (win
) CloseWindow(win
);
52 if (scr
) UnlockPubScreen(0, scr
);
54 if (ColorWheelBase
) CloseLibrary(ColorWheelBase
);
55 if (CyberGfxBase
) CloseLibrary(CyberGfxBase
);
56 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
57 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
62 /***********************************************************************************/
64 static void openlibs(void)
66 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
68 cleanup("Can't open intuition.library V39!");
71 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
73 cleanup("Can't open graphics.library V39!");
76 if (!(CyberGfxBase
= OpenLibrary("cybergraphics.library",0)))
78 cleanup("Can't open cybergraphics.library!");
81 if (!(ColorWheelBase
= OpenLibrary("gadgets/colorwheel.gadget",0)))
83 cleanup("Can't open colorwheel.gadget!");
88 /***********************************************************************************/
90 static void getvisual(void)
92 if (!(scr
= LockPubScreen(NULL
)))
94 cleanup("Can't lock pub screen!");
97 if (GetBitMapAttr(scr
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
99 cleanup("Need hi or true color screen!");
103 /***********************************************************************************/
105 static void makewin(void)
107 win
= OpenWindowTags(NULL
, WA_CustomScreen
, (IPTR
)scr
,
108 WA_InnerWidth
, SCREENWIDTH
,
109 WA_InnerHeight
, SCREENHEIGHT
,
110 WA_Title
, (IPTR
)"TrueColorPens: Press SPACE!",
112 WA_DepthGadget
, TRUE
,
113 WA_CloseGadget
, TRUE
,
115 WA_GimmeZeroZero
, TRUE
,
116 WA_IDCMP
, IDCMP_CLOSEWINDOW
|
120 if (!win
) cleanup("Can't open window");
125 /***********************************************************************************/
128 #define KC_RIGHT 0x4E
132 #define KC_SPACE 0x40
134 /***********************************************************************************/
136 static void getevents(void)
138 struct IntuiMessage
*msg
;
140 while ((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
144 case IDCMP_CLOSEWINDOW
:
150 WORD code
= msg
->Code
& ~IECODE_UP_PREFIX
;
152 Keys
[code
] = (code
== msg
->Code
) ? 1 : 0;
158 ReplyMsg((struct Message
*)msg
);
163 /***********************************************************************************/
165 static void action(void)
171 struct AreaInfo area_info
;
172 UBYTE area_buffer
[MAX_VECTORS
* 5];
174 struct TmpRas tmp_ras
;
176 rp
->AreaInfo
= &area_info
;
177 raster
= AllocRaster(SCREENWIDTH
, SCREENHEIGHT
);
180 InitTmpRas(&tmp_ras
, raster
, RASSIZE(SCREENWIDTH
, SCREENHEIGHT
));
181 rp
->TmpRas
= &tmp_ras
;
188 struct ColorWheelHSB cwhsb
= {hue
, 0xFFFFFFFF, 0xFFFFFFFF};
189 struct ColorWheelRGB cwrgb
;
193 ConvertHSBToRGB(&cwhsb
, &cwrgb
);
195 rgb
= (cwrgb
.cw_Red
& 0xFF000000) >> 8;
196 rgb
+= (cwrgb
.cw_Green
& 0xFF000000) >> 16;
197 rgb
+= (cwrgb
.cw_Blue
& 0xFF000000) >> 24;
199 SetRPAttrs(rp
, RPTAG_FgColor
, rgb
,
200 RPTAG_BgColor
, 0xFFFFFF - rgb
,
201 RPTAG_PenMode
, FALSE
,
208 WritePixel(rp
, x
, y
);
209 WritePixel(rp
, x
+ 1, y
);
210 WritePixel(rp
, x
, y
+ 1);
211 WritePixel(rp
, x
+ 1, y
+ 1);
217 Text(rp
, "Text JAM1", 4);
223 Text(rp
, "Text JAM2", 4);
228 RectFill(rp
, x
, y
, x
+ 30, y
+ 30);
235 Draw(rp
, x
+ 30, y
+ 30);
242 DrawEllipse(rp
, x
, y
, 30, 30);
246 InitArea(&area_info
, area_buffer
, MAX_VECTORS
);
247 AreaEllipse(rp
, x
, y
, 30, 30);
257 mode
= (mode
+ 1) % 7;
261 x
+= dx
; if ((x
> SCREENWIDTH
) || (x
< 0)) dx
= -dx
;
262 y
+= dy
; if ((y
> SCREENHEIGHT
) || (y
< 0)) dy
= -dy
;
266 } /* while(!Keys[KC_ESC]) */
269 FreeRaster(raster
, SCREENWIDTH
, SCREENHEIGHT
);
272 /***********************************************************************************/
282 return 0; /* keep compiler happy */
285 /***********************************************************************************/