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

Author Topic: Selba Ward  (Read 145976 times)

0 Members and 1 Guest are viewing this topic.

salianifo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Selba Ward
« Reply #120 on: May 21, 2017, 10:57:54 pm »
Are you planning on adding a feature to the Nine Patch to allow multiple stretching sections? Something along the lines of what this post on StackOverflow is trying to achieve?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Selba Ward
« Reply #121 on: May 22, 2017, 02:40:32 pm »
There are currently no plans to expand Nine Patch to have more than nine patches although it can be a consideration for the future.

Note that it can be achieved by displaying Nine Patches together.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Selba Ward
« Reply #122 on: August 07, 2017, 05:17:52 pm »
Update!

Elastic Sprite (wiki)
v1.1
Added ability to use perspective interpolation instead of bi-linear interpolation.

Bi-linear interpolation can look 'rubbery' but remains evenly distributed and edges match easily. Note that lines can be bent (notice the red diagonal squares 0-9 in the examples below); then again, it is technically a similar method to calculating bezier curves...
Perspective interpolation adjusts the apparent 3D rotation of the quad to match the vertices' positions. This is similar to Photoshop's free transform's individual corner manipulation. Note that distribution is no longer even and edges will not match so easily.

Compare below.

Bi-linear:


Perspective:



One additional thing to note is that the RGB components of the sprite's colour are disabled when drawn using perspective interpolation; the alpha is used as normal.
The reason for this is because an extra "weight" float per vertex that would be interpolated like other vertex attributes is needed. Since SFML's vertex format is rigid and only has 2d position and texture co-ordinates, this value could not be passed through a spare. This led to the decision to encode the float into the three colour (RGB) components of the sprite's colour.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Selba Ward
« Reply #123 on: June 05, 2019, 02:51:57 am »
Updates!
(summary since previous post)

Console Screen (wiki)
v2.4.1
- Can stream numbers using the new Number type.
- Can now get cell location of a given co-ordinate
- Can get (transformed) co-ordinate of a cell location.
- New 8-bit RGB palette
- Can now set the cell value used for 'clearing' a cell; it is no longer required to be zero.
- Can now customise the multiplier used for darkening a cell's colour when using Dark attribute (Bright has been swapped for Dark).
(more info.)

Tile Map (wiki)
v2.0.1
- Now fully templated.
- Connect the level when needed rather than having to pass it with every update.
- Level width is now also stored and can be changed separately.

Elastic Sprite (wiki)
v1.2
- Fixed perspective interpolation when used with larger texture or offset
- Perspective interpolation can now be used with colours

Spline (wiki)
v1.5
Multiple corner types
These are applied at every point (except start and end points) including interpolated ones.
They allow corners to take a form that is different from the original 'point' corner.

The corner types available are:
Point
The original type. This extends the edges until they meet. This has no limit.
PointLimit
Similar to Point. This extends the edges until they meet. However, if the length of this point is greater than the maximum allowed length (customisable), this point is 'pulled inwards' until it reaches that length.
PointClip
Also similar to Point. This extends the edges until they meet. However, if the length of this point is greater than the maximum allowed length, this corner is converted into a bevel-style corner (see below).
Bevel
This does not extend the edges until they meet. The two corners of the rectangles - that make up the two joining thick straight lines - are joined together.
Round
This also does not extend the edges until they meet. This is similar to Bevel except the the corners are joined together using a circular curve. The interpolation level of round corners can also be customised; a level of zero is visually equivalent to a bevel corner.

Multiple cap types
Caps are how the start and end of the Spline are drawn.
Each cap (start and end) can be customised separately.
Available cap types:
None
This adds nothing to the spline. It therefore appears as a flat edge that passes across the vertex.
Extended
This extends the flat edge so that it is half of the thickness of the Spline away from the vertex. This leaves half thickness around the vertex.
Round
This adds a semicircle to the flat edge. The centre of the semicircle is the vertex. Its radius is half of the thickness. It reaches the same distance as the Extended type. This leave half thickness around the vertex.
The interpolation level of round corners can be customised; a level of zero is visually equivalent to "None" and a level of one is a "triangle" cap.

Random normal offsets
Each point (including all interpolated points) can be offset along its normal by a random amount. The range of this random distance can be customised. Each vertex also has this range so it is interpolated and multiplied in a similar way to the thickness and vertex thicknesses. The offset, however, is centred on the original Spline path. This allows 'lightning' style effects.

Optimisation
The updates have been optimised, allowing only the visual representation to be updated if the Spline itself hasn't moved or interpolation settings haven't changed. Basically, as long as it doesn't need to calculate the points or interpolation points, just the visual representation can be updated separately.

Note that the corner and cap types only apply to a thick Spline whereas the random normal offsets apply to both a thick and a thin Spline.

Simple Example 3b (thick with rounded corners and caps):


Simple Example 4b (thick with rounded corners and caps):


Simple Example 1b (random normal offsets - lightning):


General
Numerous fixes that include compiler errors or other bugs.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Mills

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: Selba Ward
« Reply #124 on: January 26, 2020, 11:40:57 pm »
I want to thank you for the amazing console screen, it is just what I was looking for, to make a simple text editor in SFML :).

Now I'm using CSFML, so I can't use this, but I wonder if I can build a little lib only with the console screen sources, or do I need to compile all sources for the console to work?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Selba Ward
« Reply #125 on: January 29, 2020, 09:12:22 pm »
Thank you for your kind words. It's always a good feeling when you hear that someone is enjoying Selba Ward.

I'm not sure I understand your move from C++ to C but I won't judge (too much) ;D

Selba Ward is built so that each drawable object can be used separately from any of the others. So, to use just Console Screen, you can simply copy the files into your project and link them. The (3) files you need would be ConsoleScreen.hpp, ConsoleScreen.cpp and Common.hpp. You could, if you wish, also include PaletteEnums.hpp if you wish to use those but this is not required. Then, just compile along with the rest of your project.
It's worth noting, though, that the files themselves are written in C++ so would need converting to plain C first. Or you could build just those files as a library and use that. Never needed to do this though so it may or may not work or even be possible.

Hope it works out for you!
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Mills

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: Selba Ward
« Reply #126 on: February 05, 2020, 05:40:56 pm »
Thank you for your kind words. It's always a good feeling when you hear that someone is enjoying Selba Ward.

I'm not sure I understand your move from C++ to C but I won't judge (too much) ;D

Selba Ward is built so that each drawable object can be used separately from any of the others. So, to use just Console Screen, you can simply copy the files into your project and link them. The (3) files you need would be ConsoleScreen.hpp, ConsoleScreen.cpp and Common.hpp. You could, if you wish, also include PaletteEnums.hpp if you wish to use those but this is not required. Then, just compile along with the rest of your project.
It's worth noting, though, that the files themselves are written in C++ so would need converting to plain C first. Or you could build just those files as a library and use that. Never needed to do this though so it may or may not work or even be possible.

Hope it works out for you!

Thanks a lot!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Selba Ward
« Reply #127 on: April 12, 2020, 08:44:29 pm »
Just saw that you added the Pixel Display and while reading through the wiki page, I wondered, why is there no shiftUp/shiftDown?  ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Selba Ward
« Reply #128 on: April 12, 2020, 11:41:28 pm »
Well spotted! However, there is a reason...

What scrolling does is pretty obvious. The scroll movement can happen in either direction of either of the two dimensions.
It moves the pixels around the 2D space.

Shifting is different and is similar to bit shifting.
All pixels are stored in a single, one dimensional vector that wraps across the 2D space.
Shifting left moves all pixels in the vector left within the vector. This means that on the 2D display, they wrap onto the row above, not the same row.

To be more clear with a simple example:
A similar effect is having a text editor with "wrap" enabled and lots of characters without any line breaks. If you delete the first character, they all shift to the left. The letters from the left of a row appear at the end of the row above. If you deleted most of the characters, you could end with the characters from the bottom now on the top line.


