Canvas Style Display Block Not Working in HTML5

karthikeya Boyini
Updated on 29-Jan-2020 06:40:33

290 Views

Change the setTimeout() to use a function reference. It works as the function available at the time the reference.The reference will be transferred to the timeout event callback rather than a string reference:window.setTimeout(startNow, 2000);Set it like the following:setTimeout(startNow, 1000); function startNow () {    alert(‘Working correctly!'); }

Use WHERE Condition in CTAS for Table Creation

Monica Mona
Updated on 29-Jan-2020 06:39:37

248 Views

As we know that we can copy the data and structure from an existing table by CTAS script. Use of WHERE clause is demonstrated in the example belowmysql> Create table EMP_BACKUP2 AS SELECT * from EMPLOYEE WHERE id = 300 AND Name = 'Mohan'; Query OK, 1 row affected (0.14 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> Select * from EMP_BACKUP2; +------+-------+ | Id   | Name  | +------+-------+ | 300  | Mohan | +------+-------+ 1 row in set (0.00 sec)In the example above, we have created a table named EMP_BACKUP1 from table ‘Employee’ with some conditions. MySQL creates the table with only one row based on those conditions.

Draw Lines with easelJS using Ticker in HTML

Samual Sam
Updated on 29-Jan-2020 06:39:08

370 Views

EaseLJS is a JavaScript library to make the HTML5 Canvas element easy. Use it for creating games, graphics, etc.To draw lines using Ticker method in HTML with easeLJS:var myLine = new createjs.Shape(); myLine.graphics.setStrokeStyle(4); myLine.graphics.beginStroke(color); myLine.graphics.moveTo(startX, startY); startY++; myLine.graphics.lineTo(startX, startY); myLine.graphics.endStroke();

Ignore Negative Values in MySQL DATEDIFF Function

radhakrishna
Updated on 29-Jan-2020 06:39:03

1K+ Views

As we know that DATEDIFF() function is used to get the difference in a number of days between two dates. Hence, it is quite possible that it returns negative value as well.mysql> select * from differ; +------------+-------------+ | OrderDate  | WorkingDate | +------------+-------------+ | 2017-10-22 | 2017-10-29  | | 2017-10-25 | 2017-10-30  | | 2017-10-25 | 2017-11-30  | +------------+-------------+ 3 rows in set (0.00 sec)Above query will return the values from table ‘differ’. Now, if someone wants to get the difference between OrderDate and WorkingDate then the output would be negative as follows −mysql> Select DATEDIFF(OrderDate, WorkingDate)AS 'DIFFERENCE IN DAYS' ... Read More

Play Video on Canvas and Preserve Last Frame Image on HTML5 Canvas

Lakshmi Srinivas
Updated on 29-Jan-2020 06:38:07

328 Views

You can try to run the following code to play and preserve the video’s last frame:var c = $('canvas')[0]; var context = canvas.getContext('2d'); c.width = 640; c.height = 480; $("#,myPlayer").on('play', function (e) {    var $this = this;    (function loop() {       if (!$this.paused && !$this.ended) {          context.drawImage($this, 0, 0, 640, 480);          setTimeout(loop, 1000 / 30);       }    })(); });

Calculate Difference in Years, Months, and Days Between Two Dates

vanithasree
Updated on 29-Jan-2020 06:37:59

125 Views

We can create a function, which accepts the date values as its argument and returns the difference in year, month and days, as followsmysql> CREATE FUNCTION date_difference(Date1 DATE, date2 DATE) RETURNS VARCHAR(30)    -> RETURN CONCAT(    -> @years := TIMESTAMPDIFF(YEAR, date1, date2), IF (@years = 1, ' year, ', ' years, '),    -> @months := TIMESTAMPDIFF(MONTH, DATE_ADD(date1, INTERVAL @years YEAR), date2), IF (@months = 1, ' month, ', ' months, '),    -> @days := TIMESTAMPDIFF(DAY, DATE_ADD(date1, INTERVAL @years * 12 + @months MONTH), date2), IF (@days = 1, ' day', ' days')) ;    Query OK, 0 ... Read More

Retrofit Existing Web Page with Mobile CSS

karthikeya Boyini
Updated on 29-Jan-2020 06:37:40

166 Views

To retrofit, use the CSS media queries, and allow different stylesheets to different browser capabilities. A benefit is that you do not have to go for any server-side code.This would require you to add specific detection code to the script for grouping of the device.The media queries handle even devices you've never heard of.Set the following:@media handheld and (max-width: 480px), screen and (max-device-width: 480px), screen and (max-width: 600px) {    body {       color: blue;    } }

Fetch All Records from a MySQL Table

Alankritha Ammu
Updated on 29-Jan-2020 06:37:09

302 Views

We can fetch all the record from a MySQL table by using SELECT * from table_name; query. An example is as follows, fetched all the records from ‘Employee’ table −mysql> Select * from Employee; +------+--------+ | Id   | Name   | +------+--------+ | 100  | Ram    | | 200  | Gaurav | | 300  | Mohan  | +------+--------+ 3 rows in set (0.00 sec)

Frame-by-Frame Animation in HTML5 with Canvas

Nishtha Thakur
Updated on 29-Jan-2020 06:36:50

793 Views

To create a frame by frame animation in HTML5 with canvas, try to run the following code:var myImageNum = 1; var lastImage = 5; var context = canvas.getContext('2d'); var img = new Image; img.onload = function(){    context.clearRect( 0, 0, context.canvas.width, context.canvas.height );    context.drawImage( img, 0, 0 ); }; var timer = setInterval( function(){    if (myImageNum > lastImage){       clearInterval( timer );    }else{       img.src = "images/left_hnd_"+( myImageNum++ )+".png";    } }, 1000/15 );

Different Ways to Add Half-Year Interval in MySQL Date

seetha
Updated on 29-Jan-2020 06:36:20

615 Views

We can add ‘half year interval’ in date ith the following ways −(A) By adding interval of 6 Monthsmysql> Select '2017-06-20' + INTERVAL 6 Month AS 'After Half Year Interval'; +--------------------------+ | After Half Year Interval | +--------------------------+ |  2017-12-20              | +--------------------------+ 1 row in set (0.00 sec)(B) By adding interval of 2 quartersmysql> Select '2017-06-20' + INTERVAL 2 Quarter AS 'After Half Year Interval'; +--------------------------+ | After Half Year Interval | +--------------------------+ | 2017-12-20               | +--------------------------+ 1 row in set (0.00 sec)Above query will add half year interval in date with the help of Quarter keyword.

Advertisements