grayscale image in canvas
JavaScript
window.onload = function() {
let canvas = document.getElementById("c");
let ctx = canvas.getContext("2d");
canvas.width=50;
canvas.height=50;
let srcImg = document.getElementById("sof");
ctx.drawImage(srcImg, 0, 0, ctx.canvas.width, ctx.canvas.height);
let imgData = ctx.getImageData(0, 0, ctx.canvas.width, ctx.canvas.height);
let pixels = imgData.data;
for (var i = 0; i < pixels.length; i += 4) {
let lightness = parseInt((pixels[i] + pixels[i + 1] + pixels[i + 2])/3);
pixels[i] = lightness;
pixels[i + 1] = lightness;
pixels[i + 2] = lightness;
}
ctx.putImageData(imgData, 0, 0);
}
Also in JavaScript:
- Title
- how to check if object has key javascript
- Category
- JavaScript
- Title
- change style on click react
- Category
- JavaScript
- Title
- function and returns node js
- Category
- JavaScript
- Title
- firestore update map
- Category
- JavaScript
- Title
- concantene number in js
- Category
- JavaScript
- Title
- How can I refresh a page with jQuery
- Category
- JavaScript
- Title
- cdn react
- Category
- JavaScript
- Title
- how to print numbers in javascript
- Category
- JavaScript
- Title
- async axios call
- Category
- JavaScript
- Title
- how to run mocha tests on asynchronous functions in script
- Category
- JavaScript
- Title
- how to change the color using js
- Category
- JavaScript
- Title
- how to use the map method in javascript
- Category
- JavaScript
- Title
- how to find length of array in javascript without using length method
- Category
- JavaScript
- Title
- How to make string shorter javascript
- Category
- JavaScript
- Title
- javascript check if two date ranges overlap
- Category
- JavaScript
- Title
- () = javascript
- Category
- JavaScript
- Title
- Finding HTML Elements
- Category
- JavaScript
- Title
- how to prevent event capturing in javascript
- Category
- JavaScript
- Title
- ajax laravel get data
- Category
- JavaScript
- Title
- add multiple images inside the DOM js
- Category
- JavaScript
- Title
- adjust() js
- Category
- JavaScript
- Title
- get location from brwoser react
- Category
- JavaScript
- Title
- deep clone array in javascript
- Category
- JavaScript
- Title
- angular http call caching issue even after no-cache
- Category
- JavaScript
- Title
- event listener javascript
- Category
- JavaScript
- Title
- console log larger
- Category
- JavaScript
- Title
- get random numbers javascript
- Category
- JavaScript
- Title
- are you sure javascript
- Category
- JavaScript
- Title
- check window resize javascript
- Category
- JavaScript
- Title
- function in react
- Category
- JavaScript
- Title
- how to freeze js object
- Category
- JavaScript
- Title
- how to include local image files in javascript object
- Category
- JavaScript
- Title
- how to make a var and sprite in javascript
- Category
- JavaScript
- Title
- angularjs left xx characters
- Category
- JavaScript
- Title
- how to remove an object from array in react native
- Category
- JavaScript
- Title
- app script append two list
- Category
- JavaScript
- Title
- How do you start a Node Application, if the entry file is index.js:
- Category
- JavaScript
- Title
- how to delete object property of array javascript
- Category
- JavaScript
- Title
- angular file upload app with django
- Category
- JavaScript
- Title
- finding an element ina na array in js
- Category
- JavaScript
- Title
- array to string javascript
- Category
- JavaScript
- Title
- angularjs iframe src binding
- Category
- JavaScript
- Title
- angular run with proxy
- Category
- JavaScript
- Title
- create csv file javascript
- Category
- JavaScript
- Title
- how to craete a shopping cart in node js
- Category
- JavaScript
- Title
- AWS SDK for javascript assumerole with proxy
- Category
- JavaScript
- Title
- how to update kali linux on virtualbox
- Category
- JavaScript
- Title
- get only last 2 digit of year in javascript
- Category
- JavaScript
- Title
- how to create simple node project
- Category
- JavaScript
- Title
- javascript canvas
- Category
- JavaScript
- Title
- for(let [key,val] in obj){ messageBody = messageBody.replace("{"+ key + "}",val) }
- Category
- JavaScript
- Title
- ajax
- Category
- JavaScript
- Title
- add 2 class names react
- Category
- JavaScript
- Title
- cortar elemento y pegar en otro lugar jquery
- Category
- JavaScript
- Title
- check if date equal js
- Category
- JavaScript
- Title
- .filter js
- Category
- JavaScript
- Title
- blob to text javascript
- Category
- JavaScript
- Title
- if else javascript
- Category
- JavaScript
- Title
- axios set authorization header
- Category
- JavaScript
- Title
- check value exist in array javascript
- Category
- JavaScript
- Title
- javascript check if number is hexadecimal
- Category
- JavaScript
- Title
- anagram javascript example
- Category
- JavaScript
- Title
- angular npm angular material
- Category
- JavaScript
- Title
- go to page jquery
- Category
- JavaScript
- Title
- express router file
- Category
- JavaScript
- Title
- if condition in class angular 8
- Category
- JavaScript
- Title
- access index of array javascript
- Category
- JavaScript
- Title
- how to add ' in javascript string
- Category
- JavaScript
- Title
- check if var is NaN
- Category
- JavaScript
- Title
- javascript array of cumulative sum
- Category
- JavaScript
- Title
- how to scroll to an element javascript react
- Category
- JavaScript
- Title
- dom create element
- Category
- JavaScript
- Title
- async await javascript
- Category
- JavaScript
- Title
- cannot use getidtoken if null
- Category
- JavaScript
- Title
- bootstrap modal remove gray background
- Category
- JavaScript
- Title
- collision detection three js
- Category
- JavaScript
- Title
- how to get the index of an array in javascript
- Category
- JavaScript
- Title
- http interceptor angular
- Category
- JavaScript
- Title
- how reliable is js hasownproperty
- Category
- JavaScript
- Title
- how to attach javascript to html
- Category
- JavaScript
- Title
- how to load the images from the website dynamically in react
- Category
- JavaScript
- Title
- excel javascript api protect worksheet
- Category
- JavaScript
- Title
- close exit app react native
- Category
- JavaScript
- Title
- go to another page javascript
- Category
- JavaScript
- Title
- how to concatenate strings javascript
- Category
- JavaScript
- Title
- how to get tomorrow date in javascript
- Category
- JavaScript
- Title
- getting value from radio button javascript
- Category
- JavaScript
- Title
- axios post data vue js
- Category
- JavaScript
- Title
- javascript array contains
- Category
- JavaScript
- Title
- disable inputetext in react native
- Category
- JavaScript
- Title
- adonis js sort by
- Category
- JavaScript
- Title
- google sign in in firebase react
- Category
- JavaScript
- Title
- angular moment pipe timeAgo
- Category
- JavaScript
- Title
- document delete element
- Category
- JavaScript
- Title
- gitignore for angular
- Category
- JavaScript
- Title
- angry professor javascript
- Category
- JavaScript
- Title
- convert milliseconds to minutes and seconds javascript
- Category
- JavaScript
- Title
- Javascript compare two arrays
- Category
- JavaScript
- Title
- how to use a fixed time zone in nodejs
- Category
- JavaScript
- Title
- chrome add a javascript bookmark
- Category
- JavaScript