I've probably explained this far too detailed and most people would understand it from the first part (without the example). The example is just for clarity.

Hope that helps :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

sidewinder

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Selba Ward
« Reply #129 on: February 16, 2021, 02:48:08 pm »
Threadomancy incoming!

I decided to give the ElasticSprite a go but for some reason it draws the texture upside down. If I replace it with a regular sprite this does not happen.

The reduced relevant code would look something like this:

UPSIDE DOWN:
Quote
while (window.isOpen())
{
 window.clear();
 sf::RenderTexture pre;
 pre.create(resolutionX, resolutionY);
 //Write lots of stuff to pre
 pre.display();
 sw::ElasticSprite esprite(pre.getTexture());
 window.draw(esprite);
 window.display();
}

NOT UPSIDE DOWN
Quote
while (window.isOpen())
{
 window.clear();
 sf::RenderTexture pre;
 pre.create(resolutionX, resolutionY);
 //Write lots of stuff to pre
 pre.display();
 sf::Sprite sprite(pre.getTexture());
 window.draw(sprite);
 window.display();
}

Is there something I'm not allowed to do with my rendertexture before I write it using the elastic sprite?
 
 



fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: Selba Ward
« Reply #130 on: February 16, 2021, 05:37:08 pm »
You need to treat your render texture like a window - that is, create it only once, then call renderTexture.clear() before you draw on it, followed by renderTexture.display() when you've finished drawing.

sf::RenderTexture rt;
sf::RenderWindow rw;

rt.create(w,h);
rw.create(w,h);

while(rw.isOpen())
{
    rt.clear();
    //draw stuff
    rt.display();

    rw.clear();
    //draw other stuff
    rw.display();
}

 

sidewinder

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Selba Ward
« Reply #131 on: February 16, 2021, 06:03:52 pm »
You need to treat your render texture like a window - that is, create it only once, then call renderTexture.clear() before you draw on it, followed by renderTexture.display() when you've finished drawing.

Seems reasonable, and when/if I use it for real I'll do it that way  :)

I changed it in my experiment and its still upside down. And it works with a regular sprite  ???
I also tried to turn of the shaders with setUseShader(false) and then it works, so the problem seems to be in the shaders.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Selba Ward
« Reply #132 on: February 16, 2021, 07:14:23 pm »
My guess is that this is, as binary1248 put it, a "feature and not a bug".
See the explanation of RT with Shaders on this GitHub issue and the related forum post.

Not sure if Selba Ward could be adjusted to account for RT usage.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sidewinder

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Selba Ward
« Reply #133 on: February 16, 2021, 08:38:06 pm »
My guess is that this is, as binary1248 put it, a "feature and not a bug".
See the explanation of RT with Shaders on this GitHub issue and the related forum post.

Not sure if Selba Ward could be adjusted to account for RT usage.

Aha, makes sense. It's a bit much to try and reverse engineer the selba ward shaders right now, but now I at least know what I need to do if I want to try this again.

Thanks!

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Selba Ward
« Reply #134 on: March 28, 2021, 07:29:33 pm »
Yes, I believe this is related to the post linked by eXpl0it3r.

Luckily, there seems to be a simple solution (hack?)! You can invert the texture rectangle in the Elastic Sprite for drawing to a render texture. This is a pretty simple, one-time change although if you need to draw to a render texture and the main window (or even a render texture on a render texture!), you may need to keep switching the texture rectangle.

To flip the texture:
if you use the entire texture - and the texture is set to repeat - you can just negate the height.
if you use a section of a texture, you can add the current height to "top" and then negate the height.

I guess this isn't a big deal-breaker for using Elastic Sprite (or anything with shaders on a render texture) but I suppose it shouldn't be too difficult to add a "flip switch" either ;D


p.s. No problem for the necro. This thread is allowed to be necroed :P (otherwise there might be multiple threads relating to the same subject)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*