Articles on Trending Technologies

Technical articles with clear explanations and examples

How to detect point on canvas after canvas rotation in HTML5

V Jyothi
V Jyothi
Updated on 30-Jan-2020 310 Views

Whenever we work with canvas and want the canvas to be rotated, we need to translate point to draw point as per its rotation.A transform class can be made to detect point on the canvas after canvas rotationvar t = new Transform(); console.log(t.transformPoint(5,6)); //Transform point will be [5,6] t.rotate(1); // Same transformations can be applied that we did to the canvas console.log(t.transformPoint(5,6)); // Transformed point will be [-2.347, 7.449]

Read More

Draw part of an image inside HTML5 canvas

Rishi Rathor
Rishi Rathor
Updated on 30-Jan-2020 557 Views

If you want to draw part of an image inside canvas, the image onload function only fires once when the image first loads into the browser. Let us see the example:$(document).ready(function () {    var cw1 = 200;    var ch1 = 300;    var ctx1 = $("#myCanvas")[0].getContext("3d");    var myImg1 = new Image();    myImg1.src = "http://oi62.tinypic.com/148yf7.jpg";    var Fpst = 60;    var Player1Tank = {       x: cw1 / 2,       w: 85,       h: 85,       Pos: 3,       draw: function () {       ...

Read More

Circle Collision Detection HTML5 Canvas

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jan-2020 624 Views

If we want to check whether circles are colliding with each other or not, one way is by getting the distance between two centers of circles and subtracting the radius of each circle from that distanceWe also check if the distance is greater than 1. If we want to check it for 20 circles, then we need to calculate exact differences in distances. x/y positions of centers vs the radii.bs(x2 - x1) > (r2 + r1) abs(y2 - y1) > (r2 + r1)The circles cannot collide if the distance in X or Y between circle centers is greater than the ...

Read More

Required arguments in Python

Mohd Mohtashim
Mohd Mohtashim
Updated on 30-Jan-2020 9K+ Views

Required arguments are the arguments passed to a function in correct positional order. Here, the number of arguments in the function call should match exactly with the function definition.To call the function printme(), you definitely need to pass one argument, otherwise it gives a syntax error as follows −Example Live Demo#!/usr/bin/python # Function definition is here def printme( str ): "This prints a passed string into this function" print str return; # Now you can call printme function printme()OutputWhen the above code is executed, it produces the following result −Traceback (most recent call last): File "test.py", line 11, in printme(); TypeError: ...

Read More

HTML5 SVG css3 transition on fill not working when there is external link

Nancy Den
Nancy Den
Updated on 30-Jan-2020 167 Views

This cannot be done through the visited state. The best solution is to add a random query to url so that page go unvisited.

Read More

Effects and animations with Google Maps markers in HTML5

Samual Sam
Samual Sam
Updated on 30-Jan-2020 291 Views

There is no way to fade markers through API.However, markers can be simulated by creating Custom Overlay.Custom overlay usually contains a div with the help of which opacity can be controlled by javascript or jquery.In order to create effects or animations over Google Maps markers, we need a custom overlay.The marker can be added to map and it surely makes optimized: false optionvar newmarkerimg= $('#map_canvas img[src*="iconmarker "][class!="imageadjust "]');

Read More

Open a file browser with default directory in JavaScript and HTML?

V Jyothi
V Jyothi
Updated on 30-Jan-2020 1K+ Views

If you want to open a file browser in JavaScript and then want to set a default directory same as the file folder, then we cannot do it since windows do not allow you to do so,so it is not possible. For example:C: :\AmitThis is mainly due to security risk involved to let web code to set any value on the machine.We can never be assured that even directory exists or not.

Read More

What MySQL returns on passing an invalid string as an argument to STR_TO_DATE() function?

Giri Raju
Giri Raju
Updated on 30-Jan-2020 316 Views

If we pass an invalid string as an argument to STR_TO_DATE() function then MySQL will return NULL as output along with a warning. Following is an example to understand the same −mysql> Select STR_TO_DATE('20173210', '%Y%d%m'); +-----------------------------------+ | STR_TO_DATE('20173210', '%Y%d%m') | +-----------------------------------+ | NULL                              | +-----------------------------------+ 1 row in set, 1 warning (0.00 sec)In the query above the string value is invalid because of wrong (32) day value. Hence it returns NULL values and a warning which is given below.mysql> Show warnings\G *************************** 1. row ***************************   ...

Read More

How can we update values in a MySQL table?

Rama Giri
Rama Giri
Updated on 30-Jan-2020 607 Views

With the help of UPDATE statement and WHERE clause, we can update the values in single or multiple rows of the table. MySQL updates the values on the basis of condition specified in WHERE clause. For example, suppose in the ‘employee’ table we want to change the ‘name’ and ‘doj’ of the employee whose id is 1 then it can be done with the following query −mysql> UPDATE employee SET name = 'Gaurav', doj = '2010-02-01' WHERE id = 1; Query OK, 1 row affected (0.06 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from employee ...

Read More

How to use MySQL FROM_UNIXTIME() function to return datetime value in numeric format?

Sreemaha
Sreemaha
Updated on 30-Jan-2020 298 Views

As we know that we can convert a time of datetime value to an integer by adding 0(+0) to them. In a similar way, we can convert the datetime value returned by FROM_UNIXTIME() function in numeric format. The following example will clarify it more −mysql> Select FROM_UNIXTIME(1555033470)+0 AS 'Date in Numeric Format'; +------------------------+ | Date in Numeric Format | +------------------------+ | 20190412071430.000000  | +------------------------+ 1 row in set (0.00 sec)After adding 0 (+0) to datetime value MySQL returns the numeric value up to 6 digits microseconds.

Read More
Showing 50241–50250 of 61,248 articles
Advertisements