d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Trying To Make A Game, Need Help With Graphics
Add Reply New Topic New Poll
Member
Posts: 5,988
Joined: May 6 2006
Gold: 30.00
Dec 27 2013 02:53pm
The problem i'm currently having is that i want to have a circle border, such that a certain part of it is shaded a different color , and it rotates around the entire circle



In this example, the red is the part that i want to rotate around the circle. What is the easiest approach?


Edit: This is in java

This post was edited by oOn on Dec 27 2013 02:54pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Dec 27 2013 05:29pm
there should be a drawArc method if memory serves.
Member
Posts: 42
Joined: Jan 11 2014
Gold: 3,097.85
Jan 11 2014 11:06am
There are a lot of different approaches (if you're doing this with a basic drawing library). If you're not clearing the screen every frame, you could update the image by adding X pixels to the arc in the direction of rotation and removing X pixels from the arc on the opposite end

Code
moveArcClockwise(startAngle, endAngle, bigRadius, smallRadius)
for r between smallRadius and bigRadius:
drawPoint(r * cos(endAngle), r * sin(endAngle))
erasePoint(r*cos(beginAngle), r*sin(beginAngle))


in your picture, erase would just be to color blue and draw would be to color red


or just keep clearing the whole screen and redrawing a circle with an arc in it.


Code
drawCircleAndArc(startAngle, endAngle, bigRadius, smallRadius)
for angle between 0 and 360
color = blue
if angle between start and end angle
color = red

for r between smallRadius and bigRadius
drawPoint(r * cos(endAngle), r * sin(endAngle), color)



Hopefully this pseudo-code makes sense

This post was edited by Kronosaurus on Jan 11 2014 11:10am
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll