# How to do fade in and out

Hello, I need some learning advice, aka, teaching… how can make an element to fade in and/or out? Thank you so much!

1 Like

Add a tag in the transparency option of an element you want to fade in/out.

in what conditions you want that element to fade in/out?.

Which kind of tag? I’m wanting to make stars that glows “random”, I also need the “random” part but I can force that with a star pattern…

http://docs.facer.io/kitchen-sink
This shows how to fade in, fade out, or alternate fading in and out.
For info on interpAccel which is used in the first link: http://docs.facer.io/expressions
Sine (sin()) behavior is something you can find online since it is basic trigonometry, or if you can tell us the exact rates you want the fade in/out to do then we can help you figure it out.
Also in that second link are functions which you can use to generate random numbers.

What exactly are you trying to do with the stars? Make them “twinkle” by constantly fading in and out?

Here’s some code I made which will do that by choosing a random rate of fade and then randomly varing the start position for each object you put it in (put this in the Transparency box):

` (sin(#DWE#*wakeRand(3,10)-wakeRand(0, (wakeRand(3,10)*(pi*2))))*50+50)`

With this, every time the watchface is opened the object will choose a frequency (how fast the waves fluctuate) between 3 and 10, then randomly choose the wave’s starting transparency (by shifting it over a random amount between 0 and the beginning of the next cycle). Then it will multiply the wave’s amplitude by 50 and shift it 50 up so that it fluctuates between 0 and 100.

There’s one problem with this however, which is that if you copied this to every star then they would all end up doing the same thing at the same rate. This is because wakeRand() will output the same result if you use the same numbers in it, even if each usage is in a different object. The simplest workaround I can think of to this is to just slightly change the numbers within wakeRand(a, b) for each object you paste it to (although it could still potentially end up with multiple getting the same start transparency, but that shouldn’t matter much).
Here’s examples of some you would only want to paste to one object’s Transparency slot each:
` (sin(#DWE#*wakeRand(3,7)-wakeRand(0, (wakeRand(3,7)*(pi*2))))*50+50)`
` (sin(#DWE#*wakeRand(3,8)-wakeRand(0, (wakeRand(3,8)*(pi*2))))*50+50)`
` (sin(#DWE#*wakeRand(3,9)-wakeRand(0, (wakeRand(3,9)*(pi*2))))*50+50)`
` (sin(#DWE#*wakeRand(4,7)-wakeRand(0, (wakeRand(4,7)*(pi*2))))*50+50)`
` (sin(#DWE#*wakeRand(4,8)-wakeRand(0, (wakeRand(4,8)*(pi*2))))*50+50)`
and so on…

P.S. sorry for long post, i am trying to get better at making them more concise : (

4 Likes

This is perfect, and is not lengthy, is instructive, and is what I was looking for, will share later the results thank you

What would I do to make something with a transparency between 0 and 50?
(sin(#DWE#wakeRand(3,10)-wakeRand(0, (wakeRand(3,10)(pi2))))0+50)

It seems anytime i use any of this code it doesnt let me synch to my watch
Is there any other combination for fading in and out?

Hi do you know where the documentation links have been moved to? eg kitchen sink