[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Tue Apr 22, 2014 11:01 pm

R0J0hound wrote:I goes completely transparent for me on my computer. I don't know why it wouldn't... Does it fade at all?


Yes, it does fade but not completely, a small trace is left behind. See the photos below.

This is a screen capture from your example:

Image

On my monitor the trace is faint but clearly visible.

Here I manipulated the brightness and contrast in Photoshop to enhance it. If the trail was 0% opaque in the first place, it shouldn't be visible at all, even with the brightness and contrast added, right?

Image
composer - multimedia artist
www.eli0s.com/en/
B
53
S
21
G
3
Posts: 1,127
Reputation: 8,095

Post » Wed Apr 23, 2014 2:10 am

Hmm... It's still completely invisible for me in the first pic. Either way there isn't anything I can do about it in the plugin. One idea you could try is to start with the canvas completely white, aka not transparent at all...

Just tested that and it doesn't work. If finally was able to see it by tilting my screen. I think it's caused by number rounding when the colors blend. A solution that works is to use an additive blend instead.

https://dl.dropboxusercontent.com/u/542 ... itive.capx
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Wed Apr 23, 2014 1:01 pm

@R0J0hound

Thank you very much, that did the trick, now the trail fades completely, even if the "eraser" sprite has a very low opacity value, thus producing long, beautiful trails :)

I took the liberty and arranged your example in a way that displays side to side comparison of both methods and I have to say that the results are very ...transparent ;)

http://www.eli0s.com/Tests/CanvasTests/CanvasAdditiveBlend.capx

Thank you again :D

Elias
composer - multimedia artist
www.eli0s.com/en/
B
53
S
21
G
3
Posts: 1,127
Reputation: 8,095

Post » Wed Apr 23, 2014 10:23 pm

@R0j0hound @eli0s

Hey! I've been trying out the trail effect as well, noticed two issues with using additive blend:
1. It doesn't display any background or layers underneath, just covers it with a white canvas.
2. It doesn't work well with the eraser set to a colour that isn't white.
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Wed Apr 23, 2014 11:58 pm

Unfortunately I can confirm that... @R0J0hound is there a way around the "number rounding when the colors blend" (what ever this thing is :? ) ? I find it strange that no one has mentioned this before..!

-EDIT-

I thing the problem is that the "eraser" object (or the fill canvas with color) never actually adds up to be fully opaque, in other words it never reach 100% of its color value.

See the following example:

http://www.eli0s.com/Tests/CanvasTests/CanvasNotReachingBlack.capx

I use two canvas objects, on the left one, every tick I fill the canvas with black at 0.01 alpha and on the right I paste a black sprite object with 1% opacity. In theory, in both cases after 100 clicks (~1.4 seconds) the canvas objects should be completely covered with black. But the results are different. They are not the same, the paste sprite method renders darker results than the fill canvas, but never the less it's far from being fully opaque.
composer - multimedia artist
www.eli0s.com/en/
B
53
S
21
G
3
Posts: 1,127
Reputation: 8,095

Post » Thu Apr 24, 2014 3:20 am

I've wrangled with this problem in the past as well. I find it's especially noticeable with a black background and trying to make trails that fade to transparent.

If it's a rounding problem, could a float with higher precision be used behind the scenes to represent the color instead, and it would only round the value when determining what color to set the pixel to, but still leave the precise float behind for any later calculations?
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Thu Apr 24, 2014 6:28 am

I behavior is in the web browser's canvas, so I can't do anything about the issue as it is. The only idea that would work is looping over all the pixels in javascript to have more control, but it will be very slow since it would be done on the cpu instead of the gpu.

So unless another creative solution is found the fastest way will probably be to use fading sprites.
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Thu Apr 24, 2014 12:56 pm

R0J0hound wrote:So unless another creative solution is found the fastest way will probably be to use fading sprites.


@R0J0hound can you please show as a practical example with fading sprites..? I tried to use the fade behavior or setting the sprite into an empty frame after a few seconds, but the result is that the main sprite (the one that should leave the trail) just disappears.
composer - multimedia artist
www.eli0s.com/en/
B
53
S
21
G
3
Posts: 1,127
Reputation: 8,095

Post » Thu Apr 24, 2014 1:12 pm

There is a link in the How Do I section to a trail effect. Here's a very simple example:

https://www.scirra.com/forum/is-there-a-way-to-give-a-sprite-a-trail_p557543?#p557543

Also, just found this more useful example. Not sure of original author, but thanks to them anyway.
You do not have the required permissions to view the files attached to this post.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,850
Reputation: 48,301

Post » Thu Apr 24, 2014 2:49 pm

@zenox98

All of those examples basically can be summed in to two categories. The first uses a sprite as a trail and this sprite is being spawned every tick or x seconds. The second uses the canvas plugin in some way, just as in the R0J0hound's example found in page 5 in this topic.

The first method, although very flexible, has a major disadvantage, if you have many objects that leave trails (and further more the trails are long), you have to spawn many-many sprites, so there ought to be a performance issues somewhere.

The second method, on the other hand, does not require any number of sprites, but I renders a weird result, best viewed when the opacity values of the "fill canvas with color" action, or the object that has the destination out blend, are very low. The thing is that you'll need low opacity values if you want long trails.

I was hopping that in his last post, R0J0hound has something in mind that uses the canvas object and he was not referring the methods that are under the "spawn sprite trails" category...
Last edited by eli0s on Thu Apr 24, 2014 2:57 pm, edited 1 time in total.
composer - multimedia artist
www.eli0s.com/en/
B
53
S
21
G
3
Posts: 1,127
Reputation: 8,095

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: matriax, shinkan and 1 guest