help creating a triangle in corona

I need to find the area of a triangle for my class at school and I am using corona but when I try to draw a new triangle like you do a rectangle it gives me an error my code is display.newTriangle(20,20,10,40,20,40) so why doesnt it work but I can make it work for a rectangle? [import]uid: 211931 topic_id: 36184 reply_id: 336184[/import]

Hey, @bud.hooke, take a look at this API doc:

http://docs.coronalabs.com/api/

I see display.newRect() but I don’t see display.newTriangle() – so it’s not something you can use to create triagles.

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143679[/import]

Thanks naomi how do I create a triangle in corona then and also it is a triangle I want to create and not a triagle I dont know what that is is it a different form of a triangle and how do you create triangles in corona please? I thought corona was meant to be easy and sometimes it seems like it is sometimes but this is frustrating and I need to go to bed but I dont want to fail my homework tomorrow so can you please tell me how to do it thanks? [import]uid: 211931 topic_id: 36184 reply_id: 143681[/import]

Hey, @bud.hooke, I’m not sure what your homework is really about. Does your class require you to complete this triangle assignment using Corona SDK and no other tool?

If I were to display a triangle with certain attributes on a mobile device (and if that’s the assignment I’m given and if I’m allowed to use other software in addition to Corona SDK), I’d probably create a png file with a single triangle with exact size and color attributes. I may programmatically rotate it, but otherwise, the triangle image would be pre-made outside Corona and then I’d display it using display.newImageRect()

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143682[/import]

Hey Bud,

I don’t see why you couldn’t create 3 lines and make them form a triangle. You know, like a 3/4/5 triangle. I’m sure you could then create the function if LineA = x pixels long, then LineB = (), LineC = () and then the area of triangle (). Or maybe you use height and base…

Hope this helps,

Nail [import]uid: 106779 topic_id: 36184 reply_id: 143686[/import]

Good one, Nail. Yeah, that sounds more like what @bud.hooke might be looking for.

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143687[/import]

@bud

I’ve heard these called ‘polylines’ before.

You can start with one line, then add segments to it.

I wrote a small helper function to make triangles to illustrate:

[lua]
local function triangle(x1,y1,x2,y2,x3,y3)
local triangle = display.newLine(x1,y1,x2,y2)
triangle:append(x3,y3,x1,y1)
return triangle
end
local myTriangle1 = triangle(50,200,100,210,10,210)
local myTriangle2 = triangle(0,160,70,180,40,110)
local myTriangle3 = triangle(10,20,300,40,50,60)
[/lua]

Found this article while googling coronasdk +polylines: http://developer.coronalabs.com/forum/2010/12/24/polylines-10-sample-code
[import]uid: 135765 topic_id: 36184 reply_id: 143688[/import]

Hey, @bud.hooke, take a look at this API doc:

http://docs.coronalabs.com/api/

I see display.newRect() but I don’t see display.newTriangle() – so it’s not something you can use to create triagles.

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143679[/import]

Thanks naomi how do I create a triangle in corona then and also it is a triangle I want to create and not a triagle I dont know what that is is it a different form of a triangle and how do you create triangles in corona please? I thought corona was meant to be easy and sometimes it seems like it is sometimes but this is frustrating and I need to go to bed but I dont want to fail my homework tomorrow so can you please tell me how to do it thanks? [import]uid: 211931 topic_id: 36184 reply_id: 143681[/import]

Hey, @bud.hooke, I’m not sure what your homework is really about. Does your class require you to complete this triangle assignment using Corona SDK and no other tool?

If I were to display a triangle with certain attributes on a mobile device (and if that’s the assignment I’m given and if I’m allowed to use other software in addition to Corona SDK), I’d probably create a png file with a single triangle with exact size and color attributes. I may programmatically rotate it, but otherwise, the triangle image would be pre-made outside Corona and then I’d display it using display.newImageRect()

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143682[/import]

Hey Bud,

