X_LINE needed with 2 colours

Previous topic - Next topic

retrotech

I need a function like X_LINE but with 2 colours so that the colour varies from  point 1 to point 2.  Thanx.
"I am not young enough to know everything." - Oscar Wilde

matchy

#1
Isn't that just simply a facet? :S

Perhaps you can just plot X_DOT?

Note, X_LINE and X_DOT are not the same as X_DRAWOBJ.

Kitty Hello

you must do that with inline and opengl calls.

Another option is to draw the line to a texture, then roto-zoom the "sprite" to the position. I did that once...

Code (glbasic) Select

FUNCTION StretchBlock: id, x, y, phi, width, tx
LOCAL sx, sy, dx, dy, col
LOCAL upx, upy, rightx, righty
GETSPRITESIZE id, sx, sy
dx = COS(phi)
dy = -SIN(phi)

// half a block
upx =  dy*sy/2
upy = -dx*sy/2
rightx=dx*sx/2
righty=dy*sx/2
width = width/sx
tx = tx/sx

col = RGB(255,255,255)
STARTPOLY id
POLYVECTOR x+upx-rightx, y+upy-righty, 0, 0,col
POLYVECTOR x-upx-rightx, y-upy-righty, 0,sy,col
POLYVECTOR x-upx+rightx*(1+width*2), y-upy+righty*(1+width*2), INTEGER(tx+1)*sx, sy, col
POLYVECTOR x+upx+rightx*(1+width*2), y+upy+righty*(1+width*2), INTEGER(tx+1)*sx,  0, col
ENDPOLY
ENDFUNCTION



I don't really know how to use the function anymore, but it's a simple startpoint (x,y), phi=rotation angle, width=new length of the "line" and tx is the right texture coordinate point. I think.

Slydog

You could create your line using polyvectors.
Check out this thread, I posted a custom 'line' type that converts the two points, plus thickness into polyvectors.
http://www.glbasic.com/forum/index.php?topic=4301.msg52041#msg52041

You'll just need to change the four corner colours (all are the same I think in the demo) and you can have a gradient between the two points (or side to side, or have all four corners different).
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]