Graphics
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Graphics

on

  • 904 views

C# Graphics

C# Graphics

Statistics

Views

Total Views
904
Views on SlideShare
813
Embed Views
91

Actions

Likes
0
Downloads
11
Comments
0

14 Embeds 91

http://mpgddspf.blogspot.com 41
http://programmingex.blogspot.dk 12
http://programmingex.blogspot.ie 9
http://programmingex.blogspot.sg 7
http://www.slideshare.net 4
http://programmingex.blogspot.in 4
http://programmingex.blogspot.com 3
http://www.mpgddspf.blogspot.com 3
http://mpgddspf.blogspot.in 2
http://programmingex.blogspot.sk 2
http://mpgddspf.blogspot.it 1
http://mpgddspf.blogspot.hu 1
http://programmingex.blogspot.kr 1
http://programmingex.blogspot.co.il 1
More...

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Graphics Presentation Transcript

  • 1. C# .NET Graphics
    Extra – not tested
    Required for assignment 1
  • 2. What will we be learning?
    Surface, pen and brush
    Draw Lines
    Draw Rectangles
    Draw Polygons
    Draw Text
  • 3. Basic - Graphics
    (1) we need to have a Graphics instance (similar to a surface)
  • 4. Basic
    Declare
    Graphics mySurface;
  • 5. Basic
    Create
    Graphics mySurface;
    mySurface = this.CreateGraphics();
  • 6. Basic - Pen
    (2) To draw lines or outlines of shapes, we need a Pen
  • 7. Basic - Pen
    Declare
    Pen pen1;
  • 8. Basic - Pen
    Create
    2 parameters
    - Color
    - thickness
    Pen pen1;
    pen1 = new Pen(Color.Blue, 1.0f);
  • 9. Basic - Brush
    (3) To fill inside shapes, we need a Brush
  • 10. Basic - Brush
    Declare
    Types of brush
    SolidBrush
    HatchBrush
    LinearGradientBrush
    PathGradientBrush
    TextureBrush
    SolidBrush brush1;
  • 11. Basic - Brush
    Create
    SolidBrush brush1;
    brush1 = new SolidBrush(Color.Green);
  • 12. Basic - Brush
    Types of brush
    SolidBrush
    HatchBrush
    LinearGradientBrush
    PathGradientBrush
    TextureBrush
  • 13. Draw Lines
    > New Solution: SpfGraphics
    > Select Form1.cs, select design view
    > select events and double click “Paint” event
  • 14. Draw Lines
  • 15. Draw Lines
  • 16. Output
  • 17. Using points & DrawLines
    Continue in Form1_Paint
  • 18. Output
    surface1.DrawLine(pen1, pt1, pt3);
    surface1.DrawLines(pen1, points);
  • 19. Draw Rectangle
    Continue in Form1_Paint
  • 20. Draw Rectangle
  • 21. Fill Shape
    Continue in Form1_Paint
  • 22. Fill Shape
  • 23. Draw Polygon
    Continue in Form1_Paint
  • 24. Draw Polygon
  • 25. Draw Text
    Continue in Form1_Paint
  • 26. Draw Text
  • 27. Try it yourself: drawing cross for mousedown
    VIDEO
  • 28. Try it yourself!
    Hint: use the mousedown event
    Hint: use points (e.X-5, e.Y-5) , (e.X+5, e.Y+5), (e.X+5, e.Y-5) , (e.X-5, e.Y+5)
  • 29. Possible solution
  • 30. Draw fix line follow mouse
  • 31. Draw fix line follow mouse
    New project “lineFollowMouse”
  • 32. Draw fix line follow mouse
    // Get the mouse position
  • 33. Demo: flexi line follow mouse
    VIDEO
  • 34. Flexi line follow mouse
    // Get the mouse position
  • 35. Demo: Simple pixel drawing
    VIDEO
  • 36. Simple pixel drawing
    New project: SimplePixelDrawing
  • 37. Simple pixel drawing
  • 38. Simple pixel drawing
  • 39. Simple pixel drawing
    to continue next page
  • 40. Simple pixel drawing
    continue from previous page
  • 41. Summary
    Surface, pen and brush
    Draw Lines
    Draw Rectangles
    Draw Polygons
    Draw Text