Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Suggestion for developers of AppGameKit , Could you make a 'DrawTriangle' command?

Author
Message
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 25th Oct 2018 15:41 Edited at: 25th Oct 2018 15:42
As I experiment with the 'drawing' commands, I always would like something extra.
I think it would be very useful for me, and I might use it very often....

In the 'Core' commands under sub-heading 'Drawing'; I would like a 'DrawTriangle' command.

Perhaps it would look like this example below:

DrawTriangle( x1, y1, x2, y2, x3, y3, color1, color2, color3, filled )

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 25th Oct 2018 15:47
It may not be what you asked but here is my triangle function I used in one app


it should be easy enough converted to what you are asking
fubar
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Oct 2018 16:22
Drawing a 2D unfilled triangle is easy enough



Drawing a filled one is harder though..... but it is still possible. It involves setting up an object of one triangle...then editing its positions, vertex colours and then drawing it with DrawObject()

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 25th Oct 2018 16:38
great piece of code bengismo


I think if there was an added scale variable in the call function
a for next loop could be used to enlarge it by the scale factor with a bit of math producing a filled triangle
that would just draw lines from the start perimeters to the outer scale



Really would like a flood fill command
fubar
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 25th Oct 2018 16:46 Edited at: 25th Oct 2018 16:52
Yes, but there's no (fill) function on yours , or did I miss it?

I need the fill function - DrawTriangle( x1, y1, x2, y2, x3, y3, color1, color2, color3, filled )

That means if I put a 1 where it says 'filled', then the Triangle will fill with a blend of all 3 colors.

Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Oct 2018 16:47
That wouldn't actually work as it scales all the positions of the triangle away from 0,0 so you wouldnt actually end up with a triangle at all. It would work if the x,y values were scaled relative to the centre of the triangle though.

Plus, thae method above would be very slow.... especially for large triangles. Loads of drawline commands to fill an area is not great.

The "easiest" method that is also quick is to use a shader and just draw a rectangular sprite which doesnt draw pixels outside of the triangle sides. Would be quick and one drawcall.

Otherwise its a single object with a single triangle in it which is drawn with draw object.
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Oct 2018 16:49 Edited at: 25th Oct 2018 16:49
Bubba wrote: "Yes, but there's no (fill) function on yours , or did I miss it?"


Maybe missed the part where I said....

Bengismo wrote: "Drawing a filled one is harder though..... but it is still possible. It involves setting up an object of one triangle...then editing its positions, vertex colours and then drawing it with DrawObject()"
Jerry McGuire
7
Years of Service
User Offline
Joined: 25th Mar 2017
Location:
Posted: 25th Oct 2018 17:01 Edited at: 25th Oct 2018 17:05
I am not sure why you are putting 3 colors. Do you mean RGB, or do you mean a color for each corner of the triangle. The latter would mean a gradient. If you mean a single color, you could use sth similar to what has already been said: first do a big squared PNG, fill one of the two triangles with white and the other transparent. Now you can build a function that resizes, positions, and "paints" the white triangle. Of course if you don't want it "filled" than your function would draw the three lines. Because you are using a big PNG and resizing it when loading the image, the quality will be pretty good and the sprite will not be heavy like the large, original PNG.
AppGameKit 2018.10.10

iMac Book Pro, MacOS 10.14, Xcode 9.4.1;
iPhone 6, iOS 12; iPad (3rd gen), iOS 9.35; iPad Pro 12'9 (2nd gen), iOS 12.

Dell Precision T7400, Windows 7 Professional 64bit, Visual Studio Community 2017;
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Oct 2018 17:16
I think he wants a colour for every corner of the triangle....similar to DrawBox() and DrawEllipse()

You can do it with perfect image quality (and even put a texture on it if wanted) with the draw object method mentioned above




i think that he wants it built in though so paul will have to take a look at it.
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 26th Oct 2018 00:15
Check out the community shader thread, I posted some shaders where you can create 2d primitives like a triangle or hexagon with, including borders.

[/url]
puzzler2018
User Banned
Posted: 26th Oct 2018 00:23 Edited at: 26th Oct 2018 00:25
AGK is fully shaderised when we compile and run our apps - its all converted to shader code. So yes - this would be very helpful. Shaders is the way to go..

Save the interepreter from doing things - why dont we directly proramming the GPU, which AppGameKit does on our behalf anyway - that would be awesome

Do we know GLSL language

Login to post a reply

Server time is: 2024-11-23 12:05:07
Your offset time is: 2024-11-23 12:05:07