I don’t see why you couldn’t create 3 lines and make them form a triangle. You know, like a 3/4/5 triangle. I’m sure you could then create the function if LineA = x pixels long, then LineB = (), LineC = () and then the area of triangle (). Or maybe you use height and base…

Hope this helps,

Nail [import]uid: 106779 topic_id: 36184 reply_id: 143686[/import]

Good one, Nail. Yeah, that sounds more like what @bud.hooke might be looking for.

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143687[/import]

@bud

I’ve heard these called ‘polylines’ before.

You can start with one line, then add segments to it.

I wrote a small helper function to make triangles to illustrate:

[lua]
local function triangle(x1,y1,x2,y2,x3,y3)
local triangle = display.newLine(x1,y1,x2,y2)
triangle:append(x3,y3,x1,y1)
return triangle
end
local myTriangle1 = triangle(50,200,100,210,10,210)
local myTriangle2 = triangle(0,160,70,180,40,110)
local myTriangle3 = triangle(10,20,300,40,50,60)
[/lua]

Found this article while googling coronasdk +polylines: http://developer.coronalabs.com/forum/2010/12/24/polylines-10-sample-code
[import]uid: 135765 topic_id: 36184 reply_id: 143688[/import]

Hey, @bud.hooke, take a look at this API doc:

http://docs.coronalabs.com/api/

I see display.newRect() but I don’t see display.newTriangle() – so it’s not something you can use to create triagles.

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143679[/import]

Thanks naomi how do I create a triangle in corona then and also it is a triangle I want to create and not a triagle I dont know what that is is it a different form of a triangle and how do you create triangles in corona please? I thought corona was meant to be easy and sometimes it seems like it is sometimes but this is frustrating and I need to go to bed but I dont want to fail my homework tomorrow so can you please tell me how to do it thanks? [import]uid: 211931 topic_id: 36184 reply_id: 143681[/import]

Hey, @bud.hooke, I’m not sure what your homework is really about. Does your class require you to complete this triangle assignment using Corona SDK and no other tool?

If I were to display a triangle with certain attributes on a mobile device (and if that’s the assignment I’m given and if I’m allowed to use other software in addition to Corona SDK), I’d probably create a png file with a single triangle with exact size and color attributes. I may programmatically rotate it, but otherwise, the triangle image would be pre-made outside Corona and then I’d display it using display.newImageRect()

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143682[/import]

Hey Bud,

I don’t see why you couldn’t create 3 lines and make them form a triangle. You know, like a 3/4/5 triangle. I’m sure you could then create the function if LineA = x pixels long, then LineB = (), LineC = () and then the area of triangle (). Or maybe you use height and base…

Hope this helps,

Nail [import]uid: 106779 topic_id: 36184 reply_id: 143686[/import]

Good one, Nail. Yeah, that sounds more like what @bud.hooke might be looking for.

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143687[/import]

@bud

I’ve heard these called ‘polylines’ before.

You can start with one line, then add segments to it.

I wrote a small helper function to make triangles to illustrate:

[lua]
local function triangle(x1,y1,x2,y2,x3,y3)
local triangle = display.newLine(x1,y1,x2,y2)
triangle:append(x3,y3,x1,y1)
return triangle
end
local myTriangle1 = triangle(50,200,100,210,10,210)
local myTriangle2 = triangle(0,160,70,180,40,110)
local myTriangle3 = triangle(10,20,300,40,50,60)
[/lua]

Found this article while googling coronasdk +polylines: http://developer.coronalabs.com/forum/2010/12/24/polylines-10-sample-code
[import]uid: 135765 topic_id: 36184 reply_id: 143688[/import]

Hey, @bud.hooke, take a look at this API doc:

http://docs.coronalabs.com/api/

I see display.newRect() but I don’t see display.newTriangle() – so it’s not something you can use to create triagles.

Naomi [import]uid: 67217 topic_id: 36184 reply_id: 143679[/import]