Graphics Projects
 Also see: Image Processing and Colors Lab Reports Delphi Graphics  and General Graphics Reference Library

 Program Description Keywords Area/Centroid Demonstrate two ways to compute the area of a polygon, whose coordinates are defined in "world" coordinates.    An additional method that can be applied only to triangles (Heron's formula) is also demonstrated. Also, the centroid of a polygon is computed. polygon area, polygon centroid, clockwise/counterclockwise order, Green's Theorem, pixel counting, Heron's formula, world coordinates, device coordinates, PaletteIndex, Canvas.FillRect, Canvas.Polyline, Canvas.FloodFill Basketball Show how to map real-world coordinates to pixel coordinates. Show how to draw a diagram of a basketball court. TSimplePantograph, world coordinates, TRect, TRealRect, TPoint, TRealPoint, Point in Rectangle, arc, ellipse, Windows 95/98/2000, Delphi 3/4/5 Bezier Draw and distort polygons using Bézier curves and an original smoothing algorithm. Smoothing algorithm with smooth factor, Bézier curves, Square to circle transformation, Grid pattern, Drawing flowers BMPJPG Convert a BMP to a JPG file, or a JPG to a BMP. Show how to print JPG image. Use interactive BMPJPG.EXE program for experiments, or command-line utilities, BMPtoJPG.EXE and JPGtoBMP.EXE. TJPEGImage, BMP, JPG, JPEG, BMP-to-JPG, JPG-to-BMP, JPEG quality factor, progressive encoding, progressive display, incremental display, compression factor, command-line utility, Delphi 3/4 BrushBitmaps Use brush bitmaps to paint selected areas with specified patterns.  Merge several masks with various patterns with a background image to form a single composite bitmap TBrush, TBitmap, Brush.Bitmap, Windows system colors, pf4bit, pf24bit, Scanline, FillRect, FloodFill, centroid, mask, Draw, Transparent Circle Word Wrap Wrap Text from a Memo Box Inside a Circle Word Wrap, Circle, GetTextThatFits function, Canvas.Ellipse, Font.Height, Canvas.TextHeight, Canvas.TextWidth, Canvas.TextOut, Insert/Delete string functions, TMemo.Text Cursor Overlay Convert a cursor to a bitmap and overlay its bitmap on another bitmap Cursors, .CUR files, CUR-to-BMP conversion, hot spot,.RC and .RES resource files, resource compiler BRCC32,  LoadCursor, GetIconInfo, DrawIconEx, Transparency, TransparentMode, TransparentColor, FloodFill, Windows 95/98/2000, Delphi 3/4/5 Daisy Create and display 640-by-480 24-bit RGB "Daisy" image. Draw a "Blue" Daisy containing 1024 "points" using the Ellipse Canvas method, and then use ScanLine to create Red and Green planes with 2D sinusoidal patterns. Print a 2000-by-1500 pixel image at a specified location with a specified size. Write a 1024-by-768 pixel BMP file to disk. Moiré pattern, Golden Ratio, TCanvas.Ellipse, TBitmap.ScanLine, GetDeviceCaps, Delphi 3 Delphi 1 Version of Football, SphereInCube, Surface3D (338 KB) Delphi 1, 2D/3D vector graphics Football "Football" shows three perspective views and an orthographic view of a football field (American). Display these four views on the screen, print them out, or save them to a BMP file. The GraphicsMathLibrary and GraphicsPrimitivesLibrary units define a non-visual TPantograph object for mapping real coordinates to pixel coordinates, mostly for scientific and engineering calculations. (These libraries do not require OpenGL or DirectX.  I DO need to create more documentation for these libraries to make them more useful to others.) Erratum:  The constants in the FromCartesian function in the GraphicsMathLibrary unit should be PI/2 instead of  PI/4.  This affects some boundary values.  This will eventually be fixed.  (25 Sept 2000.  Thanks to Christoph Christmann for bringing this to my attention.) 2D/3D vector graphics, translation, rotation, scaling, view transform, homogeneous coordinates, clipping, projections, vectors, matrices, TPantograph, Delphi 3 LineStretch Demonstrate an alternative to using XOR to stretch lines. Show how to restrict cursor movement to a specified rectangular area. Show how to detect whether a cursor is "near" a line. OnMouseDown, OnMouseMove, OnMouseUp, Bounds, ClipCursor, PtInRect, Rectangle, Screen.Cursor, crHandPoint, crDrag, crDefault, AddPoints, SubtractPoints, NearLine, Canvas.MoveTo, Canvas.LineTo Palettes and Colors Separate page summarizing Lab Reports about Palettes and Colors: Display Color Chart. Cycle colors using Scanline. Experiment with the Palette Lab. Show 16.8 million RGB Colors. Optimized Palette Demos -- One Image Versus Many Images Palettes, ScanLine, TOctreeNode, TColorQuantizer, CreateHalftone Palette, Optimized Palette, Idle Action, TRGBTriple, dither and non-dithered display colors, FractInt color maps, Macbeth Color Checker, Delphi 3 Simple Bar Chart Create a simple bar chart and print two ways: draw directly on the printer canvas, or create bar chart as bitmap and then draw the bitmap on the printer canvas. In Delphi 3 you might want to consider the TChart component instead. Canvas, Brush.Color, Pen.Color, Rectangle, FillRect, Delphi 3 Simple Graph Create a simple graph, y = a* | sin(b*x)|. Display graph on screen dynamically, or print or write to a BMP file. In Delphi 3 you might want to consider using the TChart component instead. TPantograph, Vector2D, MoveTo, LineTo, Repaint, PointAt, TextOut, Delphi 3 SnappyLine Demonstration of line drawing/snapping and rubber banding.SnappyLine demonstrates the creation of a LogFont for drawing the text dimensions at any angle. Contributed by Gordon Whittam. AlignAngleText procedure, LogFont API call, Line rubber banding, Canvas.MoveTo, Canvas.LineTo, Canvas.FillRect, Cansvas.Pen.Mode, user-defined cursor, .RES file, Screen.Cursors, OnMouseDown, OnMouseMove, OnMouseUp, PtInRect, MessageBeep, TStatusBar Sphere In Cube "Sphere in Cube" shows six perspective views and three orthographic views of a sphere inside a cube. You can display these views on the screen or print them out. A "dynamic" checkbox allows one to view the drawing of each line segment. See comments under "Football" about graphics library units. 2D/3D vector graphics, translation, rotation, scaling, view transform, homogeneous coordinates, clipping, projections, vectors, matrices, TPantograph, Delphi 3 Sphere In Cube Movie The "Sphere in Cube Movie" generates an animation sequence (50 frames by default) to show a "fly around" of a sphere in a cube. A TList of TBitmaps is stored in memory for quick display of images. This program can be used to stretch your virtual memory system to its limits. (100 frames are possible in Win 95 with 32 MB memory). 2D/3D vector graphics, translation, rotation, scaling, view transform, homogeneous coordinates, clipping, projections, vectors, matrices, TPantograph, GetTickCount, Scrollbar, Delphi 3 Surface3D "Surface3D" produces several perspective plots of a "fishnet" surface described mathematically as z = f(x,y) = x * y * (x2 - y2) / (x2 + y2). Hidden lines are not removed. 2D/3D vector graphics, translation, rotation, scaling, view transform, homogeneous coordinates, clipping, projections, vectors, matrices, TPantograph, Delphi 3 Three-D Lab With the "3D Lab" you can choose a figure to display (Cube | Sphere | Cube & Sphere | f(x,y) Surface | Football field) and then use spinboxes to decide where your eye is. 2D/3D vector graphics, translation, rotation, scaling, view transform, homogeneous coordinates, clipping, projections, vectors, matrices, TPantograph, telephoto view, wide angle view, Delphi 3 Transparent Button Place a TBevel and a TLabel on top of a TImage to simulate a transparent button. Transparent button, Hover button,  TBevel, TLabel, ClientToScreen, ScreenToClient, MouseMove, MouseDown, keyboard shortcu Turbo Pascal 7 Version of SphereInBox Turbo Pascal, 2D/3D vector graphics. SVGA256.BGI, S3.BGI Very Large Bitmap Experiment The purpose of this experiment is (1) to find the Windows "breaking point" for creation of in-memory bitmaps and (2) to explore the performance of an algorithm to count the number of unique colors in a 24-bits/pixel bitmap. TBitmap, EOutOfResources, Scanline, pf24Bit, TRGBTripleArray, pRGBTripleArray, TBits

Also see:
efg's Printer Demo #1 in Printer Projects
for how to use the StretchDIBits Windows API call to print bitmaps.

Updated 6 Nov 2011
Since 1 Nov 1998