GetContext yog dab tsi?
GetContext yog dab tsi?

Video: GetContext yog dab tsi?

Video: GetContext yog dab tsi?
Video: Canvas2D is getting an update 2024, Kaum ib hlis
Anonim

Cov getContext () txoj kev xa rov qab ib yam khoom uas muab cov txheej txheem thiab cov khoom rau kos duab rau ntawm daim ntaub. Qhov kev siv no yuav npog cov khoom thiab cov txheej txheem ntawm cov getContext ("2d") khoom, uas tuaj yeem siv los kos cov ntawv, kab, thawv, voj voog, thiab lwm yam - ntawm daim ntaub.

Ib yam li ntawd, getContext rov qab li cas?

getContext () txoj kev rov qab los ib daim duab kos duab ntawm daim ntaub, los yog null yog tias tsis txaus siab tus cim ntsiab lus. Tom qab ntawd hu rau txoj kev no ntawm tib lub caij nplooj ntoos hlav rov qab los tib daim duab ntsiab lus piv txwv li yog rov qab los lub sij hawm dhau los tus qauv tau hu nrog tib lub ntsiab lusType kev sib cav.

Tsis tas li ntawd, leej twg ntawm cov txheej txheem hauv qab no ntawm DOM yog siv kom tau txais cov ntsiab lus rendering thiab nws cov duab kos? Cov khoom siv canvas muaj a Txoj kev DOM hu ua getContext, siv los muab cov ntsiab lus rendering thiab nws cov duab kos . Qhov no muaj nuj nqi siv ib qho parameter, hom ntawm ntsiab lus 2d ib.

Tsis tas li ntawd, 2d canvas yog dab tsi?

Lub CanvasRenderingContext2D interface, ib feem ntawm cov Canvas API, muab cov ntaub ntawv 2D rendering cov ntsiab lus rau qhov kos duab nto ntawm ib < daim ntaub > element. Nws yog siv los kos duab, ntawv, duab, thiab lwm yam khoom. Cov Canvas kev qhia muaj ntau yam lus piav qhia, piv txwv, thiab cov peev txheej, thiab.

Dab tsi yog qhov kev siv ntawm canvas tag?

HTML < daim ntaub > keeb yog siv los kos duab, ntawm ya, ntawm JavaScript. Qhov < daim ntaub > keeb tsuas yog lub thawv rau cov duab kos. Koj yuav tsum siv JavaScript los kos cov duab kos. Canvas muaj ntau txoj hauv kev rau kev kos duab, thawv, voj voog, ntawv nyeem, thiab ntxiv cov duab.

Pom zoo: