From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making a 2D array triangle?

Solved!
Go to solution

Hi, I was wondering how would one create a triangle shape from a 2D array? For example, if I wanted to create a 'white' 2x2 square, I would initialise a 2x2 square with values of 255. But I don't see how you could represent a diagonal line in a 2D array, such as in the case of a triangle. Note : I'm not looking to do this in IMAQ or using any picture functions, just in array format.

0 Kudos
Message 1 of 6
(4,925 Views)
Solution
Accepted by topic author Nik1

Doing some bitmap graphics, are we? Smiley Wink

 

Isosceles, scalene, right, or equilateral? Filled in, or only the border?

 

Obviously, you can't "draw" a triangle with a 2x2 array. You'd need to draw on a "diagonal", similar to the way you draw diagonal lines in the VI Icon Editor. You can think of the Icon Editor as a 2D array, and you can see how the individual array "elements" are filled to draw the line. If you're going to limit it equilateral then it's much simpler since you're always drawing on the actual diagonal for 2 of the sides.

0 Kudos
Message 2 of 6
(4,908 Views)

Nah just some code testing on simple patterns but it doesnt like IMAQ etc. Yeah I dont really want to draw a triangle just a diagonal line from one corner of a 1000x100 array to the opposite top corner, doesnt seem possible to do this without creating a jagged edge along the diagonal instead of a straight line.

0 Kudos
Message 3 of 6
(4,872 Views)

Hello,

every Line is jagged on any PC using Pxeils to diplay it. It is called Aliasing and you can see it an any image, if you look carefully (with no cleartype etc activated, just look at the / in your Browsers Adressline).

What you can do is to smooth edges (Look for Anti-Aliasing)

0 Kudos
Message 4 of 6
(4,862 Views)

yeah I was wondering if there was any inbuilt labview function for this, nevermind, thanks anyway.

0 Kudos
Message 5 of 6
(4,854 Views)

ScreenHunter_01 Aug. 03 18.40.gifThis is the best I could come up with. lol

CLD Certified 2014
0 Kudos
Message 6 of 6
(4,828 Views)