Found 10483 Articles for Web Development

Get pixel color from canvas with HTML

Arjun Thakur
Updated on 04-Mar-2020 06:30:51

347 Views

To get the pixel color from canvas, use the following code. This returns the color in rgba −var index = (Math.floor(y) * canvasWidth + Math.floor(x)) * 4 // color in rgba var r = data[index] var g = data[index + 1] var b = data[index + 2] var a = data[index + 3]

Not showing a placeholder for input type=“date” field with HTML5. How to solve it?

Giri Raju
Updated on 04-Mar-2020 06:30:07

4K+ Views

To show it, use the following −You can also go for CSS −input[type="date"]::before{    color: #ffffff;    content: attr(placeholder) ": "; } input[type="date"]:focus::before {    content: "" !important; }

Place autofocus in the text box when a page gets loaded without JavaScript support in HTML?

George John
Updated on 04-Jun-2020 08:25:53

170 Views

The autofocus attribute is a boolean attribute. When present, it specifies that an element should automatically get focus when the page loads. An example is given below                    First Name:          Last Name:                    

Animating canvas to infinitely animate the noise to give the appearance of movement in HTML

karthikeya Boyini
Updated on 04-Mar-2020 06:28:48

127 Views

The putImageData() method places the image data onto the canvas. To animate canvas, we create a reusable ImageData object outside the main loop,var ct = c.getContext("2d", {alpha: false});       // context without alpha channel. var a = ct.createImageData(c.width, c.height);   var buffer = new Uint32Array(a.data.buffer);   function loop() {    noise(ct);    requestAnimationFrame(loop) })() function noise(ct) {    var l =buffer.length - 1;    while(l--) buffer[l] = Math.random() >0;    ct.putImageData(a, 0, 0); }

Style options for the HTML5 Date picker

mkotla
Updated on 02-Jun-2020 09:20:33

2K+ Views

The date picker in HTML5 basically works very similar to how the JavaScript Libraries did, when we focus on the field a calendar will pop out, and then we can navigate through the months and years to select the date.Therefore, if you want the date input to use more spacing and a color scheme you could add the following to your code.::-webkit-datetime-edit { padding: 2 em; } ::-webkit-datetime-edit-fields-wrapper { background:green; } ::-webkit-datetime-edit-text { color: blue; padding: 0 0.3em; } ::-webkit-datetime-edit-month-field { color: red; } ::-webkit-datetime-edit-day-field { color: orange; } ::-webkit-datetime-edit-year-field { color: red; }

Change colour of an image drawn on an HTML5 canvas element.

radhakrishna
Updated on 22-Nov-2023 04:29:00

2K+ Views

In order to change colour of image drawn on an HTML5 Canvas element, you can try to run the following code. Use the drawImage() method − Example: Code to change color of image function display(img1, red, gr, bl) { //func to change color of image     var canvas1 = document.createElement('canvas');//canvas element initialisation canvas1.width = img.width;//canvas width initialisation     canvas1.height = img.height; //canvas height initialisation var ctx1 = canvas1.getContext('2d');     ctx1.drawImage(img, 0, 0); var myImg =ctx1.getImageData(0, 0, canvas1.width, canvas1.height); for (var t=0;t< myImg.data.length;t+=4) {            myImg.data[t]= red | myImg.data[t]; ... Read More

Same origin policy on mobile apps with HTML

George John
Updated on 30-Jul-2019 22:30:22

279 Views

There are similar rules for native mobile apps and application. Only domain needs are to be added to white list in PhoneGap or Cardova.The device acts as a server and can access content from URL .If PhoneGap is used then domains are added to whitelist or a wildcard.While dealing with a native application, you expect to make requests from file://, instead of from https://. However, a request is not made across the HTTP protocol, so the same rules do not apply.Making requests from native mobile app, will allow you to make requests to any domain without any major issues. Read More

HTML5 Canvas & z-index issue in Google Chrome

Chandu yadav
Updated on 04-Mar-2020 06:23:16

809 Views

When we apply z index to a canvas whose position is fixed, it stop causes chrome to render all other elements which have position:fixed properly. This only happens if canvas is greater than 256X256 px in size.Wrap both h1 and canvas with the fixed div and solves the issue −    Test Title     The following is the CSS −h1{    position: fixed; } body{    height: 1500px; } canvas{    position: fixed; z-index: -10; }

Menu not visible in IE8. How to make it visible with HTML?

Lakshmi Srinivas
Updated on 04-Mar-2020 06:22:09

110 Views

One of the divs, when placed in another style sheet, can make menu invisible in Internet Explorer.If opacity property is used which is not a cross-border solution, it should be like the following to display −opaque {      -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; // first      filter: alpha(opacity=90);  // second }

How do I get an address latitude-longitude using HTML5 Geolocation or Google API?

karthikeya Boyini
Updated on 04-Mar-2020 06:20:17

505 Views

In order to get latitude and longitude using an HTML5 Geolocation or any Google API, we need to add JavaScript for this. The script is as follows −if (navigator.geolocation) {    /*  If current position is obtained then there is success otherwise there is failure.    On failure, separate error message is shown  */        navigator.geolocation.getCurrentPosition(successFunc, errorFunc); }  else {        alert(‘Geolocation is not enabled in your browser. Please use a latest browser to supports it.'); }

Advertisements