Graphics

CGrGlbls Class class CGrGlbls GR_HEIGHT DefineStr #define GR_HEIGHT 480 GR_WIDTH DefineStr #define GR_WIDTH 640 Gr2BSpline Funct 2nd order. Clipping but no transform or thick. Gr2BSpline3 Funct 2nd order. Clipping and transform and thick. Gr2Bezier Funct 2nd order. Clipping but no transform or thick. Gr2Bezier3 Funct 2nd order. Clipping and transform and thick. Gr3BSpline Funct 3rd order. Clipping but no transform or thick. Gr3BSpline3 Funct 3rd order. Clipping and transform and thick. Gr3Bezier Funct 3rd order. Clipping but no transform or thick. Gr3Bezier3 Funct 3rd order. Clipping and transform and thick. GrArrow3 Funct 3D. Transformation with thick. GrBlot Funct 2D. Clipping but not transformation.. GrBlot3 Funct 3D. Clipping and transformation. GrBorder Funct 2D. Transformation with thick. GrCircle Funct 2D. Clipping but not transformation. GrCircle3 Funct 3D. Transformation with thick. GrClamp Funct Returns scrn, not window coordinates. GrEllipse Funct 2D. Clipping but not transformation. GrEllipse3 Funct 3D. Transformation with thick. GrFillCircle Funct 2D. Clipping but not transformation. GrFillPoly3 Funct 3D. Must be convex. GrFillTri0 Funct 3D. Returns cnt of pixs changed GrFloodFill Funct 2D. Ignore z and db. GrFloodFill3 Funct 3D. Transformation. GrHLine Funct 3D. No transformation or thick. GrLine Funct 2D. Clipping but not transformation. GrLine3 Funct 3D. Transformation with thick. GrPeek Funct 2D. Clipping but no transformation. GrPeek0 Funct 2D. No clipping or transformation. GrPlot Funct 2D. Clipping but No transformation or thick. GrPlot0 Funct 2D. No clipping or transformation or thick. GrPlot3 Funct 3D. Clipping and transformation and thick. GrPlot3B Funct 3D. Clipping and transformation but no thick. GrRect Funct 2D. Width Height. Clipping but not transformation. GrRect3 Funct 3D. Width Height. Clipping and transformation. GrRectB Funct 2D. Two point. Clipping but not transformation. GrRegPoly Funct 2D. Clipping but no transform or thick. GrRegPoly3 Funct 3D. Clipping and transform and thick. GrVLine Funct 3D. No transformation or thick. gr GlbVar } gr;

Graphics/Char

GrPrint Funct 2D. Clipping but not transformation. GrPrint3 Funct 3D. Transformation. DCF_SYMMETRY is silly. GrPutChar Funct 2D. Clipping but not transformation. GrPutChar3 Funct 3D. Transformation. DCF_SYMMETRY is silly. GrTextBox3 Funct 3D. Transformation. DCF_SYMMETRY is silly. GrTextDiamond3 Funct 3D. Transformation. DCF_SYMMETRY is silly. GrVPrint Funct 2D. Vertical text. Clipping but not transformation. GrVPrint3 Funct 3D. Vertical text. Transformation. DCF_SYMMETRY is silly.

Graphics/Color

CBGR24 Class U32 class CBGR24 CBGR48 Class I64 class CBGR48 CColorROPU16 Class Don't use this, use CColorROPU32 CColorROPU32 Class U32 class CColorROPU32 Color2Str Funct CColorROPU32 with flags to DCLighting str. GrPaletteColorGet Funct VGA has 6-bits for blue, for green, and for red. GrPaletteColorSet Funct VGA has 6-bits for blue, for green, and for red. GrPaletteGet Funct 16 colors GrPaletteSet Funct 16 colors PaletteSetStd Funct Activate std palette. Str2ColorU16 Funct DCLighting color str with flags to CColorROPU16. Str2ColorU32 Funct DCLighting color str with flags to CColorROPU32. gr_palette_gray GlbVar CBGR48 gr_palette_gray[COLORS_NUM]={ gr_palette_std GlbVar CBGR48 gr_palette_std[COLORS_NUM]={ gr_rainbow_10 GlbVar U8 gr_rainbow_10[10]={

Graphics/Data Types/D3I32

CD3I32 Class Three dimensional I32 pt CQueD3I32 Class Que of three dimensional I32 pts D3I32Dist Funct Distance D3I32DistSqr Funct Distance Squared D3I32Norm Funct Norm D3I32NormSqr Funct Norm Squared

Graphics/Device Contexts

CDC Class class CDC DCAlias Funct Create alias of dc, so can change pen, color, etc. DCClear Funct Set entire device context image body to 0 (BLACK). DCColorChg Funct Find and replace src color with dst in device context. DCCopy Funct Alloc copy of dc, including image body, rot mat and depth buf. DCDel Funct Free dc, image body, rot mat and depth buf. DCDepthBufAlloc Funct Alloc a 32-bit depth buffer for device context. DCDepthBufRst Funct Reset device context depth buf to far away. DCDiff Funct Trim to win of what has chged. DCExt Funct Extract new device context rect from device context. DCExtentsInit Funct Init markers for extent of next newly drawn graphics. DCFill Funct Fill entire device context with color. DCLoad Funct Loads device context from mem. DCMono Funct Set entire device context to one of two colors. DCNew Funct Create new width x height device context. DCRst Funct Reset CDC structure members but not image body, itself. DCSave Funct Stores device context to mem, perhaps, with compression. DCScrnCapture Funct Capture scrn to a device context. DCSize Funct Mem size of header, image body and depth buffer. GR2MV Funct Merge GR lst to MV file. GRRead Funct TempleOS GR File. GRWrite Funct TempleOS GR File. GrBlot Funct 2D. Clipping but not transformation.. GrBlot3 Funct 3D. Clipping and transformation.

Graphics/GR Files

GR graphics files are 8-bits-per-pixels but only 4-bits of color, with transparency and no palette. Compression is the standard TempleOS LZW compression. #define DCF_COMPRESSED 1 //This is the only saved flag. #define DCF_PALETTE 2 #define TRANSPARENT 0xFF #define BLACK 0 #define BLUE 1 #define GREEN 2 #define CYAN 3 #define RED 4 #define PURPLE 5 #define BROWN 6 #define LTGRAY 7 #define DKGRAY 8 #define LTBLUE 9 #define LTGREEN 10 #define LTCYAN 11 #define LTRED 12 #define LTPURPLE 13 #define YELLOW 14 #define WHITE 15 class CBGR48 { U16 r,g,b,pad; }; CBGR48 gr_palette_std[16]={ 0x000000000000,0x00000000AAAA,0x0000AAAA0000,0x0000AAAAAAAA, 0xAAAA00000000,0xAAAA0000AAAA,0xAAAA55550000,0xAAAAAAAAAAAA, 0x555555555555,0x55555555FFFF,0x5555FFFF5555,0x5555FFFFFFFF, 0xFFFF55555555,0xFFFF5555FFFF,0xFFFFFFFF5555,0xFFFFFFFFFFFF}; class GRFile { I32 width; I32 width_internal; //Rounded-up to multiple of 8. I32 height; I32 flags; //DCF_COMPRESSED? See ::/Kernel/Compress.HC. CBGR48 palette[16]; //Included if DCF_PALETTE. U8 body[]; }; See DCSave(), GRWrite(), DCLoad(), and GRRead(). DocGR Funct Put a GR file into a document as asprite. DocType Funct Output txt or graphic file to document. GR2MV Funct Merge GR lst to MV file. GRRead Funct TempleOS GR File. GRScrnCaptureRead Funct GrBlot TempleOS GR File to dc,x,y. GRScrnCaptureWrite Funct Capture scrn to a TempleOS GR File. GRWrite Funct TempleOS GR File. Type Funct Output txt or graphic file to command line.

Graphics/Input

PopUpColor Funct Chooser for 16-color, default or transparent. PopUpColorDither Funct Chooser for 2 x 16 colors or transparent. PopUpColorLighting Funct Chooser for std TempleOS DCLighting() color. PopUpTransform Funct Prompt for Mat4x4 transform.

Graphics/Math

BSpline2 Funct Go in 2nd order spline calling callback. BSpline3 Funct Go in 3rd order spline calling callback. Bezier2 Funct Go in 2nd order bezier calling callback. Bezier3 Funct Go in 3rd order bezier calling callback. Circle Funct Step through circle arc calling callback. ClipLine Funct Clip x1,y1 x2,y2 with left,top,right,bottom. Ellipse Funct Step through ellipse arc calling callback. Line Funct Step through line segment calling callback. RegPoly Funct Step through regular polygon calling callback. gr_x_offsets GlbVar I64 gr_x_offsets[8]={-1, 0, 1,-1,1,-1,0,1}, gr_x_offsets2 GlbVar gr_x_offsets2[4]={ 0,-1, 1, 0}, gr_y_offsets GlbVar gr_y_offsets[8]={-1,-1,-1, 0,0, 1,1,1}, gr_y_offsets2 GlbVar gr_y_offsets2[4]={-1, 0, 0, 1};

Graphics/Math/3D Transformation

CDC's have a 4x4 matrix for rotating, scaling, skewing and shifting in 3 dimensions. To make the graphics routines use the transform, you must set the DCF_TRANSFORMATION flag. The matrix consists of ints that have been scaled 32 bits (GR_SCALE). See ::/Demo/Lectures/FixedPoint.HC to learn why. See Mat4x4IdentEqu(), Mat4x4IdentNew(), Mat4x4Equ() and Mat4x4New(). See Mat4x4RotX(), Mat4x4RotY(), Mat4x4RotZ() and Mat4x4Scale() to rotate about axes and scale. Combine them with Mat4x4MulMat4x4Equ()/Mat4x4MulMat4x4New() and assign them to the CDC.dc with DCMat4x4Set(). See ::/Demo/Graphics/Box.HC. You can rotate single points using Mat4x4MulXYZ(). The 4th dimension allows a neat trick where you can place pos shifts (translations), into the matrix and Mat4x4MulMat4x4Equ/Mat4x4MulMat4x4New them to combine rotation/shift operations. Normally, you can't combine pos shift operations. See Mat4x4TranslationEqu() and ::/Demo/Graphics/Transform.HC. Finally, CDC's have an x, y and z which is an additional shift (translation). The transformation is implemented as a callback on the CDC's transform() member. The default transform() callback is DCTransform(). See ::/Demo/Games/Talons.HC or ::/Demo/Games/CastleFrankenstein.HC to see how to change the transform() callback for foreshortening. DCMat4x4Set Funct Set device context's rot matrix. Will be Freed() in DCDel().Uses fixed-point. DCReflect Funct Reflect 3D point about device context's symmetry. Uses fixed-point. DCSymmetry3Set Funct 3D. Set device context's symmetry. DCSymmetrySet Funct 2D. Set device context's symmetry. DCThickScale Funct Scale device context's thick by norm of transformation. DCTransform Funct This is the dft dc->transform() callback. Mat4x4Equ Funct Copy 4x4 Rot matrix. Mat4x4IdentEqu Funct Set matrix to identity. Uses fixed-point. Mat4x4IdentNew Funct MAlloc an identity matrix. Uses fixed-point. Mat4x4MulMat4x4Equ Funct Multiply 4x4 matrices and store in dst. Uses fixed-point. Mat4x4MulMat4x4New Funct Multiply 4x4 matrices. Return MAlloced matrix. Uses fixed-point. Mat4x4MulXYZ Funct Rotate 3D point using 4x4 matrix. Uses fixed-point. Mat4x4New Funct Return MAlloced copy of 4x4 Rot matrix. Mat4x4NormSqr65536 Funct Norm Squared of r. Mat4x4RotX Funct Rot matrix about X axis. Uses fixed-point. Mat4x4RotY Funct Rot matrix about Y axis. Uses fixed-point. Mat4x4RotZ Funct Rot matrix about Z axis. Uses fixed-point. Mat4x4Scale Funct Scale 4x4 matrix by value. Mat4x4TranslationAddFunct Add translation to 4x4 matrix. Uses fixed-point. Mat4x4TranslationEquFunct Set translation values in 4x4 matrix. Uses fixed-point. PopUpTransform Funct Prompt for Mat4x4 transform. SpriteTransform Funct Rotate Sprite using 4x4 matrix. Uses fixed-point.

Graphics/Mesh

DCLighting Funct This is the dft dc->lighting() callback. Gr3Mesh Funct Returns cnt of pixs changed.

Graphics/Misc

DrawGrabMs Funct This is a callback. See ::/Demo/Graphics/Grid.HC. DrawStdMs Funct This is a callback. See ::/Demo/Graphics/Grid.HC. DrawWaitMs Funct This is a callback. See ::/Demo/Graphics/Grid.HC. IsPixCovered0 Funct No clipping

Graphics/Scrn

DCScrnCapture Funct Capture scrn to a device context. GRScrnCaptureRead Funct GrBlot TempleOS GR File to dc,x,y. GRScrnCaptureWrite Funct Capture scrn to a TempleOS GR File. GrScaleZoom Funct Multiply zoom factor larger or smaller. WinZBufUpdate Funct Might have to call if doing graphics outside winmgr callback routines.

Graphics/Sprite

A CSprite is an ordered list of these elements, created with <CTRL-r>. Normally, they are packed together in a list and the address of the first is passed to routines. See ::/Demo/Graphics/SpritePlot.HC, ::/Demo/Graphics/SpritePlot3D.HC, ::/Demo/Graphics/SpritePut.HC, ::/Demo/Graphics/SpriteRaw.HC and SpriteMeshEd(). Be aware that copying SP, IB, or IS entries with the clip results in duplicate entries with different nums. You can manually remove dups by editing with <CTRL -t> and setting to the original num. See ::/Adam/Gr/GrSpritePlot.HC for how CSprite are stored. CSprite Class class CSprite Code2Sprite Funct Text to sprite. DC2Sprite Funct Convert device context to sprite. DocGR Funct Put a GR file into a document as asprite. DocSprite Funct Put a sprite into a document. You can, optionally, supply a fmt string GodDoodleSprite Funct Make God draw sprite. Holy Spirit Instructions Sprite Funct Put sprite to the command-line, DocPut. Sprite2Code Funct Sprite to text. Sprite2DC Funct Convert sprite to device context. Sprite3 Funct Plot a sprite into a CDC. Sprite3B Funct Plot a sprite into a CDC, post transform xyz translation. Sprite3Mat4x4B Funct Plot rotated by matrix. Sprite3XB Funct Plot rotated around X axis. Sprite3YB Funct Plot rotated around Y axis. Sprite3ZB Funct Plot rotated around Z axis. SpriteElem2Summary Funct Study ::/Demo/Graphics/SpriteText.HC. SpriteExtents Funct Ignores flood fills. SpriteInterpolate Funct The two CSprite should be ident except for points shifted around. SpriteSize Funct Walk sprite elements and return size of sprite as binary data. SpriteTransform Funct Rotate Sprite using 4x4 matrix. Uses fixed-point.