Search completed in 1.44 seconds.
Matrix math for the web - Web APIs
types of matrices, but the ones we are interested in are the 3d transformation matrices. these matrices consist of a set of 16 values arranged in a 4x4 grid. in javascript, it is easy to represent a matrix as an array. let's begin by considering the identity matrix. this is a special transformation matrix which functions much like the number 1 does in scalar multiplication; just like n * 1 = n,
multiplying any matrix by the identity matrix gives a resulting matrix whose values match the original matrix. the identity matrix looks like this in javascript: let identitymatrix = [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]; what does
multiplying by the identity matrix look like? the easiest example is to
multiply a single point by the identity matrix. since a 3d point only needs thr...
...g w to 1 will make the math work out. after adding the w component to the point, notice how neatly the matrix and the point line up: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] [4, 3, 2, 1] // point at [x, y, z, w] the w component has some additional uses that are out of scope for this article. check out the webgl model view projection article for a look into how it comes in handy. ...
...tice how neatly the matrix and the point line up: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] [4, 3, 2, 1] // point at [x, y, z, w] the w component has some additional uses that are out of scope for this article. check out the webgl model view projection article for a look into how it comes in handy. ...
...And 14 more matches
Advanced styling effects - Learn web development
new, and slightly less well supported than filters. there is no support as yet in edge, and safari only supports some of the blend mode options. background-blend-mode again, let's look at some examples so we can understand this better. ...
...al with the blended version: <div> </div> <div class="
multiply"> </div> now some css — we are adding to the <div> one background image and a green background color: div { width: 250px; height: 130px; padding: 10px; margin: 10px; display: inline-block; background: url(https://mdn.mozillademos.org/files/13090/colorful-heart.png) no-repeat center 20px; background-color: green; } .
multiply { background-blend-mode:
multiply; } the result we get is this — you can see the original on the left, and the
multiply blend mode on the right: mix-blend-mode now let's look at mix-blend-mode. here we'll present the same two <div>s, but each one is now sat on top of a simple <div> with a purple background, to show how the elements will blend together: <article> no mix blend mode <d...
...get is this — you can see the original on the left, and the
multiply blend mode on the right: mix-blend-mode now let's look at mix-blend-mode. ...
...And 4 more matches
WebGL model view projection - Web APIs
so many ones and zeros that are used to represent them. the more operations that are done on larger numbers, the more and more errors accumulate into the result. when dividing by w, this can effectively increase the precision of very large numbers by operating on two potentially smaller, less error-prone numbers. the final benefit of using homogeneous coordinates is that they fit very nicely for
multiplying against 4x4 matrices. a vertex must match at least one of the dimensions of a matrix in order to be multiplied against it. the 4x4 matrix can be used to encode a variety of useful transformations. in fact, the typical perspective projection matrix uses the division by the w component to achieve its transformation. the clipping of points and polygons from clip space actually happens after the ...
...sired spot in clip space. the cube is the size of clip space (-1,-1,-1) to (1,1,1) so it will need to be shrunk down in order to not fill the entirety of clip space. this matrix is sent directly to the shader, having been multiplied in javascript beforehand. the following code sample defines a method on the cubedemo object that will create the model matrix. it uses custom functions to create and
multiply matrices as defined in the mdn webgl shared code. the new function looks like this: cubedemo.prototype.computemodelmatrix = function(now) { //scale down by 50% var scale = mdn.scalematrix(0.5, 0.5, 0.5); // rotate a slight tilt var rotatex = mdn.rotatexmatrix(now * 0.0003); // rotate according to time var rotatey = mdn.rotateymatrix(now * 0.0005); // move slightly down var pos...
...de. the new function looks like this: cubedemo.prototype.computemodelmatrix = function(now) { //scale down by 50% var scale = mdn.scalematrix(0.5, 0.5, 0.5); // rotate a slight tilt var rotatex = mdn.rotatexmatrix(now * 0.0003); // rotate according to time var rotatey = mdn.rotateymatrix(now * 0.0005); // move slightly down var position = mdn.translatematrix(0, -0.1, 0); //
multiply together, make sure and read them in opposite order this.transforms.model = mdn.
multiplyarrayofmatrices([ position, // step 4 rotatey, // step 3 rotatex, // step 2 scale // step 1 ]); }; in order to use this in the shader it must be set to a uniform location. the locations for the uniforms are saved in the locations object shown below: this.locations.model = gl.getuni...
...And 4 more matches
Viewpoints and viewers: Simulating cameras in WebXR - Web APIs
is: let viewmatrix = view.transform.inverse.matrix; if the library you're using accepts an xrrigidtransform object directly, you can instead get view.transform.inverse, rather than pulling out just the array representing the view matrix. composing multiple transforms if your camera needs to be performing multiple transforms simultaneously, such as zooming and panning at the same time, you can
multiply the transform matrices together to compose them into a single matrix that applies both changes at once. see
multiplying two matrices in the article matrix math for the web for a clear but readable function that does this or use your preferred matrix math library such as glmatrix to do the work. it's crucial to remember that unlike typical arithmetic, where multiplication is commutative (that is,...
...ompose them into a single matrix that applies both changes at once. see
multiplying two matrices in the article matrix math for the web for a clear but readable function that does this or use your preferred matrix math library such as glmatrix to do the work. it's crucial to remember that unlike typical arithmetic, where multiplication is commutative (that is, you get the same answer whether you
multiply left to right or right to left), matrix multiplication is not commutative! this is because each transform affects the position of the object and possibly the very coordinate system itself, which can dramatically change the results of the next operation performed. so you need to be careful about the order in which you apply your transforms when building your composite transform (or directly applyi...
...is because each transform affects the position of the object and possibly the very coordinate system itself, which can dramatically change the results of the next operation performed. so you need to be careful about the order in which you apply your transforms when building your composite transform (or directly applying transforms in sequence). applying the transform to apply the transform, you
multiply the point or vector by the transform or composition of transforms. this has been a very quick overview of the concepts of position in terms of physical location, orientation or facing direction, and perspective. for more detail on the subject, see the articles geometry and reference spaces, webgl model view projection, and matrix math for the web. simulating classic cinematography cinematograp...
...And 4 more matches
<blend-mode> - CSS: Cascading Style Sheets
normal the final color is the top color, regardless of what the bottom color is. the effect is like two opaque pieces of paper overlapping. <div id="div"></div> #div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode: normal; }
multiply the final color is the result of
multiplying the top and bottom colors. a black layer leads to a black final layer, and a white layer leads to no change. the effect is like two images printed on transparent film overlapping. <div id="div"></div> #div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://md...
...om colors. a black layer leads to a black final layer, and a white layer leads to no change. the effect is like two images printed on transparent film overlapping. <div id="div"></div> #div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode:
multiply; } screen the final color is the result of inverting the colors,
multiplying them, and inverting that value. a black layer leads to no change, and a white layer leads to a white final layer. the effect is like two images shone onto a projection screen. <div id="div"></div> #div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/b...
...white layer leads to a white final layer. the effect is like two images shone onto a projection screen. <div id="div"></div> #div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode: screen; } overlay the final color is the result of
multiply if the bottom color is darker, or screen if the bottom color is lighter. this blend mode is equivalent to hard-light but with the layers swapped. <div id="div"></div> #div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode: overlay; } ...
...And 3 more matches
mix-blend-mode - CSS: Cascading Style Sheets
element's content should blend with the content of the element's parent and the element's background. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
...r; mix-blend-mode: luminosity; /* global values */ mix-blend-mode: initial; mix-blend-mode: inherit; mix-blend-mode: unset; values <blend-mode> the blending mode that should be applied. ...
...%,100%)" /> </lineargradient> </defs> <ellipse class="item r" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item g" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item b" cx="75" cy="75" rx="25" ry="70"></ellipse> </svg> </div> </div> </div> <div class="cell">
multiply <div class="container
multiply"> <div class="group"> <div class="item firefox"></div> <svg viewbox="0 0 150 150"> <ellipse class="item r" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item g" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item b" cx="75" cy="75" rx="25" ry="70"></ellipse> ...
...And 2 more matches
Functions - JavaScript
scope can access all variables defined in the global scope. a function defined inside another function can also access all variables defined in its parent function, and any other variables to which the parent function has access. // the following variables are defined in the global scope var num1 = 20, num2 = 3, name = 'chamahk'; // this function is defined in the global scope function
multiply() { return num1 * num2; }
multiply(); // returns 60 // a nested function example function getscore() { var num1 = 2, num2 = 3; function add() { return name + ' scored ' + (num1 + num2); } return add(); } getscore(); // returns "chamahk scored 5" scope and the function stack recursion a function can refer to and call itself. there are three ways for a function to refer...
...ts and variables in all scopes it references. since each call provides potentially different arguments, a new closure is created for each call to outside. the memory can be freed only when the returned inside is no longer accessible. this is not different from storing references in other objects, but is often less obvious because one does not set the references directly and cannot inspect them.
multiply-nested functions functions can be
multiply-nested. for example: a function (a) contains a function (b), which itself contains a function (c). both functions b and c form closures here. so, b can access a, and c can access b. in addition, since c can access b which can access a, c can also access a. thus, the closures can contain multiple scopes; they recursively contain the scope of the ...
...t a different default value. this is exactly what default parameters do. without default parameters (pre-ecmascript 2015) in the past, the general strategy for setting defaults was to test parameter values in the body of the function and assign a value if they are undefined. in the following example, if no value is provided for b, its value would be undefined when evaluating a*b, and a call to
multiply would normally have returned nan. however, this is prevented by the second line in this example: function
multiply(a, b) { b = typeof b !== 'undefined' ? b : 1; return a * b; }
multiply(5); // 5 with default parameters (post-ecmascript 2015) with default parameters, a manual check in the function body is no longer necessary. you can simply put 1 as the default value for b in the functi...
...And 2 more matches
Default parameters - JavaScript
statements } description in javascript, function parameters default to undefined. however, it's often useful to set a different default value. this is where default parameters can help. in the past, the general strategy for setting defaults was to test parameter values in the function body and assign a value if they are undefined. ...
...undefined. however, it's often useful to set a different default value. this is where default parameters can help. in the past, the general strategy for setting defaults was to test parameter values in the function body and assign a value if they are undefined. in the following example, if no value is provided for b when
multiply is called, b's value would be undefined when evaluating a * b and
multiply would return nan. ...
... to set a different default value. this is where default parameters can help. in the past, the general strategy for setting defaults was to test parameter values in the function body and assign a value if they are undefined. in the following example, if no value is provided for b when
multiply is called, b's value would be undefined when evaluating a * b and
multiply would return nan. ...
...And 2 more matches
Functions - JavaScript
to set that property. method definition syntax starting with ecmascript 2015, you are able to define own methods in a shorter syntax, similar to the getters and setters. see method definitions for more information. var obj = { foo() {}, bar() {} }; constructor vs. declaration vs. ...
...perty. method definition syntax starting with ecmascript 2015, you are able to define own methods in a shorter syntax, similar to the getters and setters. see method definitions for more information. var obj = { foo() {}, bar() {} }; constructor vs. declaration vs. ...
...thods in a shorter syntax, similar to the getters and setters. see method definitions for more information. var obj = { foo() {}, bar() {} }; constructor vs. declaration vs. ...
...And 2 more matches
Compositing example - Web APIs
ut looks like this: compositing example this code sets up the global values used by the rest of the program. ...
...he color is determined by adding color values.', 'only the new shape is shown.', 'shapes are made transparent where both overlap and drawn normal everywhere else.', 'the pixels are of the top layer are multiplied with the corresponding pixel of the bottom layer. a darker picture is the result.', 'the pixels are inverted, multiplied, and inverted again. ...
...ng color values.', 'only the new shape is shown.', 'shapes are made transparent where both overlap and drawn normal everywhere else.', 'the pixels are of the top layer are multiplied with the corresponding pixel of the bottom layer. a darker picture is the result.', 'the pixels are inverted, multiplied, and inverted again. a lighter picture is the result (opposite of
multiply)', 'a combination of
multiply and screen. ...
... result (opposite of
multiply)', 'a combination of
multiply and screen. dark parts on the base layer become darker, and light parts become lighter.', 'retains the darkest pixels of both layers.', 'retains the lightest pixels of both layers.', 'divides the bottom layer by the inverted top layer.', 'divides the inverted bottom layer by the top layer, and then inverts the result.', 'a combination of
multiply and screen like overlay, but with top and bottom layer swapped.', 'a softer version of hard-light. pure black or white does not result in pure black or white.', 'subtracts the bottom layer from the top layer or the other way round to always get a positive value.', 'like difference, but with lower contrast.', 'preserves the luma and chroma of the bottom layer, while adopting the hue of the top lay...
KeyboardEvent: code values - Web APIs
0x002d "keyx" "keyx" 0x002e "keyc" "keyc" 0x002f "keyv" "keyv" 0x0030 "keyb" "keyb" 0x0031 "keyn" "keyn" 0x0032 "keym" "keym" 0x0033 "comma" "comma" 0x0034 "period" "period" 0x0035 "slash" "slash" 0x0036 "shiftright" "shiftright" 0x0037 "numpad
multiply" "numpad
multiply" 0x0038 "altleft" "altleft" 0x0039 "space" "space" 0x003a "capslock" "capslock" 0x003b "f1" "f1" 0x003c "f2" "f2" 0x003d "f3" "f3" 0x003e "f4" "f4" 0x003f "f5" "f5" 0x0040 "f6" "f6" 0x0041 "f7" "f7" 0x0042 "f8" "f8...
... "shiftright" "shiftright" kvk_rightoption (0x3d) "altright" "altright" kvk_rightcontrol (0x3e) "controlright" "controlright" kvk_function (0x3f) "fn" (no events fired actually) "" (no events fired actually) kvk_f17 (0x40) "f17" "f17" kvk_ansi_keypaddecimal (0x41) "numpaddecimal" "numpaddecimal" kvk_ansi_keypad
multiply (0x43) "numpad
multiply" "numpad
multiply" kvk_ansi_keypadplus (0x45) "numpadadd" "numpadadd" kvk_ansi_keypadclear (0x47) "numlock" "numlock" kvk_volumeup (0x48) "audiovolumeup" (was "volumeup" until firefox 48) "audiovolumeup" (was "volumeup" until chrome 50) kvk_volumedown (0x49) "audiovolumedown" (was "volumedown" until firefox 49) ...
... 0x0035 "keyx" "keyx" 0x0036 "keyc" "keyc" 0x0037 "keyv" "keyv" 0x0038 "keyb" "keyb" 0x0039 "keyn" "keyn" 0x003a "keym" "keym" 0x003b "comma" "comma" 0x003c "period" "period" 0x003d "slash" "slash" 0x003e "shiftright" "shiftright" 0x003f "numpad
multiply" "numpad
multiply" 0x0040 "altleft" "altleft" 0x0041 "space" "space" 0x0042 "capslock" "capslock" 0x0043 "f1" "f1" 0x0044 "f2" "f2" 0x0045 "f3" "f3" 0x0046 "f4" "f4" 0x0047 "f5" "f5" 0x0048 "f6" "f6" 0x0049 "f7" "f7" 0x004a "f8" "f8...
... "backquote" 0x002a "shiftleft" 0x002b "backslash" 0x002c "keyz" 0x002d "keyx" 0x002e "keyc" 0x002f "keyv" 0x0030 "keyb" 0x0031 "keyn" 0x0032 "keym" 0x0033 "comma" 0x0034 "period" 0x0035 "slash" 0x0036 "shiftright" 0x0037 "numpad
multiply" 0x0038 "altleft" 0x0039 "space" 0x003a "capslock" 0x003b "f1" 0x003c "f2" 0x003d "f3" 0x003e "f4" 0x003f "f5" 0x0040 "f6" 0x0041 "f7" 0x0042 "f8" 0x0043 "f9" 0x0044 "f10" 0x0045 "numlock" 0x0046 "scrolllock" 0...
WebGL constants - Web APIs
ontext.blendfuncseparate() to specify the blending mode (for both, rbg and alpha, or separately). constant name value description zero 0 passed to blendfunc or blendfuncseparate to turn off a component. one 1 passed to blendfunc or blendfuncseparate to turn on a component. src_color 0x0300 passed to blendfunc or blendfuncseparate to
multiply a component by the source elements color. one_minus_src_color 0x0301 passed to blendfunc or blendfuncseparate to
multiply a component by one minus the source elements color. src_alpha 0x0302 passed to blendfunc or blendfuncseparate to
multiply a component by the source's alpha. one_minus_src_alpha 0x0303 passed to blendfunc or blendfuncseparate to mult...
...to
multiply a component by one minus the source elements color. src_alpha 0x0302 passed to blendfunc or blendfuncseparate to
multiply a component by the source's alpha. one_minus_src_alpha 0x0303 passed to blendfunc or blendfuncseparate to
multiply a component by one minus the source's alpha. dst_alpha 0x0304 passed to blendfunc or blendfuncseparate to
multiply a component by the destination's alpha. one_minus_dst_alpha 0x0305 passed to blendfunc or blendfuncseparate to
multiply a component by one minus the destination's alpha. dst_color 0x0306 passed to blendfunc or blendfuncseparate to
multiply a component by the destination's color. one_minus_dst_color 0x0307 passed to blendfunc or blendfuncseparate to mul...
... constant_color 0x8001 passed to blendfunc or blendfuncseparate to specify a constant color blend function. ...
...x8cdd framebuffer_binding 0x8ca6 renderbuffer_binding 0x8ca7 max_renderbuffer_size 0x84e8 invalid_framebuffer_operation 0x0506 pixel storage modes constants passed to webglrenderingcontext.pixelstorei(). constant name value description unpack_flip_y_webgl 0x9240 unpack_pre
multiply_alpha_webgl 0x9241 unpack_colorspace_conversion_webgl 0x9243 additional constants defined webgl 2 these constants are defined on the webgl2renderingcontext interface. all webgl 1 constants are also available in a webgl 2 context. getting gl parameter information constants passed to webglrenderingcontext.getparameter() to specify what information to return. ...
Movement, orientation, and motion: A WebXR example - Web APIs
ction in which they'll initially be looking. cubeorientation will store the current orientation of the cube, while cubematrix and mousematrix are storage for matrices used during the rendering of the scene. inverseorientation is a quaternion which will be used to represent the rotation to apply to the reference space for the object in the frame being rendered. radians_per_degreee is the value to
multiply an angle in degrees by to convert the angle into radians. the last four variables declared are storage for references to the <div> elements into which we'll output the matrices when we want to show them to the user. logging errors a function called logglerror() is implemented to provide an easily customized way to output logging information for errors that occur while executing webgl functions...
...t rendering webgl draws into the layer and therefore the xr device's display). with webgl now configured to render to the xr device, we clear the frame to black and are ready to begin rendering. the time elapsed since the last frame was rendered (in seconds) is computed by subtracting the previous frame's timestamp, lastframetime, from the current time as specified by the time parameter and then
multiplying by 0.001 to convert milliseconds to seconds. the current time is then saved into lastframetime; the drawscene() function ends by iterating over every view found in the xrviewerpose, setting up the viewport for the view, and calling drawscene() to render the frame. by setting the viewport for each view, we handle the typical scenario in which the views for each eye are each rendered onto half ...
...ubematrix, // matrix to rotate yrotationfortime, // amount to rotate in radians [0, 1, 0]); // axis to rotate around (y) mat4.rotate(cubematrix, // destination matrix cubematrix, // matrix to rotate xrotationfortime, // amount to rotate in radians [1, 0, 0]); // axis to rotate around (x) } mat4.
multiply(modelviewmatrix, view.transform.inverse.matrix, cubematrix); mat4.invert(normalmatrix, modelviewmatrix); mat4.transpose(normalmatrix, normalmatrix); displaymatrix(view.projectionmatrix, 4, projectionmatrixout); displaymatrix(modelviewmatrix, 4, modelmatrixout); displaymatrix(view.transform.matrix, 4, cameramatrixout); displaymatrix(mousematrix, 4, mousematrixout); { const numc...
...otationfortime, yrotationfortime, and zrotationfortime. after enabling and configuring depth testing, we check the value of the enablerotation constant to see if rotation of the cube is enabled; if it is, we use glmatrix to rotate the cubematrix (representing the cube's current orientation relative to the world space) around the three axes. with the cube's global orientation established, we then
multiply that by the inverse of the view's transform matrix to get the final model view matrix—the matrix to apply to the object to both rotate it for its animation purposes, but to also move and reorient it to simulate the viewer's motion through the space. then the view's normal matrix is computed by taking the model view matrix, inverting it, and transposing it (swapping its columns and rows). the ...
Using Web Workers - Web APIs
onmessage = function(e) { console.log('message received from main script'); var workerresult = 'result: ' + (e.data[0] * e.data[1]); console.log('posting message back to main script'); postmessage(workerresult); } the onmessage handler allows us to run some code whenever a message is received, with the message itself being available in the message event's data attribute. here we simply
multiply together the two numbers then use postmessage() again, to post the result back to the main thread. back in the main thread, we use onmessage again, to respond to the message sent back from the worker: myworker.onmessage = function(e) { result.textcontent = e.data; console.log('message received from worker'); } here we grab the message event data and set it as the textcontent of the result ...
...ted. shared workers a shared worker is accessible by multiple scripts — even if they are being accessed by different windows, iframes or even workers. in this section we'll discuss the javascript found in our basic shared worker example (run shared worker): this is very similar to the basic dedicated worker example, except that it has two functions available handled by different script files:
multiplying two numbers, or squaring a number. both scripts use the same worker to do the actual calculation required. here we'll concentrate on the differences between dedicated and shared workers. note that in this example we have two html pages, each with javascript applied that uses the same single worker file. note: if sharedworker can be accessed from several browsing contexts, all those browsing...
...) method. note: when using the start() method to open the port connection, it needs to be called from both the parent thread and the worker thread if two-way communication is needed. sending messages to and from a shared worker now messages can be sent to the worker as before, but the postmessage() method has to be invoked through the port object (again, you'll see similar constructs in both
multiply.js and square.js): squarenumber.onchange = function() { myworker.port.postmessage([squarenumber.value,squarenumber.value]); console.log('message posted to worker'); } now, on to the worker. there is a bit more complexity here as well (worker.js): onconnect = function(e) { var port = e.ports[0]; port.onmessage = function(e) { var workerresult = 'result: ' + (e.data[0] * e.data[1]);...
...t, we add a message handler on the port to do the calculation and return the result to the main thread. setting up this message handler in the worker thread also implicitly opens the port connection back to the parent thread, so the call to port.start() is not actually needed, as noted above. finally, back in the main script, we deal with the message (again, you'll see similar constructs in both
multiply.js and square.js): myworker.port.onmessage = function(e) { result2.textcontent = e.data; console.log('message received from worker'); } when a message comes back through the port from the worker, we insert the calculation result inside the appropriate result paragraph. about thread safety the worker interface spawns real os-level threads, and mindful programmers may be concerned that conc...
in - SVG: Scalable Vector Graphics
ibute. workaround for backgroundimage instead of using in="backgroundimage", we need to import one of the images to blend inside the filter itself, using an <feimage> element. ...
... images to blend inside the filter itself, using an <feimage> element. html <div style="width: 420px; height: 220px;"> <svg style="width:200px; height:200px; display: inline;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <filter id="background
multiply"> <!-- this will not work. ...
.../1999/xlink"> <defs> <filter id="background
multiply"> <!-- this will not work. --> <feblend in="backgroundimage" in2="sourcegraphic" mode="
multiply"/> </filter> </defs> <image xlink:href="https://developer.mozilla.org/files/6457/mdn_logo_only_color.png" x="10%" y="10%" width="80%" height="80%"/> <circle cx="50%" cy="40%" r="40%" fill="#c00" style="filter:url(#background
multiply);" /> </svg> <svg style="width:200px; height:200px; display: inline;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <filter id="image
multiply"> <!-- this is a workaround. --> <feimage xlink:href="https://developer.mozilla.org/files/6457/mdn_logo_only_color.png" x="10%" y="10%" width="80%" height="80%"/> <feblend in2="sourcegraphic" ...
... </svg> <svg style="width:200px; height:200px; display: inline;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <filter id="image
multiply"> <!-- this is a workaround. --> <feimage xlink:href="https://developer.mozilla.org/files/6457/mdn_logo_only_color.png" x="10%" y="10%" width="80%" height="80%"/> <feblend in2="sourcegraphic" mode="
multiply"/> </filter> </defs> <circle cx="50%" cy="40%" r="40%" fill="#c00" style="filter:url(#image
multiply);"/> </svg> </div> result specifications specification status comment filter effects module level 1the definition of 'in' in that specification. working draft no change scalable vector graphics (svg) 1.1 (second edition)the definition of 'in' ...
LIR - Archive of obsolete content
it's only used on i386/x64. the operand is the result of a lir_divi because on i386/x64 div and mod results are computed by the same instruction. 84 noti integer bitwise-not int 85 andi integer bitwise-and int 86 ori integer bitwise-or int ...
...the back-ends cannot generate code for it.it's used in tracemonkey briefly but is always demoted to a lir_modl or converted to a function call before nanojit has to do anything serious with it. 105 cmovi integer conditional move int 106 cmo...
...i integer convert double to int (no exceptions raised) 114 dasq quad 64 bit interpret the bits of a double as a quad 115 qasd double 64 bit interpret the bits of a quad as a double overflow arithmetic 116 addxovi integer add int and exit on overflow 117 subxovi integer subtract int and exit on overflow 118 mulxovi integer
multiply int and exit on overflow 119 addjovi integer add int and branch on overflow 120 subjovi integer subtract int and branch on overflow 121 muljovi integer
multiply int and branch on overflow 122 addjovq quad 64 bit add quad and branch on overflow 123 subjovq quad 64 bit subtract quad and branch on overflow softfloat 124 dlo2i ...
Test your skills: Math - Learn web development
or in your code it will be outputted into the results panel on the page, to help you try to figure out the answer (or into the browser's javascript console, in the case of the downloadable version). math 1 let's start out by testing your knowledge of basic math operators. you will have to create four numeric values, then add the first two together, then subtract the fourth from the third, then
multiply the two secondary results together to get a result of 48. finally, we need to write a test that proves that this value is an even number. so, try updating the live code below to recreate the finished example, following these steps: create four variables that contain numbers. call the variables something sensible. add the first two variables together and store the result in another variable. ...
...est that proves that this value is an even number. so, try updating the live code below to recreate the finished example, following these steps: create four variables that contain numbers. call the variables something sensible. add the first two variables together and store the result in another variable. subtract the fourth variable from the third and store the result in another variable.
multiply the results from the last two steps together, storing the result in a variable called finalresult. the product should be 48. if it isn't, you'll have to adjust some of the initial input values. finally, write a calculation that checks whether finalresult is an even number. store the result in a variable called evenoddresult. download the starting point for this task to work in your own edit...
... called evenoddresult. download the starting point for this task to work in your own editor or in an online editor. math 2 in the second task you are already provided with two calculations, with the results stored in the variables result and result2. but these results aren't what we want; you'll need to take the calculations and change them to give us what we want. what do we want? after
multiplying the two results together and formatting the result to 2 decimal places, the final result should be 10.42. try updating the live code below to recreate the finished example, following these steps: write a calculation that multiplies result and result2 together and assigns the result back to result. this will require assignment shorthand. write a line of code that takes result and formats i...
JavaScript basics - Learn web development
ome of the simplest operators, along with some examples to try in the javascript console. operator explanation symbol(s) example addition add two numbers together or combine two strings. + 6 + 9; 'hello ' + 'world!'; subtraction, multiplication, division these do what you'd expect them to do in basic math. -, *, / 9 - 3; 8 * 2; //
multiply in js is an asterisk 9 / 3; assignment as you've seen already: this assigns a value to a variable. = let myvariable = 'bob'; equality this performs a test to see if two values are equal. it returns a true/false (boolean) result. === let myvariable = 3; myvariable === 4; not, does-not-equal this returns the logically opposite value of what it...
...ses, separated by commas if there is more than one argument. for example, the alert() function makes a pop-up box appear inside the browser window, but we need to give it a string as an argument to tell the function what message to display. you can also define your own functions. in the next example, we create a simple function which takes two numbers as arguments and multiplies them: function
multiply(num1,num2) { let result = num1 * num2; return result; } try running this in the console; then test with several arguments. for example:
multiply(4, 7);
multiply(20, 20);
multiply(0.5, 3); note: the return statement tells the browser to return the result variable out of the function so it is available to use. this is necessary because variables defined inside functions are only available i...
imgIContainer
type_vector 1 flag_none 0x0 flags for imgicontainer operations. meanings: flag_none: lack of flags. flag_sync_decode: forces synchronous/non-progressive decode of all available data before the call returns. it is an error to pass this flag from a call stack that originates in a decoder (that is, from a decoder observer event). flag_decode_no_pre
multiply_alpha: do not pre
multiply alpha if it is not already premultiplied in the image data. flag_decode_no_colorspace_conversion: do not do any colorspace conversion; ignore any embedded profiles, and do not convert to any particular destination space. flag_clamp: extend the image to the fill area by clamping image sample coordinates instead of by tiling. this only affects 'draw()'. f...
...premultiplied in the image data. flag_decode_no_colorspace_conversion: do not do any colorspace conversion; ignore any embedded profiles, and do not convert to any particular destination space. flag_clamp: extend the image to the fill area by clamping image sample coordinates instead of by tiling. this only affects 'draw()'. flag_sync_decode 0x1 flag_decode_no_pre
multiply_alpha 0x2 flag_decode_no_colorspace_conversion 0x4 flag_clamp 0x8 frame_first 0 constants for specifying various "special" frames. frame_first: the first frame frame_current: the current frame. frame_max_value should be set to the value of the maximum constant above, as it is used for ensuring that a valid value was passed in. ...
nsCOMPtr versus RefPtr
s, these concrete classes cannot be used with nscomptr. while is possible to use nscomptr<t> on concrete classes t that only singly inherit from nsisupports, it is best to avoid doing so. in the future, more base classes might be added to t that would then cause unrelated code to break, which would be very confusing. hence, the interface versus concrete class rule of thumb: interfaces will never
multiply inherit from nsisupports, so they can always use be used with nscomptr without fear of breaking in the future. concrete classes should only be used with refptr. nscomptr<t> also requires that you can queryinterface to type t. it does this so that it can assert that mrawptr is a canonical t pointer (i.e., that mrawptr->queryinterface(t_iid) == mrawptr). do_queryinterface versus do_queryobject t...
... powerful form of do_queryinterface. it differs from do_queryinterface as follows: do_queryobject inherits from nscomptr_helper, so it can be assigned into both nscomptr and refptr. the downside of this inheritance is that do_queryobject requires an extra virtual call to operator() in the helper method. do_queryobject is templated on the argument type, so it's possible to pass in objects that
multiply inherit from nsisupports. however, when the destination type is an xpcom interface, it's probably better to static_cast to a class that unambiguously inherits from nsisupports and use do_queryinterface in such cases. ...
AudioBufferSourceNode.AudioBufferSourceNode() - Web APIs
mple frames, comprising the loop, run from the values loopstart to loopend-(1/samplerate). it's sensible to set this to a value between 0 and the duration of the buffer. if loopend is less than 0, looping will end at 0. if loopend is greater than the duration of the buffer, looping will end at the end of the buffer. this attribute is converted to an exact sample frame offset within the buffer, by
multiplying by the buffer's sample rate and rounding to the nearest integer value. thus, its behavior is independent of the value of the playbackrate parameter. loopstart: an optional value in seconds, where looping should begin if the loop attribute is true. the default is 0. it's sensible to set this to a value between 0 and the duration of the buffer. if loopstart is less than 0, looping will be...
...conds, where looping should begin if the loop attribute is true. the default is 0. it's sensible to set this to a value between 0 and the duration of the buffer. if loopstart is less than 0, looping will begin at 0. if loopstart is greater than the duration of the buffer, looping will begin at the end of the buffer. this attribute is converted to an exact sample frame offset within the buffer, by
multiplying by the buffer's sample rate and rounding to the nearest integer value. thus, its behavior is independent of the value of the playbackrate parameter. playbackrate: the speed at which to render the audio stream. its default value is 1. this parameter is k-rate. this is a compound parameter with detune. its nominal range is (-∞ to +∞). return value a new audiobuffersourcenode object ...
DOMMatrixReadOnly - Web APIs
alent a m11 b m12 c m21 d m22 e m41 f m42 methods this interface doesn't inherit any methods. none of the following methods alter the original matrix. dommatrixreadonly.flipx() returns a new dommatrix created by flipping the source matrix around its x-axis. this is equivalent to
multiplying the matrix by dommatrix(-1, 0, 0, 1, 0, 0). the original matrix is not modified. dommatrixreadonly.flipy() returns a new dommatrix created by flipping the source matrix around its y-axis. this is equivalent to
multiplying the matrix by dommatrix(1, 0, 0, -1, 0, 0). the original matrix is not modified. dommatrixreadonly.inverse() returns a new dommatrix created by inverting the source mat...
...if no matrix is specified as the multiplier, the matrix is multiplied by a matrix in which every element is 0 except the bottom-right corner and the element immediately above and to its left: m33 and m34. these have the default value of 1. ...
Key Values - Web APIs
e to simply be the character generated by the decimal key (one of those two characters). [1] vk_decimal (0x6e) kvk_ansi_keypaddecimal (0x41) gdk_key_kp_decimal (0xffae) keycode_numpad_dot (158) "key11" the 11 key found on certain media numeric keypads. "key12" the 12 key found on certain media numeric keypads. "
multiply" [1] the numeric keypad's multiplication key, *. vk_
multiply (0x6a) kvk_ansi_keypad
multiply (0x43) gdk_key_kp_
multiply (0xffaa) qt::key_
multiply (0x0d7) keycode_numpad_
multiply (155) "add" [1] the numeric keypad's addition key, +. vk_add (0x6b) kvk_ansi_keypadplus (0x45) gdk_key_kp_add (0xffab) keycode_numpad_add (157) "clear" the numeric...
... ...
A basic 2D WebGL animation example - Web APIs
xposition.x * urotationvector.x ); gl_position = vec4(rotatedposition * uscalingfactor, 0.0, 1.0); } </script> the main program shares with us the attribute avertexposition, which is the position of the vertex in whatever coordinate system it's using. we need to convert these values so that both components of the position are in the range -1.0 to 1.0. this can be done easily enough by
multiplying by a scaling factor that's based on the context's aspect ratio. we'll see that computation shortly. we're also rotating the shape, and we can do that here, by applying a transform. we'll do that first. the rotated position of the vertex is computed by applying the rotation vector, found in the uniform urotationvector, that's been computed by the javascript code. then the final position is co...
...caling factor that's based on the context's aspect ratio. we'll see that computation shortly. we're also rotating the shape, and we can do that here, by applying a transform. we'll do that first. the rotated position of the vertex is computed by applying the rotation vector, found in the uniform urotationvector, that's been computed by the javascript code. then the final position is computed by
multiplying the rotated position by the scaling vector provided by the javascript code in uscalingfactor. the values of z and w are fixed at 0.0 and 1.0, respectively, since we're drawing in 2d. the standard webgl global gl_position is then set to the transformed and rotated vertex's position. fragment shader next comes the fragment shader. its role is to return the color of each pixel in the shape bei...
Lighting in WebGL - Web APIs
, directionalvector), 0.0); vlighting = ambientlight + (directionallightcolor * directional); } `; once the position of the vertex is computed, and we pass the coordinates of the texel corresponding to the vertex to the fragment shader, we can work on computing the shading for the vertex. the first thing we do is transform the normal based on the current orientation of the cube, by
multiplying the vertex's normal by the normal matrix. we can then compute the amount of directional lighting that needs to be applied to the vertex by calculating the dot product of the transformed normal and the directional vector (that is, the direction from which the light is coming). if this value is less than zero, then we pin the value to zero, since you can't have less than zero light. once the am...
... the only thing left is to look up the location of the avertexnormal attribute and the unormalmatrix uniform. const programinfo = { program: shaderprogram, attriblocations: { vertexposition: gl.getattriblocation(shaderprogram, 'avertexposition'), vertexn...
WebGL best practices - Web APIs
prefer doing uploads before starting drawing, or at least between pipelines: in webgl: ... bindtexture(webgl_texture) teximage2d(htmlvideoelement) useprogram(prog1) <pipeline flush> bindframebuffer(target) drawarrays() bindtextur...
...l_texture) drawarrays() ... behind the scenes in the browser: ... bindtexture(webgl_texture) -teximage2d(htmlvideoelement): +useprogram(_internal_tex_tranform_prog) <pipeline flush> +bindframebuffer(webgl_texture._internal_framebuffer) +bindtexture(htmlvideoelement._internal_video_tex) +drawarrays() // y-flip/colorspace-transform/alpha-(un)pre
multiply +bindtexture(webgl_texture) +bindframebuffer(target) useprogram(prog1) <pipeline flush> bindframebuffer(target) drawarrays() bindtexture(webgl_texture) drawarrays() ... webgl 2 use texstorage to create textures the teximage* api lets you define each mip level independently and at any size, even the mis-matching mips sizes are not an error until draw tim...
XRReferenceSpaceEvent.transform - Web APIs
ated coordinate system. alternatively, you can just discard any cached positional information and recompute from scratch. the approach you take will depend on your needs. for details on what causes a reset event and how to respond, see the reset event's documentation. ...
...t's documentation. examples this example handles the reset event by walking through all the objects in a scene, updating each object's position by
multiplying it with the event's given transform. the scene is represented by a scene object, with all the objects in an array called objects within it. xrreferencespace.addeventlistener("reset", event => { for (let obj of scene.objects) { mat4.
multiply(obj.transform, obj.transform, event.transform); } }); specifications specification status comment webxr device apithe definition of 'xrreferencespaceevent.transform' in that specification. working draft initial definition. ...
XRRigidTransform.inverse - Web APIs
accessed. applying the inverse of a transform to any object previously transformed by the parent xrrigidtransform always undoes the transformation, resulting in the object returning to its previous pose. in other words, its position and orientation both return to their prior configurations. ...
... both return to their prior configurations. examples in this example, the model view matrix for an object is computed by taking the view matrix and
multiplying it by the object's pose matrix. let modelviewmatrix = mat4.create(); for (let view of pose.view) { let viewport = gllayer.getviewport(view); gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); /* ... */ mat4.
multiply(modelviewmatrix, view.transform.inverse.matrix, objectmatrix); gl.uniformmatrix4fv(programinfo.uniformlocations.modelviewmatrix, false, modelviewmatrix); /* ... */ } this outline of a renderer's core code shows how the pose's view gets represented by taking its transform's inverse's matrix as the model view matrix used to transform objects based on the viewer's positi...
XRView.transform - Web APIs
de fragment used while rendering an xrframe, which makes use of the view transform to place objects in the world during rendering. ...
...m has been left to extend the specification to support that in the future with some additions to the api. for each view, we obtain its viewport and pass that to webgl using gl.viewport(). for the left eye, this will be the left half of the canvas, while the right eye will use the right half. then we iterate over each object that makes up the scene. each object's model view matrix is computed by
multiplying its own matrix which describes the object's own position and orientation by the additional position and orientation adjustments needed to match the camera's movement. to convert the "camera focused" transform matrix into an "object focused" transform, we use the transform's inverse, thus taking the matrix returned by view.transform.inverse.matrix. the resulting model view matrix will apply all...
XRView - Web APIs
l view transforms there are a few special transforms that are used on the view while rendering and lighting a scene. ...
...g and lighting a scene. model view matrix the model view matrix is a matrix which defines the position of an object relative to the space in which it's located: if objectmatrix is a transform applied to the object to provide its basic position and rotation, then the model view matrix can be computed by
multiplying the object's matrix by the inverse of the view transform matrix, like this: mat4.
multiply(modelviewmatrix, view.transform.inverse.matrix, objectmatrix); normal matrix the model view's normal matrix is used when lighting the scene, in order to transform each surface's normal vectors to ensure that the light is reflected in the correct direction given the orientation and position of the surface relative to the light source or sources. it's computed by inverting then transposing the mo...
XRWebGLLayer.getNativeFramebufferScaleFactor() static method - Web APIs
this information can be used when creating a new xrwebgllayer to configure the xrwebgllayerinit property framebufferscalefactor in the options specified when calling the xrwebgllayer() constructor. see the usage notes and examples for details. if the scaling factor is 1.0, then the frame buffer pixels and the native display pixels are the same size. ...
.... return value a floating-point value which, when multiplied by the xrsession's recommended framebuffer dimensions, results in the xr device's native frame buffer resolution. if the session has ended, this function returns 0.0. usage notes the scaling factor returned by this function will be 1.0 if the native resolution of the xr device and the resolution of the xr device match. in any case,
multiplying the recommended resolution as identified by the xrsession by this value will result in the actual native resolution of the xr hardware. the recommended webgl frame buffer resolution is the best possible estimate of the resolution necessary to contain all of fthe xrviews needed by the device while at the same time providing typical applications an acceptable balance of image quality and perfor...
background-blend-mode - CSS: Cascading Style Sheets
ode to be applied. there can be several values, separated by commas. formal definition initial valuenormalapplies toall elements. in svg, it applies to container elements, graphics elements, and graphics referencing elements.. ...
...etter and ::first-line.inheritednocomputed valueas specifiedanimation typediscrete formal syntax <blend-mode>#where <blend-mode> = normal |
multiply | screen | overlay | darken | lighten | color-dodge | color-burn | hard-light | soft-light | difference | exclusion | hue | saturation | color | luminosity examples <div id="div"></div> <select id="select"> <option>normal</option> <option>
multiply</option> <option selected>screen</option> <option>overlay</option> <option>darken</option> <option>lighten</option> <option>color-dodge</option> <option>color-burn</option> <option>hard-light</option> <option>soft-light</option> <option>difference</option> <option>exclusion</option> <option>hue</option> <option>saturation</option> <option>color<...
Rest parameters - JavaScript
ts is given by the length property: function fun1(...theargs) { console.log(theargs.length) } fun1() // 0 fun1(5) // 1 fun1(5, 6, 7) // 3 ordinary parameter and rest parameters in the next example, a rest parameter is used to collect all parameters after the first into an array. ...
...un1(5) // 1 fun1(5, 6, 7) // 3 ordinary parameter and rest parameters in the next example, a rest parameter is used to collect all parameters after the first into an array. ...
MMgc - Archive of obsolete content
es in the library; for example: mmgc::gc, mmgc::gcfinalizedobject. alternately, you can open the mmgc namespace in your c++ source so that you can refer to the objects more concisely: using namespace mmgc; ... gc* gc = gc::getgc(this); gcobject* gcobject; gc class the class mmgc::gc is the main class of the gc. it represents a full, self-contained instance of the garbage collector. it may be
multiply instantiated; you may have multiple instances of the garbage collector running at once. each instance manages its own set of objects; objects are not allowed to reference objects in other gc instances. the gc typically is constructed early in your program's initialization, and then passed to operations like operator new for allocating gc objects. there are a few methods that you may need to call...
Visualizing an audio spectrum - Archive of obsolete content
fbl; i++ ) { // assuming interlaced stereo channels, // need to split and merge into a stero-mix mono signal signal[i] = (fb[2*i] + fb[2*i+1]) / 2; } fft.forward(signal); // clear the canvas before drawing spectrum ctx.clearrect(0,0, canvas.width, canvas.height); for (var i = 0; i < fft.spectrum.length; i++ ) { //
multiply spectrum by a zoom value magnitude = fft.spectrum[i] * 4000; // draw rectangle bars for each frequency bin ctx.fillrect(i * 4, canvas.height, 3, -magnitude); } } var audio = document.getelementbyid('audio-element'); audio.addeventlistener('mozaudioavailable', audioavailable, false); audio.addeventlistener('loadedmetadata', loadedmeta...
confirm - Archive of obsolete content
confirmation dialog. this string is typically in the form of a prompt for the user (e.g., "are you sure you want to delete the selected file(s)?"). adialogtitle the string to be used as the dialog title. defaults to "confirm" (or the localized equivalent). abuttonflags a set of flags defining the buttons that should appear in the dialog. the value is calculated by
multiplying the corresponding button position constant with a button title constant for each button, then adding the results and any additional options (see other constants). button position constants button_pos_0: the first logical button button_pos_1: the second logical button button_pos_2: the third logical button button title constants button...
Keyboard Shortcuts - Archive of obsolete content
vk_b vk_c vk_d vk_e vk_f vk_g vk_h vk_i vk_j vk_k vk_l vk_m vk_n vk_o vk_p vk_q vk_r vk_s vk_t vk_u vk_v vk_w vk_x vk_y vk_z vk_numpad0 vk_numpad1 vk_numpad2 vk_numpad3 vk_numpad4 vk_numpad5 vk_numpad6 vk_numpad7 vk_numpad8 vk_numpad9 vk_
multiply vk_add vk_separator vk_subtract vk_decimal vk_divide vk_f1 vk_f2 vk_f3 vk_f4 vk_f5 vk_f6 vk_f7 vk_f8 vk_f9 vk_f10 vk_f11 vk_f12 vk_f13 vk_f14 vk_f15 vk_f16 vk_f17 vk_f18 vk_f19 vk_f20 vk_f21 vk_f22 vk_f23 vk_f24 vk_num_lock vk_scroll_lock vk_comma vk_p...
Displaying a graphic with audio samples - Archive of obsolete content
tereo channels, // need to split and merge into a stero-mix mono signal signal[i] = (fb[2*i] + fb[2*i+1]) / 2; } // clear the canvas before drawing spectrum ctx.fillstyle = "rgb(0,0,0)"; ctx.fillrect (0,0, canvas.width, canvas.height); ctx.fillstyle = "rgb(255,255,255)"; for (var i = 0; i < signal.length; i++ ) { //
multiply spectrum by a zoom value magnitude = signal[i] * 1000; // draw rectangle bars for each frequency bin ctx.fillrect(i * 4, canvas.height, 3, -magnitude); } ctx.drawimage(document.getelementbyid('mozlogo'),0,0, canvas.width, canvas.height); } var audio = document.getelementbyid('audio-element'); audio.addeventlistener('mozau...
GLSL Shaders - Game development
the current example. save and load index.html in your browser — you should see a blue cube. the vertex shader code let's continue by writing a simple vertex shader — add the code below inside the body's first <script> tag: void main() { gl_position = projectionmatrix * modelviewmatrix * vec4(position.x+10.0, position.y, position.z+5.0, 1.0); } the resulting gl_position is calculated by
multiplying the model-view and the projection matrices by each vector to get the final vertex position, in each case. note: you can learn more about model, view, and projection transformations from the vertex processing paragraph, and you can also check out the links at the end of this article to learn more about it. both projectionmatrix and modelviewmatrix are provided by three.js and the vector is ...
Video and Audio APIs - Learn web development
digital clock display works. the actual time value to display is set as minutevalue plus a colon character plus secondvalue. the node.textcontent value of the timer is set to the time value, so it displays in the ui. the length we should set the inner <div> to is worked out by first working out the width of the outer <div> (any element's clientwidth property will contain its length), and then
multiplying it by the htmlmediaelement.currenttime divided by the total htmlmediaelement.duration of the media. we set the width of the inner <div> to equal the calculated bar length, plus "px", so it will be set to that number of pixels. fixing play and pause there is one problem left to fix. if the play/pause or stop buttons are pressed while the rewind or fast forward functionality is active, they ...
Basic math in JavaScript — numbers and operators - Learn web development
finally "60 divided by 10 equals 6". but the browser does "10 divided by 8 equals 1.25", then "50 plus 1.25 plus 2 equals 53.25". this is because of operator precedence — some operators are applied before others when calculating the result of a calculation (referred to as an expression, in programming). operator precedence in javascript is the same as is taught in math classes in school —
multiply and divide are always done first, then add and subtract (the calculation is always evaluated from left to right). if you want to override operator precedence, you can put parentheses round the parts that you want to be explicitly dealt with first. so to get a result of 6, we could do this: (num2 + num1) / (8 + 2); try it and see. note: a full list of all javascript operators and their preced...
What went wrong? Troubleshooting JavaScript - Learn web development
ecimal number between 0 and 1, e.g. 0.5675493843. math.random() next, we pass the result of invoking math.random() through math.floor(), which rounds the number passed to it down to the nearest whole number. we then add 1 to that result: math.floor(math.random()) + 1 rounding a random decimal number between 0 and 1 down will always return 0, so adding 1 to it will always return 1. we need to
multiply the random number by 100 before we round it down. the following would give us a random number between 0 and 99: math.floor(math.random()*100); hence us wanting to add 1, to give us a random number between 1 and 100: math.floor(math.random()*100) + 1; try updating both lines like this, then save and refresh — the game should now play like we are intending it to! other common errors there a...
MathML Demo: <mtable> - tables and matrices
he reverse ---... ab ab ab ab ab ab , modulo pixel roundoff errors. here 'a' and 'b' can be other combinations of possibly irregular boxes. and making floating elements do a multiplication such as the following one which is anchored at a baseline is made simple by using align="baseline1" on both tables [ a b c d ] [ a b c d ] to
multiply a matrix a by a vector x, each row of the matrix has to be multiplied to the vector. so at the i-th step, it proceeds thus: i-th row [ a11 a12 a13 … a1n ⋮ ⋮ ⋮ … ⋮ ai1 ai2 ai3 … ain ⋮ ⋮ ⋮ ⋮ an1 an2 an3 … a n n ] [ x1 x2 x3 ⋮ xn ] ...
BloatView
0.00% nsframe 47568 -26.15% 48096 -50.49% cssdeclarationimpl 42984 0.67% 43488 0.67% this "delta report" shows the leak offenders, sorted from most leaks to fewest. the delta numbers show the percentage change between runs for the amount of leaks and amount of bloat (negative numbers are better!). the bloat number is a metric determined by
multiplying the total number of objects allocated of a given class by the class size. note that although this isn't necessarily the amount of memory consumed at any given time, it does give an indication of how much memory we're consuming. the more memory in general, the worse the performance and footprint. the percentage 99999.99% will show up indicating an "infinite" amount of leakage. this happens when...
nss tech note6
responding libfreebl_32int_3.chk on the 64-bit solaris sparc architecture, there are 2 freebl libraries : libfreebl_64int_3.so for ultrasparc t1 cpus, with a corresponding libfreebl_64int_3.chk libfreebl_64fpu_3.so for other ultrasparc cpus, with a corresponding libfreebl_64fpu_3.chk on the 32-bit hp-ux pa-risc architecture, there are 2 freebl libraries : libfreebl_32fpu_3.sl for cpus that do
multiply operations faster in floating point, with a corresponding libfreebl_32fpu_3.chk libfreebl_32int_3.sl for other pa-risc cpus, with a corresponding libfreebl_32int_3.chk on the 64-bit hp-ux pa-risc architecture, there is only one freebl library, called libfreebl3.sl, with a corresponding libfreebl3.chk applications should always use nss binaries that are the output of the regular nss build proc...
Redis Tips
anage the queues themselves, and store pointers for the job data which might be retrieved by workers from some different, disk-resident db. (this is, for instance, how tj holowaychuk's implemented kue: https://github.com/learnboost/kue.) memory usage in redis is important to think about. the speed benefits of redis are lost when you overflow into disk memory. as a conservative calculation, i
multiply all the bytes i think i might store and
multiply by 10, which antirez once recommended as a worst-case factor for data structure overhead. keyspace design here are some things i keep in mind when creating keys: keys are like urls and should read like nice urls keys are like urls with paths separated by a colon, ':' (this is convention only) use a common prefix for all keys in your app (l...
Starting WebLock
out parameter of the method getfilesize is a 64-bit integer. the type of this variable is print64, but this type is not represented as a primitive on all platforms. on some platforms, print64 is a struct with two fields - a high and a low 32-bit integer. so operations on this type must use special macros that do the right thing on each platform. on windows or linux, for example, it is possible to
multiply a print64 by a long like this: print64 x = 1, y = 2; y = x * 2; however, this same snippet will not compile on a platform like macintosh os 9, where you need to use macros to perform the calculation: print64 x, y, two; ll_i2l(x, 1); ll_i2l(y, 2); ll_i2l(two, 2); ll_mul(y, x, two); a full listing of nspr's long long support can be found at http://www.mozilla.org/projects/nspr/. the weblock ...
RefPtr
ent to the nscomptr (common in implementation details of nscomptr) but not when an instance of the concrete class is assigned directly?). and it's not clear what happens when the compiler does accept this pattern. what goes wrong at runtime - uaf? memory leak? qi failure and null-deref crashes?. note: in the above example, "nscomptr<nsfoo>" might compile and work ok (it won't if your xpcom class
multiply-inherits nsisupports). but this is considered bad form, and may soon be made a compile-time error. don't do it! can i queryinterface a refptr to get a nscomptr from the object it points to? sure. instead of using "do_queryinterface()" (which is used for nscomptrs), use "do_queryobject()", which works with refptrs: // let's say nsfoo implements nsifoo and nsibar xpcom interfaces: refptr<nsf...
Using the clipboard
.getinterface(ci.nsiwebnavigation); res.init(source); } return res; } here, the string "text to copy" will be copied but you can replace this with the text string that you want to copy. now that we have the object to copy, a transferring object needs to be created: var str = "text to copy"; var trans = transferable(sourcewindow); trans.adddataflavor("text/unicode"); // we
multiply the length of the string by 2, since it's stored in 2-byte utf-16 // format internally. trans.settransferdata("text/unicode", supportsstring(str), str.length * 2); the first line gets the transferring component which implements nsitransferable. next we need to initialize it with a "privacy context", which will ensure that source data from inside private browsing mode will be cleared when the mo...
AudioNode.channelInterpretation - Web APIs
l output.r = input.r output.c = 0 output.lfe = 0 output.sl = input.sl output.sr = input.sr 6 (5.1) 1 (mono) down-mix from 5.1 to mono. the left (l and sl), right (r and sr) and central channels are all mixed together. the surround channels are slightly attenuated and the regular lateral channels are power-compensated to make them count as a single channel by
multiplying by √2/2. the subwoofer (lfe) channel is lost. output.m = 0.7071 * (input.l + input.r) + input.c + 0.5 * (input.sl + input.sr) 6 (5.1) 2 (stereo) down-mix from 5.1 to stereo. the central channel (c) is summed with each lateral surround channel (sl or sr) and mixed to each lateral channel. as it is mixed down to two channels, it is mixed at a lower power: in each case it...
DOMMatrix - Web APIs
b m12 c m21 d m22 e m41 f m42 methods this interface includes the following methods, as well as the methods it inherits from dommatrixreadonly. dommatrix.invertself() modifies the matrix by inverting it. if the matrix can't be inverted, its components are all set to nan, and is2d returns false. dommatrix.
multiplyself() modifies the matrix by post-
multiplying it with the specified dommatrix. this is equivalent to the dot product a⋅b, where matrix a is the source matrix and b is the matrix given as an input to the method. returns itself. dommatrix.pre
multiplyself() modifies the matrix by pre-
multiplying it with the specified dommatrix. this is equivalent to the dot product b⋅a, where matrix a is the ...
SVGFEBlendElement - Web APIs
r text { fill: #0095dd; pointer-events: all;} constants name value description svg_feblend_mode_unknown 0 the type is not one of predefined types. it is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type. svg_feblend_mode_normal 1 corresponds to the value normal. svg_feblend_mode_
multiply 2 corresponds to the value
multiply. svg_feblend_mode_screen 3 corresponds to the value screen. svg_feblend_mode_darken 4 corresponds to the value darken. svg_feblend_mode_lighten 5 corresponds to the value lighten. properties this interface also inherits properties from its parent interface, svgelement, and implements properties of svgfi...
SVGMatrix - Web APIs
at representing the a component of the matrix. svgmatrix.b a float representing the b component of the matrix. svgmatrix.c a float representing the c component of the matrix. svgmatrix.d a float representing the d component of the matrix. svgmatrix.e a float representing the e component of the matrix. svgmatrix.f a float representing the f component of the matrix. methods svgmatrix.
multiply() performs matrix multiplication. this matrix is post-multiplied by another matrix, returning the resulting new matrix as svgmatrix. svgmatrix.inverse() returns the inverse matrix as svgmatrix. svgmatrix.translate() post-multiplies a translation transformation on the current matrix and returns the resulting matrix as svgmatrix. svgmatrix.scale() post-multiplies a uniform scale transformati...
SVGTransformList - Web APIs
ransformfrommatrix(in svgmatrix) svgtransform creates an svgtransform object which is initialized to transform of type svg_transform_matrix and whose values are the given matrix. the values from the parameter matrix are copied, the matrix parameter is not adopted as svgtransform::matrix. consolidate() svgtransform consolidates the list of separate svgtransform objects by
multiplying the equivalent transformation matrices together to result in a list consisting of a single svgtransform object of type svg_transform_matrix. the consolidation operation creates new svgtransform object as the first and only item in the list. the returned item is the item itself and not a copy. any changes made to the item are immediately reflected in the list. exceptions: a dome...
TextEncoder.prototype.encodeInto() - Web APIs
llocator is known to use power-of-two buckets, rounduptobucketsize() should return the argument if it is a power-of-two or the next power-of-two otherwise. if the behavior of the wasm allocator is unknown, rounduptobucketsize() should be an identity function. if the behavior of your allocator is unknown, you might want to have up to two reallocation steps and make the the first reallocation step
multiply the remaining unconverted length by two instead of three. however, in that case, it makes sense not to implement the usual
multiplying by two of the already written buffer length, because in such a case if a second reallocation happened, it would always overallocate compared to the original length times three.the above advice assumes that you don't need to allocate space for a zero terminator. th...
WaveShaperNode.oversample - Web APIs
applied, the number of samples is reduced to its initial numbers. this leads to better results by avoiding some aliasing, but comes at the expense of a lower precision shaping curve. the possible oversample values are: value effect 'none' do not perform any oversampling. '2x' double the amount of samples before applying the shaping curve. '4x'
multiply by 4 the amount of samples before applying the shaping curve. syntax distortion.oversample = enumeratedvalue; values distortion is a waveshapernode. enumeratedvalue is one of 'none', '2x', or '4x'. example the following example shows basic usage of an audiocontext to create a wave shaper node. for applied examples/information, check out our voice-change-o-matic demo (see app.js f...
WebGLRenderingContext.pixelStorei() - Web APIs
specified in gl.pack_alignment packing of pixel data into memory glint 4 1, 2, 4, 8 opengl es 2.0 gl.unpack_alignment unpacking of pixel data from memory. glint 4 1, 2, 4, 8 opengl es 2.0 gl.unpack_flip_y_webgl flips the source data along its vertical axis if true. glboolean false true, false webgl gl.unpack_pre
multiply_alpha_webgl multiplies the alpha channel into the other color channels glboolean false true, false webgl gl.unpack_colorspace_conversion_webgl default color space conversion or no color space conversion. glenum gl.browser_default_webgl gl.browser_default_webgl, gl.none webgl when using a webgl 2 context, the following values are available additionally...
Geometry and reference spaces in WebXR - Web APIs
ransform to adjust the coordinates of all vertices. the most efficient way, of course, is to design your objects and code to use the same coordinate system as webgl does. the webgl coordinates and lengths are transformed automatically at render time to the size of the viewport in which the scene is being rendered. angles angles are specified using radians. to convert degrees to radians, simply
multiply the value in degrees by π/180. the following code snippet shows two simple functions, degreestoradians() and radianstodegrees(), which convert back and forth between the two units for measuring angles. const radians_per_degree = math.pi / 180.0; let degreestoradians = (deg) => deg * radians_per_degree; let radianstodegrees = (rad) => rad / radians_per_degree; times and durations note that f...
Lighting a WebXR setting - Web APIs
nt light ambient light is light that doesn't come from a defined source, but is just present throughout the scene. this light reaches every surface in the scene at the same intensity from every direction, and is then reflected equally in every direction. as a result, the effect applied by ambient light is universally equal all through the scene. the effect of ambient light is computed by simply
multiplying the intensity of the light source by the reflectance of the surface at the pixel's location. the color and intensity of every pixel in the scene is affected exactly the same way, regardless of where it is in the scene or the direction it's facing. ambient light is commonly present simply to prevent shadowed areas from becoming too dark, although it affects the entire scene; however, the amount...
Rendering and the WebXR frame animation callback - Web APIs
{ /* ... schedule next frame, prepare the buffer, etc ... */ const deltatime = (time - lastframetime) * 0.001; lastframetime = time; for (let view of pose.views) { /* render each view */ } } this maintains a global (or an object property) called lastframetime which contains the previous frame's time of rendering. in this case, since the time values are stored in milliseconds, we
multiply by 0.001 to convert the time into seconds. in some cases, this saves time later. in other situations, you need the time in milliseconds, so you wouldn't need to change anything. with the elapsed time in hand, your rendering code has the means to compute just how much every moving object has moved in the time elapsed. for instance, if an object is rotating, you might apply the rotation like this:...
Using the Web Animations API - Web APIs
ckrate. we use updateplaybackrate() instead of setting the playbackrate directly since that produces a smooth update: setinterval( function() { // make sure the playback rate never falls below .4 if (redqueen_alice.playbackrate > .4) { redqueen_alice.updateplaybackrate(redqueen_alice.playbackrate * .9); } }, 3000); but urging them on by clicking or tapping causes them to speed up by
multiplying their playbackrate: var gofaster = function() { redqueen_alice.updateplaybackrate(redqueen_alice.playbackrate * 1.1); } document.addeventlistener("click", gofaster); document.addeventlistener("touchstart", gofaster); the background elements also have playbackrates that are impacted when you click or tap. what happens when you make alice and the red queen run twice as fast? what happens wh...
Basic concepts behind Web Audio API - Web APIs
l output.r = input.r output.c = 0 output.lfe = 0 output.sl = input.sl output.sr = input.sr 6 (5.1) 1 (mono) down-mix from 5.1 to mono. the left (l and sl), right (r and sr) and central channels are all mixed together. the surround channels are slightly attenuated and the regular lateral channels are power-compensated to make them count as a single channel by
multiplying by √2/2. the subwoofer (lfe) channel is lost. output.m = 0.7071 * (input.l + input.r) + input.c + 0.5 * (input.sl + input.sr) 6 (5.1) 2 (stereo) down-mix from 5.1 to stereo. the central channel (c) is summed with each lateral surround channel (sl or sr) and mixed to each lateral channel. as it is mixed down to two channels, it is mixed at a lower power: in each case it...
Visualizations with Web Audio API - Web APIs
ating, and clearing the display with each animation frame. function draw() { drawvisual = requestanimationframe(draw); analyser.getbytefrequencydata(dataarray); canvasctx.fillstyle = 'rgb(0, 0, 0)'; canvasctx.fillrect(0, 0, width, height); now we set our barwidth to be equal to the canvas width divided by the number of bars (the buffer length). however, we are also
multiplying that width by 2.5, because most of the frequencies will come back as having no audio in them, as most of the sounds we hear every day are in a certain lower frequency range. we don't want to display loads of empty bars, therefore we simply shift the ones that will display regularly at a noticeable height across so they fill the canvas display. we also set a barheight variable, and an x variab...
Web Audio API - Web APIs
rcenode) and audio streams (mediastreamaudiosourcenode). in fact, sound files are just recordings of sound intensities themselves, which come in from microphones or electric instruments, and get mixed down into a single, complicated wave. outputs of these nodes could be linked to inputs of others, which mix or modify these streams of sound samples into different streams. a common modification is
multiplying the samples by a value to make them louder or quieter (as is the case with gainnode). once the sound has been sufficiently processed for the intended effect, it can be linked to the input of a destination (audiocontext.destination), which sends the sound to the speakers or headphones. this last connection is only necessary if the user is supposed to hear the audio. a simple, typical workflow ...
self.createImageBitmap() - Web APIs
ebitmap will be extracted. this value can be negative. sh the height of the rectangle from which the imagebitmap will be extracted. this value can be negative. options optional an object that sets options for the image's extraction. the available options are: imageorientation: specifies whether the image should be presented as is or flipped vertically. either none (default) or flipy. pre
multiplyalpha: specifies whether the bitmap's color channels should be premultiplied by the alpha channel. one of none, pre
multiply, or default (default). colorspaceconversion: specifies whether the image should be decoded using color space conversion. either none or default (default). the value default indicates that implementation-specific behavior is used. resizewidth: a long integer that indicates...
XRRigidTransform.matrix - Web APIs
this yields the final transform matrix as returned by matrix: [1-2(qy2+qz2)2(qxqy-qzqw)2(qxqz+qyqw)px2(qxqy+qzqw)1-2(qx2+qz2)2(qyqz-qxqw)py2(qxqz-qyqw)2(qyqz+qxqw)1-2(qx2+qy2)pz0001]\begin{bmatrix} 1 - 2(q_y^2 + q_z^2) & 2(q_xq_y - q_zq_w) & 2(q_xq_z + q_yq_w) & p_x\\ 2(q_xq_y + q_zq_w) & 1 - 2(q_x^2 + q_z^2...
filter - CSS: Cascading Style Sheets
cal-align: top; width:25%; height:auto; } #img3 { height:100%; } opacity() the opacity() function applies transparency to the samples in the input image. the value of amount defines the proportion of the conversion. a value of 0% is completely transparent. a value of 100% leaves the input unchanged. values between 0% and 100% are linear multipliers on the effect. this is equivalent to
multiplying the input image samples by amount. the lacuna value for interpolation is 1. this function is similar to the more established opacity property; the difference is that with filters, some browsers provide hardware acceleration for better performance. filter: opacity(50%) <table class="standard-table"> <thead> <tr> <th style="text-align: left;" scope="col">original image</th> ...
Expressions and operators - JavaScript
y are applied when evaluating an expression. you can override operator precedence by using parentheses. the following table describes the precedence of operators, from highest to lowest. operator precedence operator type individual operators member . ...
Array.prototype.reduce() - JavaScript
nsole.log) // 1200 function composition enabling piping // building-blocks to use for composition const double = x => x + x const triple = x => 3 * x const quadruple = x => 4 * x // function composition enabling pipe functionality const pipe = (...functions) => input => functions.reduce( (acc, fn) => fn(acc), input ) // composed functions for multiplication of specific values const
multiply6 = pipe(double, triple) const
multiply9 = pipe(triple, triple) const
multiply16 = pipe(quadruple, quadruple) const
multiply24 = pipe(double, triple, quadruple) // usage
multiply6(6) // 36
multiply9(9) // 81
multiply16(16) // 256
multiply24(10) // 240 write map using reduce if (!array.prototype.mapusingreduce) { array.prototype.mapusingreduce = function(callback, thisarg) { return t...
Math.imul() - JavaScript
imul, you will experience a degrade in performance. this is because of the costly conversion from a floating point to an integer for multiplication, and then converting the multiplied integer back into a floating point. the reason imul exists is because it is faster in only one (so far) circumstance: asmjs. asmjs allows for jist-optimizers to more easily implement internal integers in javascript.
multiplying two numbers stored internally as integers (which is only possible with asmjs) with imul is the only potential circumstance where math.imul may prove performant in current browsers. polyfill this can be emulated with the following function: if (!math.imul) math.imul = function(a, b) { var ahi = (a >>> 16) & 0xffff; var alo = a & 0xffff; var bhi = (b >>> 16) & 0xffff; var blo = b & 0...
Digital audio concepts - Web media technologies
tion when listening to the audio. the lfe channels typically drive subwoofers and similar devices. monophonic audio has one channel, stereo sound has two channels, 5.1 surround sound has 6 channels (five standard and one lfe), and so forth. each audio frame is a data record that contains the samples for all of the channels available in an audio signal. the size of an audio frame is calculated by
multiplying the sample size in bytes by the number of channels, so a single frame of stereo 16-bit audio is 4 bytes long and a single frame of 5.1 floating-point audio is 24 (4 bytes per sample multiplied by 6 channels). note: it's worth noting that some codecs will actually separate the left and right channels, storing them in separate blocks within their data structure. however, an audio frame is alwa...