Found 10483 Articles for Web Development

Load image from url and draw to HTML5 Canvas

Lakshmi Srinivas
Updated on 28-Jan-2020 09:19:27

4K+ Views

You need to create an image object in JavaScript after that set the src.However, you need to wait for the load event before drawing.The following is the canvas:var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); var myImg = new Image(); img.onload = function() {    context.drawImage(myImg, 0, 0); }; img.src = 'https://www.tutorialspoint.com/images/seaborn-4.jpg?v=2';

Improve performance of a HTML5 Canvas with particles bouncing around

Nishtha Thakur
Updated on 28-Jan-2020 09:18:43

161 Views

To enhance the performance of Canvas with particles bouncing around, try the following:Separate the calculations from the drawing.Request a redraw after you have updated your calculations.Optimize collision detection by not testing evert particle against each other.Reduce callback usage.Reduce function calls.Inline.

Difference between div~div and div:not(:first-of-type)?

karthikeya Boyini
Updated on 28-Jan-2020 09:18:12

137 Views

Both are same in terms of matching elements. Let us see an example:                             If you have CSS rules with both selectors matching the same elements, then your div: not(:first-of-type) will get precedence due to the: first-of-type pseudo-class.

What HTML5 tag should be used for filtering search results.

Smita Kapse
Updated on 28-Jan-2020 09:17:26

211 Views

To filter search results, use the element. The header should be in the section of the search results:    Search results                                                                      

Strange cursor placement in modal when using autofocus in Internet Explorer with HTML

Samual Sam
Updated on 28-Jan-2020 08:29:35

133 Views

To solve this problem, use the following:.modal.fade {    transition:opacity .3s linear; }You can also solve it by forcing the modal to fade in without sliding.windowClass: 'modal fade in'

HTML5

Lakshmi Srinivas
Updated on 28-Jan-2020 08:31:19

636 Views

Use Mediaplayer of Android for playing audio. You need to call function of Android from JavaScript that you have written in HTML file.WebView wv = (WebView) findViewById(R.id.webview); wv.addJavascriptInterface(new WebAppInterface(this), "Android"); public class WebAppInterface {    Context mContext;    WebAppInterface(Context c) {       mContext = c;    }    @JavascriptInterface    public void showToast(String toast) {       Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();    } }The following is my JavaScript:    function showAndroidToast(toast) {       Android.showToast(toast);    }

How to set focus on a text input in a list with AngularJS and HTML5

karthikeya Boyini
Updated on 28-Jan-2020 08:30:41

490 Views

To set focus on a text input in a list, try the following code:newApp.directive('focus', function () {    return function (scope, element, attrs) {       attrs.$observe('focus', function (newValue) {          newValue === 'true' && element[0].focus();       });    } });The following is the HTML:{{cue.isNewest}}

Drop Shadow with HTML5 Canvas

Yaswanth Varma
Updated on 11-Oct-2023 18:02:38

1K+ Views

In HTML5 canvas, you can add shadows to shapes, lines, texts, and images to give them the appearance of depth. You can use the following canvas context attributes to add shadows when using the HTML5 canvas. shadowOffsetX() shadowOffsetY() shadowColor() shadowBlur() shadowOffsetX() The property can be used to get or set a shadow's horizontal distance of a shadow from a page. To change the location of a shadow, you can use positive or negative numbers. Zero is the default value. Syntax Following is the syntax for shadowOffsetX() ctx.shadowOffsetX = h_distance; where h_distance belongs to the horizontal distance ... Read More

Draw Bezier Curve with HTML5 Canvas

Yaswanth Varma
Updated on 11-Oct-2023 17:48:18

914 Views

The bezierCurveTo() feature of HTML5 Canvas can be used to generate a Bezier curve. The context point, two control points, and an ending point are used to define Bezier curves. Bezier curves, in contrast to quadratic curves, are specified using two control points rather than one, allowing us to produce more intricate curves. The lineWidth, strokeStyle, and lineCap attributes can be used to customise the look of bezier curves. What are Bezier curves Bezier curves may have appeared in desktop publishing and graphics programs. Beziers offer a great deal more form control. Because the beginning of the curve follows its ... Read More

What is getContext in HTML5 Canvas?

Lakshmi Srinivas
Updated on 28-Jan-2020 08:30:13

1K+ Views

The canvas element has a DOM method called getContext, used to obtain the rendering context and its drawing functions. This function takes one parameter, the type of context 2d.Following is the code to get required context along with a check if your browser supports element:var canvas = document.getElementById("mycanvas"); if (canvas.getContext){    var ctx = canvas.getContext('2d');    // drawing code here    } else {    // canvas-unsupported code here }

Advertisements