复制代码代码如下: for (var i = 0; i i++) { // Grab the RBG for each pixel: r = currentFrameSource1.data[i * 4 + 0]; g = currentFrameSource1.data[i * 4 + 1]; b = currentFrameSource1.data[i * 4 + 2];
// If this seems like a green pixel replace it: if ( (r = 0 r = 59) (g = 74 g = 144) (b = 0 b = 56) ) // Target green is (24, 109, 21), so look around those values. { pixelIndex = i * 4; currentFrameSource1.data[pixelIndex] = currentFrameSource2.data[pixelIndex]; currentFrameSource1.data[pixelIndex + 1] = currentFrameSource2.data[pixelIndex + 1]; currentFrameSource1.data[pixelIndex + 2] = currentFrameSource2.data[pixelIndex + 2]; currentFrameSource1.data[pixelIndex + 3] = currentFrameSource2.data[pixelIndex + 3]; } }
head script type="text/javascript" // This function is called when the circle is clicked. function clickMe() { // Display the alert. alert("You clicked the SVG UI element."); } /script /head body h1 SVG User Interface /h1 !-- Create the SVG pane. -- svg height="200" width="200" !-- Create the circle. -- circle cx="100" cy="100" r="50" fill="gold" id="uIElement" / /svg p Click on the gold circular user interface element. /p /body /html