Help us understand the problem. What is going on with this article?

三角関数を使ってクリスマスツリー風のエフェクトをつくる

More than 1 year has passed since last update.

 
三角関数を習ったとき、こんなの人生のどこで使うんだよ!!!って思った方多いと思います。
なので今日は三角関数を使ってクリスマスツリー風のエフェクトを作ってみましょう。

まずはこんな感じの円運動を作ります

01.gif

Y軸は半径を半分にすれば楕円になります。

// 毎フレーム行われる処理
this.x = Math.cos(_angle) * _radius;
this.y = Math.sin(_angle) * (_radius / 2);
_angle += _speed;

半径を段々小さくしながら、Y座標は段々上に行くようにする

02.gif

開始の角度をずらして4つ用意する

03.gif

これをパーティクルのemitter(発生装置)として使うとXmasツリーみたいなエフェクトが作れます!

完成例

04_1.gif

さらに色をXmasカラーにする

05_1.gif

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした