CoolFace
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes838downloads
GraphicsOverview.txt119 linesDownload Raw Back to Doc
1 2                               Graphics Overview3 4Dive into Demo Index to learn.5 6The order layers are drawn on top of each other is:7 8 9 10 11 12 13 14 15 16 17 18/* Graphics Not Rendered in HTML */19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46* See GrUpdateScrn(), GrUpdateTasks() and GrUpdateTaskWin() called by the WinMgr47task 30fps.  Notice the task's draw_it() callback being called.  Only tasks on C48ore0 are allowed to have windows.  There is one window per task, no child49windows.  You can have pop-up child tasks.50 51* CDCs (device contexts) are a data type for controlling graphics on the scrn or52graphics in mem.  The device context structure has thick and color.  You use53DCAlias() to create your own structure, with its own color and thick.  Free it54with DCDel() when finished.55 56* gr.dc is a device context for persistent data on the scrn, not needing to be57redrawn.  You create an alias for this by using DCAlias() and work with that.58See ::/Demo/Graphics/NetOfDots.HC.59 60* There are various flavors of line and point plotting routines.  GrLine() and61GrPlot() are the simplest.  The others allow 3D graphics and rotations.62 63* See ::/Doc/Transform.DD for adding a transformation.64 65* You change the Fs->draw_it var to point to your DrawIt() function which gets66called each scrn refresh (30 fps).  You draw everything in the window over and67over again.  See ::/Demo/Graphics/Box.HC.68 69* Use the graphic sprite resource editor, <CTRL-r>, to create a sprite that can70be plotted with Sprite3() or output to the cmd line with Sprite().  Use $IB,"",B71I=1$ in a src program to insert the addr of sprite binary data item #1.  To72learn how the numbers work, after creating a sprite with <CTRL-r>, toggle to73plain text with <CTRL-t> and check its num.  Make an assignment to a ptr var or74pass to Sprite3() with $IB,"",BI=n$.  Use <CTRL-r>'s "Pointer to Sprite" to make75a $IB...$ entry.  See ::/Demo/Graphics/SpritePlot.HC and76::/Demo/Graphics/SpritePlot3D.HC.  The origin (zero point) for a sprite is77defined by the cursor location when you pressed <CTRL-r> to make it.  You can78edit a sprite by clicking the cursor on it and pressing <CTRL-r> again.79 80* Set DCF_SYMMETRY in the CDC.flags and call DCSymmetrySet() or DCSymmetry3Set()81.  This will plot a mirror image in addition to the primary image.  Set82DCF_JUST_MIRROR to plot just the image, but this required DCF_SYMMETRY to be set83at the same time.  Note: You can only have one symmetry active at a time84including in CSprites.85 86* Use DCNew() to create a mem bitmap which can be used to work off-scrn and87which can be GrBloted onto the scrn.  If you set brush member of CDC to another88CDC, all the graphic routines will GrBlot() the brush instead of GrPlot().  See89::/Demo/Graphics/Blot.HC.90 91* There are a few raster operations available.  They go in bits 8-11 of the dc->92color member var which is a CColorROPU32.  ROP_COLLISION is special.  It counts93the num of pixs drawn on non-background locations.  Using ROP_COLLISION with94vector CSprite's is tricky because overlapping pixs from lines in the CSprite95reg as collisions.  You can either work with a nonzero count or convert your96CSprite to a bitmap if your subelements draw on top of each other.  Be sure to97set ->bkcolor before using ROP_COLLISION.  See ::/Demo/Graphics/Collision.HC and98Titanium.99 100* The ->dither_probability_u16 member of CDC is a U16 used to statistically sel101between two colors to get something resembling more shades of color.  See102::/Demo/Graphics/SunMoon.HC and ::/Demo/Graphics/Shading.HC.  It works with many103graphic routines, but not those with pens.104 105* There is a mechanism built-in for generating motion based on differential106equations, which allows realistic physics.  You create an CMathODE struct with107ODENew(), passing it the num of vars in the state vect.  For realistic physics,108you usually have 2 state vars for each dimension (for each mass) because motion109is governed by F=mA which is a 2nd order equation.  The two states are pos and110velocity and to solve these you need to supply the derivative of pos and111velocity.  The derivative of pos is usually simply the current velocity and the112derivative of velocity is the acceleration (the sum of forces on a mass divided113by mass).  To help provide meaningful names for values in the state vect, you114can create an COrder2D3 ptr and point it to a mass in the state vect.  Six115elements in the state vect are required for each mass.116 117See Math/CMathODE.118See ::/Demo/Games/Rocket.HC.119