Download presentation
Presentation is loading. Please wait.
1
Graphics and Multimedia
Lecture 9
2
Outline Drawing Polygons and Polylines Advanced Graphics Capabilities
3
Drawing Polygons and Polylines
Multisided shapes Graphics methods used to draw polygons DrawLines, DrawPolygon, and FillPolygon
4
Drawing Polygons and Polylines
5
Drawing a Triangle Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) Dim myGraphics As Graphics = e.Graphics Dim myPen As Pen Dim A As New Point(10, 10) Dim B As New Point(100, 50) Dim C As New Point(60, 150) Dim myPoints As Point() = {A, B, C} myPen = New Pen(Drawing.Color.Blue, 5) myGraphics.DrawPolygon(myPen, myPoints) End Sub
6
Advanced Graphics Capabilities
Visual Basic offers many additional graphics capabilities Examples Brush hierarchy also includes: HatchBrush, LinearGradientBrush, PathGradientBrush and TextureBrush Additional graphics features Dashed lines, thick lines, filling shapes with patterns, etc
7
Advanced Graphics Capabilities
Bitmap Class Produce images in color and gray scale with a particular width and height. Used to work with images defined by pixel data. How to use… Dim graphicsObject As Graphics = e.Graphics Dim BitmapVar As Bitmap = New Bitmap(width, height) . Dim BrushVar As TextureBrush = New TextureBrush(BitmapVar) graphicsObject.FillRectangle(BrushVar, X, Y, width, height)
8
Texture Brush Dim pts() As Point = { _ New Point(20, 5), _ New Point(100, 30), _ New Point(80, 100), _ New Point(120, 120), _ New Point(60, 140), _ New Point(5, 60) _ } ' Fill a polygon with a textured brush. e.Graphics.FillPolygon(New Drawing.TextureBrush(picFace.Image), pts) ' Make a pen. Dim a_pen As New Pen(Color.Tomato, 3) a_pen.DashStyle = Drawing.Drawing2D.DashStyle.Dash ' Outline the polygon. e.Graphics.DrawPolygon(a_pen, pts)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.