Function:ns2vthcline
From S2PLOT
(Difference between revisions)
Revision as of 22:48, 6 January 2009 S2plot admin (Talk | contribs) ← Previous diff |
Current revision S2plot admin (Talk | contribs) |
||
Line 1: | Line 1: | ||
==ns2vthcline== | ==ns2vthcline== | ||
- | Draw a hick coloured line. | + | Draw a thick coloured line - vector input. |
==Prototype== | ==Prototype== | ||
Line 12: | Line 12: | ||
==See Also== | ==See Also== | ||
+ | <table> | ||
+ | <tr><td>[[Function:ns2thcline | ns2thcline ]]</td><td>Draw a thick coloured line. </td></tr> | ||
+ | <tr><td>[[Function:ns2line | ns2line ]]</td><td>Draw a line from one point to another in a specific colour.</td></tr> | ||
+ | <tr><td>[[Function:ns2vline | ns2vline ]]</td><td>Draw a line from one point to another in a specific colour - vector input. </td></tr> | ||
+ | <tr><td>[[Function:ns2thline | ns2thline ]]</td><td>Draw a thick line from one point to another in a specific colour. </td></tr> | ||
+ | <tr><td>[[Function:ns2vthline | ns2vthline ]]</td><td>Draw a thick line from one point to another in a specific colour - vector input. </td></tr> | ||
+ | <tr><td>[[Function:ns2cline | ns2cline ]]</td><td>Draw a coloured line, with colour blended between the two given colours along the line. </td></tr> | ||
+ | <tr><td>[[Function:ns2vcline | ns2vcline ]]</td><td>Draw a coloured line, with colour blended between the two given colours along the line - vector input. </td></tr> | ||
+ | </table> | ||
==Code Example== | ==Code Example== | ||
<code><pre> | <code><pre> | ||
- | </pre></code> | + | #include <stdio.h> |
+ | #include <stdlib.h> | ||
+ | #include <time.h> | ||
+ | #include "s2plot.h" | ||
- | [[S2PLOT:Function List | Back]] to S2PLOT function list. | + | int main(int argc, char *argv[]) |
+ | { | ||
+ | XYZ start; /* Start of line */ | ||
+ | XYZ end; /* End of line */ | ||
+ | COLOUR col1; /* Colour of line segment (start) */ | ||
+ | COLOUR col2; /* Colour of line segment (end) */ | ||
+ | float size; /* Line thickness */ | ||
+ | int N = 10; /* Number of lines */ | ||
+ | int i; /* Loop variable */ | ||
+ | srand48((long)time(NULL)); /* Seed random numbers */ | ||
+ | s2opend("/?",argc, argv); /* Open the display */ | ||
+ | s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */ | ||
+ | s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */ | ||
+ | s2sci(S2_PG_YELLOW); /* Set colour */ | ||
+ | for (i=0;i<N;i++) { | ||
+ | start.x = drand48()*2.0 - 1.0; /* Random (x,y,z) coordinates */ | ||
+ | start.y = drand48()*2.0 - 1.0; | ||
+ | start.z = drand48()*2.0 - 1.0; | ||
+ | end.x = drand48()*2.0 - 1.0; /* Random (x,y,z) coordinates */ | ||
+ | end.y = drand48()*2.0 - 1.0; | ||
+ | end.z = drand48()*2.0 - 1.0; | ||
+ | col1.r = drand48(); | ||
+ | col1.g = drand48(); | ||
+ | col1.b = drand48(); | ||
+ | col2.r = drand48(); | ||
+ | col2.g = drand48(); | ||
+ | col2.b = drand48(); | ||
+ | size = drand48()*10.0; | ||
+ | ns2vthcline(start, end, col1, col2, size); /* Draw the thick line */ | ||
+ | } | ||
- | __NOTOC__ | + | s2show(1); /* Open the s2plot window */ |
- | __NOEDITSECTION__ | + | |
+ | return 1; | ||
+ | } | ||
+ | </pre></code> | ||
- | Back to [[Function:Template | template]] page. | + | [[S2PLOT:Function List | Back]] to S2PLOT function list. |
+ | |||
+ | __NOTOC__ | ||
+ | __NOEDITSECTION__ |
Current revision
ns2vthcline
Draw a thick coloured line - vector input.
Prototype
void ns2vthcline(XYZ P1, XYZ P2, COLOUR col1, COLOUR col2, float width);
Description
Draw a thick coloured line, with colour blended between the two given colours along the line, and given width.
See Also
ns2thcline | Draw a thick coloured line. |
ns2line | Draw a line from one point to another in a specific colour. |
ns2vline | Draw a line from one point to another in a specific colour - vector input. |
ns2thline | Draw a thick line from one point to another in a specific colour. |
ns2vthline | Draw a thick line from one point to another in a specific colour - vector input. |
ns2cline | Draw a coloured line, with colour blended between the two given colours along the line. |
ns2vcline | Draw a coloured line, with colour blended between the two given colours along the line - vector input. |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"
int main(int argc, char *argv[])
{
XYZ start; /* Start of line */
XYZ end; /* End of line */
COLOUR col1; /* Colour of line segment (start) */
COLOUR col2; /* Colour of line segment (end) */
float size; /* Line thickness */
int N = 10; /* Number of lines */
int i; /* Loop variable */
srand48((long)time(NULL)); /* Seed random numbers */
s2opend("/?",argc, argv); /* Open the display */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
s2sci(S2_PG_YELLOW); /* Set colour */
for (i=0;i<N;i++) {
start.x = drand48()*2.0 - 1.0; /* Random (x,y,z) coordinates */
start.y = drand48()*2.0 - 1.0;
start.z = drand48()*2.0 - 1.0;
end.x = drand48()*2.0 - 1.0; /* Random (x,y,z) coordinates */
end.y = drand48()*2.0 - 1.0;
end.z = drand48()*2.0 - 1.0;
col1.r = drand48();
col1.g = drand48();
col1.b = drand48();
col2.r = drand48();
col2.g = drand48();
col2.b = drand48();
size = drand48()*10.0;
ns2vthcline(start, end, col1, col2, size); /* Draw the thick line */
}
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.