Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Cos 160: Program 8- Star Sampler Objectives Creating a method with parameters. Part 1 (5 points) Drawing Polygons Java has a graphics method fillPolygon() for

image text in transcribed
image text in transcribed
image text in transcribed
Cos 160: Program 8- Star Sampler Objectives Creating a method with parameters. Part 1 (5 points) Drawing Polygons Java has a graphics method fillPolygon() for drawing any arbitray polygon. It works by taking arrays of the X and Y coordinates for the points and then drawing a polygon whose border goes from point to point and then returns to the starting point. Its API description is: public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) Fills a closed polygon defined by arrays of and y coordinates. This method draws the polygon defined by nPoints line segments, where the first nPoints 1 line segments are line segments from (xPoints[i 11, yPoints[i 1]) to (xPoints[i], yPoints[I), for 1 si s nPoints. The figure is automatically closed by drawing a line connecting the final point to the first point, if those points are different. The area inside the polygon is defined using an even-odd fill rule, also known as the alternating rule. Parameters: xPoints- an array of x coordinates yPoints an array of y coordinates nPoints - the total number of points. See Also: drawPolygon(int[), int[], int) Test it by making a little test program that makes arrays of x and y coordinates and draws a polygon. Part 2 (10 points) Method to draw a filled regular polygor po po p1 p7, P4 p1 6 p2. p5 p3 p3 p2 p4 points 8 points = 5 Cos 160: Program 8- Star Sampler Objectives Creating a method with parameters. Part 1 (5 points) Drawing Polygons Java has a graphics method fillPolygon() for drawing any arbitray polygon. It works by taking arrays of the X and Y coordinates for the points and then drawing a polygon whose border goes from point to point and then returns to the starting point. Its API description is: public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) Fills a closed polygon defined by arrays of and y coordinates. This method draws the polygon defined by nPoints line segments, where the first nPoints 1 line segments are line segments from (xPoints[i 11, yPoints[i 1]) to (xPoints[i], yPoints[I), for 1 si s nPoints. The figure is automatically closed by drawing a line connecting the final point to the first point, if those points are different. The area inside the polygon is defined using an even-odd fill rule, also known as the alternating rule. Parameters: xPoints- an array of x coordinates yPoints an array of y coordinates nPoints - the total number of points. See Also: drawPolygon(int[), int[], int) Test it by making a little test program that makes arrays of x and y coordinates and draws a polygon. Part 2 (10 points) Method to draw a filled regular polygor po po p1 p7, P4 p1 6 p2. p5 p3 p3 p2 p4 points 8 points = 5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago