12.3. Drawing Simple Graphics

As we discussed in the previous section, from the programming perspective, drawing on the Web is the same as drawing in Windows Forms, except for a few small differences. Drawing on the Web is often called “drawing on the fly” (or “graphics on the fly”). The code in Listing 12.4 draws various graphics objects, including lines, text, rectangles, and an ellipse. We create various pens, brushes, and a 300×300 bitmap. Then we create a Graphics object from this bitmap by calling Graphics.FromImage. Once we have a Graphics object, we can call its methods to draw and fill graphics shapes.

After creating the Graphics object, we set its smoothing mode to AntiAlias, create font and size objects, and call the DrawString, ...

Get Graphics Programming with GDI+ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.