निर्देशांक प्रणाली में एक परिवर्तन मैट्रिक्स लागू करता है।
रूपांतरण जैसे translate(), rotate(), और scale() पर्दे के पीछे मैट्रिक्स-वेक्टर गुणन का उपयोग करें। संख्याओं की एक तालिका, जिसे मैट्रिक्स कहा जाता है, प्रत्येक परिवर्तन को एन्कोड करती है। फिर मैट्रिक्स में मान कैनवास पर प्रत्येक बिंदु को गुणा करते हैं, जिसे एक वेक्टर द्वारा दर्शाया जाता है।
applyMatrix() एक साथ कई परिवर्तनों को लागू करने की अनुमति देता है। देखें विकिपीडिया और MDN परिवर्तनों के बारे में अधिक जानकारी के लिए।
दो और तीन आयामों में applyMatrix() को कॉल करने के दो तरीके हैं।
2डी मोड में, पैरामीटर ए, बी, सी, डी, ई< /code>, और एफ, निम्नलिखित परिवर्तन मैट्रिक्स में तत्वों के अनुरूप हैं:
संख्याओं को अलग-अलग पारित किया जा सकता है, जैसे कि मैट्रिक्स लागू करें(2, 0, 0, 0, 2, 0)। उन्हें एक सरणी में भी पारित किया जा सकता है, जैसे applyMatrix([2, 0, 0, 0, 2, 0])
3डी मोड में, पैरामीटर ए, बी, सी, डी, ई< /code>, एफ, जी, एच, आई,
जे, के, एल, एम, n, o, और p निम्नलिखित परिवर्तन मैट्रिक्स में तत्वों के अनुरूप हैं:

संख्याओं को अलग-अलग पास किया जा सकता है, जैसे applyMatrix(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)< /code>. वे किसी ऐरे में भी पारित किया जा सकता है, जैसे कि applyMatrix([2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1])< /code>.
डिफ़ॉल्ट रूप से, परिवर्तन एकत्रित होते हैं। push() और pop() फ़ंक्शंस का उपयोग भीतर परिवर्तनों को अलग करने के लिए किया जा सकता है विशिष्ट ड्राइंग समूह।
ध्यान दें: ट्रांसफ़ॉर्मेशन ड्रॉ लूप की शुरुआत में रीसेट किए जाते हैं। draw() फ़ंक्शन के अंदर applyMatrix() को कॉल करने से आकृतियों में लगातार परिवर्तन नहीं होगा।
उदाहरण
सिंटैक्स
applyMatrix(arr)
applyMatrix(a, b, c, d, e, f)
applyMatrix(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
पैरामीटर्स
an array containing the elements of the transformation matrix. Its length should be either 6 (2D) or 16 (3D).
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
an element of the transformation matrix.
