issue152:inkscape
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
issue152:inkscape [2020/01/08 15:14] – andre_domenech | issue152:inkscape [2020/01/08 15:36] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 101: | Ligne 101: | ||
Pour notre animation, cependant, nous voulons une valeur qui varie linéairement vers le haut et vers le bas, sans saut brusque entre les itérations. Nous voulons un tracé triangulaire : | Pour notre animation, cependant, nous voulons une valeur qui varie linéairement vers le haut et vers le bas, sans saut brusque entre les itérations. Nous voulons un tracé triangulaire : | ||
- | Comme vous le voyez, pour un nombre impair d' | + | Comme vous le voyez, pour un nombre impair d' |
**The “if” statement that follows checks to see if this direction value is greater than the duration: if it is then we must be on an even cycle. In that case the “skewXPosition” variable (which, if you recall, ranges from 0 to 1) is subtracted from 1, so as the animation progresses the final position value first steps upwards, then steps downwards, before the cycle repeats in a triangle wave pattern. | **The “if” statement that follows checks to see if this direction value is greater than the duration: if it is then we must be on an even cycle. In that case the “skewXPosition” variable (which, if you recall, ranges from 0 to 1) is subtracted from 1, so as the animation progresses the final position value first steps upwards, then steps downwards, before the cycle repeats in a triangle wave pattern. | ||
Ligne 109: | Ligne 109: | ||
Phew! That was a lot to take in for a few lines of code. If you find it easier to follow, try adding some console.log() lines amongst the code so you can see how the values change in the developer tools.** | Phew! That was a lot to take in for a few lines of code. If you find it easier to follow, try adding some console.log() lines amongst the code so you can see how the values change in the developer tools.** | ||
- | La déclaration « if » qui suit vérifie si cette valeur de direction est plus grande que la durée : si oui, alors nous sommes dans un cycle impair. Dans ce cas, la variable « skewXPosition » (qui, pour mémoire, varie de 0 à 1) est soustraite de 1, de sorte que l' | + | La déclaration « if » qui suit vérifie si cette valeur de direction est plus grande que la durée : si oui, alors nous sommes dans un cycle pair. Dans ce cas, la variable « skewXPosition » (qui, pour mémoire, varie de 0 à 1) est soustraite de 1, de sorte que l' |
La dernière étape du calcul de la valeur réelle est pour multiplier la position actuelle dans le cycle par l' | La dernière étape du calcul de la valeur réelle est pour multiplier la position actuelle dans le cycle par l' | ||
- | Ouf ! Ça fait beaucoup à prendre en compte en si peu de lignes de code. Si ça vous permet | + | Ouf ! Ça fait beaucoup à prendre en compte en si peu de lignes de code. Pour vous permettre |
**With our final value calculated, the last step is to update the transform attribute to hold both the rotate() and the skewX() functions. Extend the previous template string to this: | **With our final value calculated, the last step is to update the transform attribute to hold both the rotate() and the skewX() functions. Extend the previous template string to this: | ||
Ligne 119: | Ligne 119: | ||
Loading the file into the browser, you should see the square being skewed as it rotates. But you’ll also notice that our simple, constrained rotation in the middle of the screen has turned into a whirling dervish that swoops out of the bounds of our image before flying back in and then setting off into the distance once more. Next time we’ll discuss why this is happening, and finish this little animation by adding scaling and translation. In the meantime why not test your own understanding of this code by adding the necessary lines to make the shape also skew in the Y direction, at a different frequency to the skewX() effect.** | Loading the file into the browser, you should see the square being skewed as it rotates. But you’ll also notice that our simple, constrained rotation in the middle of the screen has turned into a whirling dervish that swoops out of the bounds of our image before flying back in and then setting off into the distance once more. Next time we’ll discuss why this is happening, and finish this little animation by adding scaling and translation. In the meantime why not test your own understanding of this code by adding the necessary lines to make the shape also skew in the Y direction, at a different frequency to the skewX() effect.** | ||
- | Avec le calcul de notre valeur finale, la dernière étape est de mettre à jour l' | + | Avec le calcul de notre valeur finale, la dernière étape est de mettre à jour l' |
- | En chargeant le fichier dans le navigateur, vous devriez voir le carré qui se déforme tout en tournant. Mais vous devriez noter aussi que notre simple rotation contrainte au milieu | + | En chargeant le fichier dans le navigateur, vous devriez voir le carré qui se déforme tout en tournant. Mais vous devriez noter aussi que notre simple rotation contrainte au milieu de l' |
issue152/inkscape.1578492886.txt.gz · Dernière modification : 2020/01/08 15:14 de andre_domenech