S05DrawingShapes - Cse536 Functional Programming Lecture#5...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Cse536 Functional Programming 1 10/05/15 Lecture #5, Oct 11, 2004 Reading Assignments Finish Chapter 3, Simple Graphics Read Chapter 4, Shapes II, Drawing Shapes Today’s Topics Using the graphics primitives Drawing Primitive Shapes Sierpinski’s Triangle Snow-flake Coordinate Systems Position independent shapes Drawing the Shape Data-type
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Cse536 Functional Programming 2 10/05/15 Turning in Homework In order to facilitate my grading homework I would ask the following Email me a copy of the homework. Include the code right in the body of the email. Put all directions in comments. I will try and run this email, so don’t clutter it with stuff that will make this hard. Put your name and the homework # in the Subject heading. i.e. Subject: Tim Sheard #2 The e-mail is expected to be received before or on the due-date and will be acknowledged if you ask for acknowledgement. The email address to use is: [email protected] You are also expected to turn in a paper copy in class on the due date. This way I don’t have to print it, and I have something to write comments on.
Image of page 2
Cse536 Functional Programming 3 10/05/15 Drawing Primitive Shapes The Graphics libraries contain primitives for drawing a few primitive shapes. We will build complicated drawing programs from these primitives ellipse :: Point -> Point -> Draw () shearEllipse :: Point -> Point -> Point -> Draw () line :: Point -> Point -> Draw () polygon :: [Point] -> Draw () polyline :: [Point] -> Draw ()
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Cse536 Functional Programming 4 10/05/15 Coordinate Systems (0,0) Increasing x-axis I n c r e a s i n g y - a x i s
Image of page 4
Cse536 Functional Programming 5 10/05/15 Example Program main2 = runGraphics( do { w <- openWindow "Draw some shapes" (300,300) ; drawInWindow w (ellipse (0,0) (50,50)) ; drawInWindow w (shearEllipse (0,60) (100,120) (150,200)) ; drawInWindow w (withColor Red (line (200,200) (299,275))) ; drawInWindow w (polygon [(100,100),(150,100),(160,200)]) ; drawInWindow w (withColor Green (polyline [(100,200),(150,200), (160,299),(100,200)])) ; spaceClose w } )
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Cse536 Functional Programming 6 10/05/15 The Result ; drawInWindow w (ellipse (0,0) (50,50)) ; drawInWindow w (shearEllipse (0,60) (100,120) (150,200)) ; drawInWindow w (withColor Red (line (200,200) (299,275))) ; drawInWindow w (polygon [(100,100), (150,100), (160,200)]) ; drawInWindow w (withColor Green (polyline [(100,200),(150,200), (160,299),(100,200)]))
Image of page 6
Cse536 Functional Programming 7 10/05/15 Building Programs We’d like to build bigger things from these small pieces Perhaps things such as fractals Example: Sierpinski’s Triangle a repeated drawing of a triangle at repeatedly smaller sizes.
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern