Code for these debug graphics:
/* * g - Graphics2D object provided in onPaint(Graphics2D) (or from bot.getGraphics() in 1.6.1 +) * bot - reference to my instance of AdvancedRobot * w - wave. * w.ctime - when the wave was fired */ if (bot.getOthers() == 1) { g.setColor(new Color(0f, 0.5f, 0f)); g.draw(new Ellipse2D.Double(goal.x - 10, goal.y - 10, 20, 20)); double radius, arcSegment, segmentHeading; double time = bot.getTime(); for (Wave w : waves) { radius = (time - w.ctime) * w.speed; arcSegment = w.extent / NUM_WAVEBUCKETS; segmentHeading = 0; for (int i = 0; i < NUM_WAVEBUCKETS; i++) { g.setColor(Color.getHSBColor( (w.reachableBucket == i ? 0f : 1/3f), // green, or red if it's the target bucket 1f, // full saturation of course (float)(0.25 + 0.75 * waveBuckets[i] / bucketMax) // brighter as the bucket is fuller )); //g.setStroke(new BasicStroke((float)(4 * waveBuckets[i] / bucketMax))); // disabled due to CPU expense //draw a line for each bucket along the arc of the wave segmentHeading = w.heading - w.clockwise * (w.extent / 2 - arcSegment * (i - 0.5)); g.draw(new Line2D.Double( w.origin.x + radius * Math.sin(segmentHeading), w.origin.y + radius * Math.cos(segmentHeading), w.origin.x + radius * Math.sin(segmentHeading + arcSegment), w.origin.y + radius * Math.cos(segmentHeading + arcSegment) )); } } }
This code is free, do whatever you like with it.
You used a similar method to what I've now got for painting waves in DrussGT, using the many small sections of line to make up the continuous arc. The main difference is that I change the color from blue -> yellow -> orange -> red depending on the danger, and it's in several increments, not in a continuous function. I didn't even know about the Color.getHSBColor method - looks very nice! I might just steal that idea - I take it this code is under the RWPCL? -- Skilgannon