Eufloria > Eufloria Classic Mods

Questions about [drawing]

<< < (2/2)

Breakord:

--- Quote from: Aino on February 10, 2013, 08:23:40 PM ---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 :)

--- End quote ---

3.Awesome!Though, it is a pity that there are no build-in functions...
5.I think now I understand what makes you want to write a new DrawText()...=_=
Thank you!
Sorry to reply so late, New Year's day is a bit busy...

Aino:

--- Quote from: Breakord on February 18, 2013, 11:00:07 AM ---3.Awesome!Though, it is a pity that there are no build-in functions...
5.I think now I understand what makes you want to write a new DrawText()...=_=
Thank you!
Sorry to reply so late, New Year's day is a bit busy...

--- End quote ---

The real reason why I wrote the DrawText function was basically because nobody really knew that there were any built-in DrawText function back then, unless people have been lying to me all along... :o

However, now it's optional to use my function or the built-in one. The built-in one provides better performance, but mine provides more customization. I'm actually using the built-in one most because I like it best...

Navigation

[0] Message Index

[*] Previous page

Go to full version