p5.js中的textureMode()函數用於設置紋理映射的坐標空間。此函數在WEBGL模式下有效。圖像模式是指映射圖像的實際坐標。 NORMAL模式是指範圍為0到1的值的標準化空間的映射。
用法:
textureMode(mode)
參數:該函數接受如上所述和以下描述的單個參數:
- mode:這是設置紋理映射模式的常量。它可以有兩個值,IMAGE或NORMAL。默認為圖像模式。
以下示例說明了p5.js中的textureMode()函數:
例:
Javascript
// Creating a global image variable
let img;
// Load the image in the
// preload function
function preload() {
img =
loadImage('images/gfg_logo.jpg');
}
// Create the canvas
function setup() {
createCanvas(500, 300, WEBGL);
}
function draw() {
// Draw the texture
texture(img);
// Set the mode to NORMAL
// for the texture
textureMode(NORMAL);
beginShape();
// Adding the coordinates in NORMAL form
vertex(-100, -100, 0, 0);
vertex(100, -100, 1, 0);
vertex(100, 100, 1, 1);
vertex(-100, 100, 0, 1);
endShape();
}
輸出:
相關用法
- Lodash _.method()用法及代碼示例
- Node.js Http2ServerRequest.method用法及代碼示例
- Node.js http.IncomingMessage.method用法及代碼示例
- Javascript dataView.getInt16()用法及代碼示例
- Javascript RegExp toString()用法及代碼示例
- Node.js URLSearchParams.has()用法及代碼示例
- JavaScript Math cosh()用法及代碼示例
- HTML DOM isEqualNode()用法及代碼示例
- JavaScript Date toLocaleTimeString()用法及代碼示例
- Node.js crypto.createHash()用法及代碼示例
- Node.js writeStream.clearLine()用法及代碼示例
- Node.js fs.link()用法及代碼示例
- Java ArrayList toArray()用法及代碼示例
- JavaScript Math random()用法及代碼示例
- JavaScript Math round()用法及代碼示例
- Javascript toString()用法及代碼示例
- Javascript Number.isInteger( )用法及代碼示例
- Javascript Number.isFinite()用法及代碼示例
- Javascript toFixed()用法及代碼示例
- Javascript toPrecision()用法及代碼示例
- JavaScript Math abs()用法及代碼示例
- JavaScript Math sqrt()用法及代碼示例
注:本文由純淨天空篩選整理自_sh_pallavi大神的英文原創作品 p5.js textureMode() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。