Download presentation
Presentation is loading. Please wait.
Published byPenelope Sparks Modified over 9 years ago
1
Line Graphics Summary 1.drawLine(xStart, yStart, xEnd, yEnd); 2.drawRect(x, y, width, height); 3.drawRoundRect(x, y, width, height, cornerWidth, cornerHeight); 4.drawOval(x, y, width, height); 5.drawArc(x, y, width, height, startAngle, numDegrees);
2
Make a Happy Face 1.Use an oval to make a head 2.Use two more ovals to make eyes 3.Make a nose with a round rectangle 4.Use rectangles for eyebrows 5.Use an arc for the mouth 6.Use lines to make some spiked hair 7.Use arcs for the ears
3
Fill Method Make three more shapes below your face –Compile and execute Replace the word “draw” with the word “fill” in your commands for these shapes –Compile and execute
4
Add Some Color g.setColor(Color. ); Preset colors (case-sensitive): black, blue, cyan, gray, darkGray, lightGray, green, magenta, orange, pink, red, white, yellow Change the color of your eyes, mouth, and face
5
Custom Color Color myColor = new Color(r,g,b); g.setColor(myColor); Useful site for picking rgb combinations http://www.pitt.edu/~nisg/cis/web/cgi/rgb.ht mlhttp://www.pitt.edu/~nisg/cis/web/cgi/rgb.ht ml Try to make your java face match your own eye, skin, lip, and hair color as close a possible.
6
Polygons Process to define and use a polygon (multi-pointed shape) Give your polygon a name –Polygon myPoly; Create the polygon –myPoly = new Polygon(); Define the point for your polygon (repeat the command for the number of points your polygon has) –myPoly.addPoint(x,y); –The last point defined will join with th first point defined Draw your polygon using: –g.drawPolygon(myPoly); –g.fillPolygon(myPoly);
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.