Eufloria > Eufloria Classic Mods

Questions about [drawing]

(1/2) > >>

Breakord:
:)
Still, many questions!
I'd like to say thank you first~
Q1:Can I set the cascading order of the graphes drawed by DrawSprite(), DrawLine(), DrawTexLine() and DrawBox()?
How?
I've noticed that lines drawed by DrawLine()  is always on the top of other graphes, is there a way to explicitly set the cascading index?
Q2:How to draw a polygon or polyline?Or how to call function "DrawPolygon()/DrawPolyline()"?
Q3:Can I draw a sector or arch?How?
Q4:Besides DrawTexLine(),is there a way to draw an ellipse?How?
Q5:Can I use the "TextureLoader" to draw text?Though Aino's function DrawText() is very useful, it will be great to use the build-in functions~

Pilchard123:
1) It depends on the order you draw them. They will always be on top of the asteroids.

2) I made a polygon drawing function, it's around somewhere (I'll look for it)

3) Not easily

4) I don't think so

5) Don't know

Pilchard123:
DrawPoly()

http://www.euflorium.com/index.php?topic=1359.msg9403

Aino:
3:
Using math.sin and math.cos you can find the angles on screen, now you just got to do a for loop and draw hundreds of lines.


--- Code: ---function DrawArc(x,y, width, height, startAngle, arcAngle, r1, g1, b1,a1, r2,g2,b2,a2, lineWidth)
local numLines = 32
for i = 0,numLines-1 do
DrawLine(x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*width, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*height,
x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*width, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*height,
r1,b1,g1,a1, r1+(r2-r1)*i/numLines, b1+(b2-b1)*i/numLines, g1+(g2-g1)*i/numLines, a1+(a2-a1)*i/numLines, lineWidth);
end
end
function DrawArc(x,y, radius, startAngle, arcAngle, r1, g1, b1,a1, r2,g2,b2,a2, lineWidth)
local numLines = 32
for i = 0,numLines-1 do
DrawLine(x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*radius, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*radius,
x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*radius, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*radius,
r1,b1,g1,a1, r1+(r2-r1)*i/numLines, b1+(b2-b1)*i/numLines, g1+(g2-g1)*i/numLines, a1+(a2-a1)*i/numLines, lineWidth);
end
end
function DrawArc(x,y, radius, startAngle, arcAngle, r, g, b,a, lineWidth)
local numLines = 32
for i = 0,numLines-1 do
DrawLine(x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*radius, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*radius,
x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*radius, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*radius,
r,b,g,a, r,b,g,a, lineWidth);
end
end
function DrawArc(x,y, radius, startAngle, arcAngle, r, g, b,a, lineWidth, numLines)
if (numLines > 0) then
for i = 0,numLines-1 do
DrawLine(x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*radius, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*radius,
x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*radius, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*radius,
r,b,g,a, r,b,g,a, lineWidth);
end
end
end
function DrawArc(x,y, width, height, startAngle, arcAngle, r1, g1, b1,a1, r2,g2,b2,a2, lineWidth, numLines)
if (numLines > 0) then
for i = 0,numLines-1 do
DrawLine(x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*width, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*i/numLines)*height,
x+math.cos(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*width, y+math.sin(startAngle/180*math.pi+arcAngle/180*math.pi*(i+1)/numLines)*height,
r1,b1,g1,a1, r1+(r2-r1)*i/numLines, b1+(b2-b1)*i/numLines, g1+(g2-g1)*i/numLines, a1+(a2-a1)*i/numLines, lineWidth);
end
end
end

--- End code ---

It's a little math heavy, but this functions means you won't need to write it. You can(and should IMO) check out the maths, and please don't ask for a fill function.
I don't know if you can take all of them and copy them into your code though, so pick a favorite and print it in (I recommend the last one!) :)
And one more note: THEY US DEGREES, NOT RADIANS.

5:
Using the inbuilt DrawText function from the game: DrawText(text,x,y,alpha,size) the size is a tricky one, it's not normal font size, I think it's sizemultiplication of the image size, which means it would be easy to find where the next line should be :)

Breakord:

--- Quote from: Pilchard123 on February 10, 2013, 06:00:49 PM ---1) It depends on the order you draw them. They will always be on top of the asteroids.

2) I made a polygon drawing function, it's around somewhere (I'll look for it)

3) Not easily

4) I don't think so

5) Don't know

--- End quote ---
Sorry to reply so late,New Year's day is a bit busy ~
1)Not so simple, for example,  box drawn by DrawBox(5,...)is always on the top of sprite drawn by DrawSprite(1,...)
2)Nice dude!
Thank you !

Navigation

[0] Message Index

[#] Next page

Go to full version