Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Utility] Stroke  (Read 18345 times)

0 Members and 1 Guest are viewing this topic.

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
[Utility] Stroke
« on: February 17, 2010, 03:05:12 am »
Hi there!

It doesn't come often that I post some code I made since I focus only on my shmup project. To change this bad habit, I post a little class I made during those 4 last days.

Stroke help you to draw lines from an array of points. Stroke allow you to change the stroke appearance and behavior throught many functions, like its thickness, inner and outer colors, textures, start and end thickness, smoothness (or sweepness), lifetime and many other things.

At first, this was a class to help me draw spaceship trails for my shmup, but with time it became a more general class.

I took exemple from sf::Shape and sf::Sprite to compose this class.

Here is a small exemple of what you can do with it :
http://www.megaupload.com/?d=63QNKJ1M

And the Visual Studio project with sources :
http://www.megaupload.com/?d=VNW70BRA

In few words, you have 4 files :
- .cpp and .h of the Stroke class,
- my_utility.h, regrouping some math function from the wiki and many other functions I added, like Spline/Bezier function, collisions detection, etc... Functions numbered 2 are for inverted Y axis reference. I apologize but I didn't take time to write english comments, thoses are french ones, but most of function name are explicit.
(Just in case, the ResampleBezier one convert an array of non-equidistant points generated from previous Bezier fonction to another array of equidistant ones of same size.)
- The main.cpp used to create the exemple.

The sources are a bit commented but the class isn't documented.

I hope you will find some use for this class in your projects. :]

And of course, if you want to enhance the class with optimization or new features, feel free to do and share. :D There is plainty of things to do about this class.

EDIT : Last version on the wiki!
Quote

A video :
A binary exemple (win32) : http://www.megaupload.com/?d=TACO1MWW
The sources of the binary : http://www.megaupload.com/?d=1U5BS38W
And the wiki : http://www.sfml-dev.org/wiki/en/sources/stroke

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
[Utility] Stroke
« Reply #1 on: February 17, 2010, 03:46:46 am »
I just had a look at the example, and it looks fantastic!
This could actually replace the need for a full particle engine in many situations, and more. Very impressive!

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
[Utility] Stroke
« Reply #2 on: February 17, 2010, 04:52:23 pm »
I added some stuff since last night :

Stroke 1.1
- "M_PI" constant has been renamed to "pi".
- A new "stippling" parameter has been added. It allow to add a stip or dot effect to the stroke.
- The exemple file has been updated with the new stippling effect.
- The joint adding system has been enhanced. You don't need to place all the joint of a single straitgh line to build it anymore. Just add the two extremities of the line after specifying a minimum segment lenght (SetMinSegmentLenght()), it will build itself.
- If you give 0 (default value) to the min_segment_lenght parameter, it will no longer add intermediate joints or ignore your joint will placing it. Much better for custom static strokes (road exemple).

Exemple :
http://www.megaupload.com/?d=N0METJ00

Sources :
http://www.megaupload.com/?d=JOCPNNYU

JDieskau

  • Newbie
  • *
  • Posts: 6
    • View Profile
[Utility] Stroke
« Reply #3 on: February 17, 2010, 06:18:28 pm »
It looks very good. I will give it a try. But why are you using megaupload? It looks a little bit "unprofessional". Whats wrong with sourceforge/berlios/github/... ?

EDIT: What version of sfml do you use?

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
[Utility] Stroke
« Reply #4 on: February 17, 2010, 06:26:51 pm »
Huh, I just don't know those sites. =p

EDIT : I use SFML 2.0. Someone said the renderer is not available in SFML 1.5. I don't know if it will be accessible in SFML 1.6.

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
[Utility] Stroke
« Reply #5 on: February 17, 2010, 11:13:15 pm »
Here are some few changes :

- Fixed some issue with the joint adding function, making the stroke segments of irregular lenght.
- Added more consistent comments in the main and Stroke.h.
- Changed the my_utility.h's comments to english ones.
- Cleaned some function calls from the main. Thoses calls were here without real meaning.

Exemples :
http://www.megaupload.com/?d=ZJEKHM6W

Sources :
http://www.megaupload.com/?d=LQY9INDP

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
[Utility] Stroke
« Reply #6 on: February 18, 2010, 12:19:55 pm »
Excellent utility. I was looking for Bezier to compute roads yesterday lol :-D

T.T.H.

  • Full Member
  • ***
  • Posts: 112
    • View Profile
[Utility] Stroke
« Reply #7 on: February 18, 2010, 12:23:13 pm »
I didn't have a look at it yet but in case it's only 4 files you could even put them into SFML's wiki.

phear-

  • Jr. Member
  • **
  • Posts: 64
    • MSN Messenger - LOApokalypse@hotmail.com
    • View Profile
    • http://gtproductions.org
[Utility] Stroke
« Reply #8 on: February 18, 2010, 11:42:53 pm »
Didnt look at the source yet but seems like a neat idea.
Eugene Alfonso
GTP | Twitter

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
[Utility] Stroke
« Reply #9 on: August 05, 2010, 12:08:31 am »
Heya! After a few time working on my shmup, I returned on this class to upgrade it with features I need.

Here are the result : 4 rendering mode, shaking, looping for closed shapes, texture management and more.

Here are some links :

A video :
A binary exemple (win32) : http://www.megaupload.com/?d=TACO1MWW
The sources of the binary : http://www.megaupload.com/?d=1U5BS38W
And the wiki : http://www.sfml-dev.org/wiki/en/sources/stroke

Enjoy!

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
[Utility] Stroke
« Reply #10 on: August 05, 2010, 06:47:35 am »
Wow Spidyy this is amazing now!

ActionBoy

  • Newbie
  • *
  • Posts: 36
    • View Profile
[Utility] Stroke
« Reply #11 on: August 13, 2010, 09:36:40 pm »
Awesome. The road and the laser is just wow.

Nexxtron

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: [Utility] Stroke
« Reply #12 on: November 07, 2012, 12:32:55 am »
This class looks really amazing, but the Link is broken... :'(
Has anyone the example project and can upload it?
« Last Edit: November 07, 2012, 12:35:21 am by Nexxtron »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: [Utility] Stroke
« Reply #13 on: November 07, 2012, 01:52:37 am »
You're quite bold to bring up a two year old thread for you first post. ;D
Luckily around community doesn't have anything against that... ;)

Anyways the original author stated that he doesn't have the example anymore but he's working on a new version + example.

See here:
Quote from: Spidyy
Someone really wanted to use the Stroke class, so I'm working on it to port it to SFML 2.0 and give it a few enhancements.

Also I've made a dirty port of the library to SFML 2 here.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 190
    • View Profile
Re: [Utility] Stroke
« Reply #14 on: November 07, 2012, 02:10:45 pm »
Impressive! Why not put the code on GitHub?

 

anything