Home >Web Front-end >JS Tutorial >Why is visual important?
Starting with OOP, client-server applications and ML, it's often unclear how important it is to visualize data. For example, receiving a response from the server prints the console and the functionality is obvious, but how to display this data to the client?
var image; function upload() { var canvas=document.getElementById("can"); var fileinput=document.getElementById("finput"); image=new SimpleImage(fileinput); image.drawTo(canvas); } function makeGrey() { for (var pixel of image.values()){ var avg =(pixel.getRed()+pixel.getGreen()+pixel.getBlue())/3; pixel.setRed(avg); pixel.setGreen(avg); pixel.setBlue(avg); } var canvas=document.getElementById("can2"); image.drawTo(canvas); }
The simplest visual forms can be learned to make and connected to the server part for processing data and displaying it on the screen. Note that variable declarations at system boundaries are done in a scoped (local/global) manner.
Don't be lazy to explicitly indicate which file is saved to which variable, this will help avoid collisions when saving data. Especially if there're many services and asynchronous stream processing is in progress.
function docolor() { var dd1=document.getElementById("d1"); var colorinput=document.getElementById("clr"); var color = colorinput.value; dd1.style.backgroundColor=color; } function dosquare() { var dd1=document.getElementById("d1"); var sizeinput=document.getElementById("slr"); var size = sizeinput.value; var ctx=dd1.getContext("2d"); ctx.clearRect(0,0, dd1.width, dd1.height); ctx.fillStyle="#8B0000"; ctx.fillRect(10,10,size,size); ctx.fillRect(parseInt(size)+20,10,size,size); //ctx.fillRect(size*3,10,size,size); }
Use React to match the master system file image sizes with the image on the screen (slave). Unfortunately, it won't work the other way around, because the handler will only work when receiving/transmitting data on the master device.
The above is the detailed content of Why is visual important?. For more information, please follow other related articles on the PHP Chinese website!