|
mansie
|
 |
« on: September 10, 2008, 06:41:40 AM » |
|
Not sure if this will help anyone - but the 2d line draw function in 6.5 has no width change parameter, which makes it a bit limited  . So, I've written a small procedure which takes 5 parameters - fromX, fromY, toX, toY,widthofline. And draws a nice thick line with rounded ends! It took me a little while to work out the trig (I'm a little rusty) so hopefully it'll save someone else having to do the same! Private Sub myline(x1 As Single, y1 As Single, x2 As Single, y2 As Single,w As Single)
Dim m As Single Dim n As Single Dim a As Single Dim x As Single Dim y As Single Dim l As Single
'circle at the intersection for smoothness... and single point 'lines' screen2D.Draw_FilledCircle x1, y1, w, 20, RGBA(1, 1, 1, 1)
' base line x = x2 - x1 'height y = y2 - y1
' Work out the line length l = Sqr((x * x) + (y * y)) 'check for zero line length If l = 0 Then Exit Sub
'angle a = math.ACos(x / l) - 90 If y2 >= y1 Then m = w * (Sin(math.Deg2Rad(a - 90))) n = w * -(Cos(math.Deg2Rad(a - 90))) End If If y2 < y1 Then m = w * (Sin(math.Deg2Rad(a + 90))) n = w * (Cos(math.Deg2Rad(a + 90))) End If
'put in the first triangle screen2D.Draw_FilledTriangle (x1 + m), (y1 + n), (x2 - m), (y2 - n), (x2 + m), (y2 + n), RGBA(1, 1, 1, 1) 'then the second to make a filled rectangle... screen2D.Draw_FilledTriangle (x1 + m), (y1 + n), (x1 - m), (y1 - n), (x2 - m), (y2 - n), RGBA(1, 1, 1, 1)
'and round off the end screen2D.Draw_FilledCircle x2, y2, w, 20, RGBA(1, 1, 1, 1)
End Submansie
|
|
|
|
|
Logged
|
|
|
|
AriusEso
Customers
Community Member
    
Posts: 377
Esoteric
|
 |
« Reply #1 on: September 10, 2008, 06:46:37 AM » |
|
lol A line with a thicker width than 1 pixel is no longer a line. It is a rect. TV has functions for this already, rounded ones too. 
|
|
|
|
|
Logged
|
|
|
|
|
mansie
|
 |
« Reply #2 on: September 10, 2008, 06:53:57 AM » |
|
Really? You can you draw a rectangle from (say) 100,100 to 300,200 with any 'width' and with rounded ends?
What is this function - I cant find it, but if it exists - looks like I've done all this for nothing!
|
|
|
|
|
Logged
|
|
|
|
AriusEso
Customers
Community Member
    
Posts: 377
Esoteric
|
 |
« Reply #3 on: September 10, 2008, 07:02:00 AM » |
|
Aha, I checked the header. It doesn't have rounded. But you can use this for a thicker line:
void Draw_FilledBox(float x1, float y1, float x2, float y2, int color1 = -1, int color2 = -2, int color3 = -2, int color4 = -2);
After all, a thick line is simply a filled quad/box.
|
|
|
|
|
Logged
|
|
|
|
WEst
Community Member

Posts: 813
Daniel Martinek
|
 |
« Reply #4 on: September 10, 2008, 08:17:32 AM » |
|
Aha, I checked the header. It doesn't have rounded. But you can use this for a thicker line:
void Draw_FilledBox(float x1, float y1, float x2, float y2, int color1 = -1, int color2 = -2, int color3 = -2, int color4 = -2);
After all, a thick line is simply a filled quad/box.
But thats not a line with width, its a rectangle in screenspace coordinates, a line with width is imho an aligned rectangle with its width (normally smaller than length) being normal to its direction.
|
|
|
|
|
Logged
|
Greetings
Daniel Martinek Lead Programmer Roaming Nova Studios
|
|
|
AriusEso
Customers
Community Member
    
Posts: 377
Esoteric
|
 |
« Reply #5 on: September 10, 2008, 08:24:46 AM » |
|
But thats not a line with width, its a rectangle in screenspace coordinates, a line with width is imho an aligned rectangle with its width (normally smaller than length) being normal to its direction.
Depends whether you're talking a 3D line or a 2D line, no? Unless I'm misunderstanding what you mean. In this case I think he means a 2D line.
|
|
|
|
|
Logged
|
|
|
|
|
mansie
|
 |
« Reply #6 on: September 10, 2008, 08:54:51 AM » |
|
Let me explain....
If I need to draw a thick line, of a certain thickness, from one screen coordinate to another, in 2d, then drawing a filled rectangle doesn't really do it. Hence my routine.
Mansie
|
|
|
|
|
Logged
|
|
|
|
|
Raine
|
 |
« Reply #7 on: September 10, 2008, 09:04:15 AM » |
|
In layman terms, you wanna draw a line to point x1y1 to point x2y2 no matter what - this excludes drawing a rect instead of a line, since it would only work if the coords make sure the borders are parallel to the screen axis. You can't draw a rotated line with a the tv draw rect function.
Is this correct? :S
|
|
|
|
|
Logged
|
|
|
|
|
mansie
|
 |
« Reply #8 on: September 10, 2008, 09:17:10 AM » |
|
Thats correct. It's what my procedure (above) does.
I'm using it as part of a freehand drawing application in which the coordinates come from the mouse x,y position, and it draws a freehand line, on a 2d background, with each segment of the line connected to the end of the previous line, to create a continuous wavy line.
|
|
|
|
|
Logged
|
|
|
|
AriusEso
Customers
Community Member
    
Posts: 377
Esoteric
|
 |
« Reply #9 on: September 10, 2008, 09:38:17 AM » |
|
Ahh, I guess I was mistaken then. It is like 4pm and I still haven't been to bed yet, so forgive me  .
|
|
|
|
|
Logged
|
|
|
|
jviper
Community Member

Posts: 1365
Discipline in training
|
 |
« Reply #10 on: September 10, 2008, 12:15:34 PM » |
|
There is a draw custom polygon.
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
|