Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / How to draw fast thick lines with (optional) curved ends!

Author
Message
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Apr 2007 23:01
You will require two images, but they are just a circle and a square so can easily be created by your program if you want.
You only need the circle image if you want curved ends on your line.

You need two sprites, for the two images which should be created before hand. I have used sprites 1 and 2 here, but you can use any numbers. Sprite 1 is the circle image, sprite 2 the square.

Both images should be 100x100 (or you won't be able to get every size of line).
The square should fill the whole image, and be filled white.
The circle should fill its image, and be filled white.
The circle should have a transparent background.
Here are the images I used:


x1,y1 define the start of the line
x2,y2 define the end of the line
r,g,b define the colour
thickness defines the width of the line



enjoy

Login to post a reply

Server time is: 2024-11-22 18:26:57
Your offset time is: 2024-11-22 18:26:57