off­screen CAN­VAS

Web Designer - - Javascript in 2019 -

There are times when a can­vas el­e­ment is the best tool for the job. For ex­am­ple, on­line games can use them to gen­er­ate sprites, or videos can have pro­cess­ing ef­fects ap­plied to them.

The prob­lem is that any in­ter­ac­tions with the el­e­ment will al­ways work on the main thread, which slows things down for the user. For re­peated an­i­ma­tions or heavy pro­cess­ing, this can be­came a prob­lem.

Off­screen­can­vas de­cou­ples the can­vas logic from the el­e­ment. With­out the link to the DOM, it can be used in a worker to free up the main thread.

Cur­rently only Chrome sup­ports this fea­ture, with Fire­fox in­clud­ing it be­hind a flag. •­hjt

Newspapers in English

Newspapers from UK

© PressReader. All rights reserved.