Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java & StdDraw - How can I draw a baseball (using filled white circles and red arcs on top of the cirlces) using this code?

Java & StdDraw - How can I draw a baseball (using filled white circles and red arcs on top of the cirlces) using this code? I'm having trouble getting the red arcs onto the cirlces with the offsets and what not. I have the gray circles so I can tell them apart. Very new at coding so I apologize...

import java.awt.Color;

import StdDraw;

public class ... {

/******************************************************************** * * Main program * * Set up the canvas, and draw several examples of the baseball. * ******************************************************************/ public static void main(String args[]) { // initialize canvas int width = 1000, height = 1000; StdDraw.setCanvasSize(width, height); StdDraw.clear(StdDraw.BLACK); // draw a black background // test circles manually at different scales StdDraw.setXscale(0, width/5); StdDraw.setYscale(0, height/5); drawBB(Color.WHITE);

// demonstrate offset StdDraw.setXscale(0, width/20); StdDraw.setYscale(0, height/20); drawBB(Color.WHITE,10,35); StdDraw.setXscale(0, width/10); StdDraw.setYscale(0, height/10); drawBB(Color.WHITE,75,35); // use for loops StdDraw.setXscale(0, width/2); StdDraw.setYscale(0, height/2); for (int i=0;i<7;i++) drawBB(Color.GRAY, 250+i*30,270); for (int i=0;i<5;i++) drawBB(Color.WHITE, 200+i*50,300); } /******************************************************************** * drawBB * * Main drawBB method. All other methods call this one. * ******************************************************************/ public static void drawBB(Color bodyColor, int offsetX, int offsetY) { StdDraw.setPenColor(bodyColor); StdDraw.filledCircle(8+offsetX,7+offsetY,5); } /******************************************************************** * Other drawBB methods * ******************************************************************/ public static void drawBB() { drawBB(Color.WHITE, 0, 0); } public static void drawBB(Color bodyColor) { drawBB(bodyColor, 0, 0); } public static void drawBB(int offsetX, int offsetY) { drawBB(Color.GRAY, offsetX, offsetY); }

}

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

using signal flow graph

Answered: 1 week ago