關於css3中矩陣的使用方法

來源:互聯網
上載者:User
這篇文章主要介紹了css3 矩陣的使用詳解的相關資料,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

css3 矩陣變化. 應用格式為:

transform: matrix(a,b,c,d,e,f);

對應於就是:

實際應用中的轉換就是:

其中:

ax+cy+e = 橫座標

bx+dy+f = 縱座標

為什麼會多出 0 0 1呢? 因為, 為了湊參數.

translate 矩陣

基本格式為:

transform: matrix(1, 0, 0, 1, X, Y); // X 橫向平移, Y 縱向平移

scale 矩陣

scale(縮放) 的矩陣也挺簡單.

// 將 X 軸縮放 A 倍// 將 Y 軸縮放 B 倍matrix(A, 0, 0, B, 0,0);

當然, 如果你在最後兩位寫上數字, 代表著, 先縮放再平移.

// 得到: X 軸 = 0.3*x + 100// 得到: Y 軸 = 0.2*x + 200matrix(0.3,0,0,0.2,100,200);

rotate 矩陣

rotate 實際上和三角函數有很大的關係. 首先,確定你的旋轉角(順時針旋轉). 然後, 計算 sinθ 和 cosθ. 最後的矩陣公式為:

matrix(cosθ,sinθ,-sinθ,cosθ,0,0) // 就是 cs-sc

skew 矩陣

skew(展開) 矩陣也是三角函數, 不過, 用到的是tanθ. 格式為:

// 將 Y 軸向 X 軸傾斜 A°// 將 X 軸向 Y 軸傾斜 B°matrix(1,tan(A),tan(B),1,0,0)

3D變換矩陣

3D 變換是 4*4 的矩陣. 他和 2D 類似,只是, 多出一個Z。 // 這是縮放的3D矩陣

對應的 css 寫法為:

transform: matrix3d(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1)

以上就是本文的全部內容,希望對大家的學習有所協助,更多相關內容請關注topic.alibabacloud.com!

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.