repo_id
stringlengths 22
103
| file_path
stringlengths 41
147
| content
stringlengths 181
193k
| __index_level_0__
int64 0
0
|
---|---|---|---|
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/abstractrange/dom-fragment.svg | <svg xmlns="http://www.w3.org/2000/svg" width="463" height="319"><path d="M4 117.5h140v80H4zm-.5 0" fill="#E6E6FF"/><path d="M4.5 118h140v80H4.5zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(73.5 143.5)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(231.5 170.5)"><tspan x="-43.255" y="0" font-family="Helvetica" font-size="12">thing..."</tspan></text><text transform="translate(74 165)"><tspan x="-38.829" y="-3.5" font-family="Helvetica" font-size="12">"An in</tspan> <tspan x="-7.203" y="-3.5" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-3.872" y="-3.5" font-family="Helvetica" font-size="12">e</tspan> <tspan x="2.804" y="-3.5" font-family="Helvetica" font-size="12">r</tspan> <tspan x="6.8" y="-3.5" font-family="Helvetica" font-size="12">e</tspan> <tspan x="13.477" y="-3.5" font-family="Helvetica" font-size="12">s</tspan> <tspan x="19.477" y="-3.5" font-family="Helvetica" font-size="12">t</tspan> <tspan x="22.808" y="-3.5" font-family="Helvetica" font-size="12">ing</tspan> <tspan x="38.829" y="-3.5" font-family="Helvetica" font-size="12"> </tspan> <tspan x="-20.142" y="11.5" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-16.81" y="11.5" font-family="Helvetica" font-size="12">hing</tspan> <tspan x="5.887" y="11.5" font-family="Helvetica" font-size="12">...</tspan> <tspan x="15.882" y="11.5" font-family="Helvetica" font-size="12">"</tspan></text><path d="M4 1.5h140v80H4zm-.5 0" fill="#E6FFE6"/><path d="M4.5 2h140v80H4.5zM4 2" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(73.504 34.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(73.502 48.5)"><tspan x="-13.684" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-6.676" y="4" font-family="Helvetica" font-size="12">h2</tspan> <tspan x="6.676" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M162 117.5h140v80H162zm-.5 0" fill="#E6E6FF"/><path d="M162.5 118h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(231.5 150.5)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(226.099 164.5)"><tspan x="-9.599" y="4" font-family="Helvetica" font-size="12">"</tspan> <tspan x="-5.34" y="4" font-family="Helvetica" font-size="12">A</tspan> <tspan x="1.68" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="5.34" y="4" font-family="Helvetica" font-size="12">"</tspan></text><path d="M320 233.5h140v80H320zm-.5 0" fill="#E6E6FF"/><path d="M320.5 234h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(389.5 266.5)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(389.501 280.5)"><tspan x="-10.598" y="4" font-family="Helvetica" font-size="12">"v</tspan> <tspan x="-.338" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="6.338" y="4" font-family="Helvetica" font-size="12">"</tspan></text><path d="M320 117.5h140v80H320zm-.5 0" fill="#E6FFE6"/><path d="M320.5 118h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(389.504 150.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(389.501 164.5)"><tspan x="-15.344" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-8.336" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-1.66" y="4" font-family="Helvetica" font-size="12">m</tspan> <tspan x="8.336" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M320 1.5h140v80H320zm-.5 0" fill="#E6FFE6"/><path d="M320.5 2h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(389.504 34.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(389.501 48.5)"><tspan x="-10.346" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-3.338" y="4" font-family="Helvetica" font-size="12">p</tspan> <tspan x="3.338" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M390.5 82v36m0 80v36M335.517 82l-49.034 36M74.5 82v36" stroke="#000" stroke-linecap="round" fill="none"/></svg> | 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/abstractrange/simpledom.svg | <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1080" height="1152"><defs><clipPath id="a"><path d="M120-768h294v-174H120z"/></clipPath><clipPath id="b"><path d="M436-1000h294v-174H436z"/></clipPath><clipPath id="c"><path d="M436-768h294v-174H436z"/></clipPath><clipPath id="d"><path d="M120-1651h294v-174H120z"/></clipPath><clipPath id="e"><path d="M120-1419h294v-174H120z"/></clipPath><clipPath id="f"><path d="M436-1651h294v-174H436z"/></clipPath><clipPath id="g"><path d="M752-1883h294v-174H752z"/></clipPath><clipPath id="h"><path d="M752-1651h294v-174H752z"/></clipPath><clipPath id="i"><path d="M1068-1651h294v-174h-294z"/></clipPath><clipPath id="j"><path d="M752-1419h294v-174H752z"/></clipPath><clipPath id="k"><path d="M1384-1883h294v-174h-294z"/></clipPath><clipPath id="l"><path d="M1384-1651h294v-174h-294z"/></clipPath><clipPath id="m"><path d="M1700-1883h294v-174h-294z"/></clipPath><clipPath id="n"><path d="M1700-1651h294v-174h-294z"/></clipPath><clipPath id="o"><path d="M1384-1419h294v-174h-294z"/></clipPath><clipPath id="p"><path d="M752-1000h294v-174H752z"/></clipPath><clipPath id="q"><path d="M752-768h294v-174H752z"/></clipPath><clipPath id="r"><path d="M1068-768h294v-174h-294z"/></clipPath><clipPath id="s"><path d="M594-536h294v-174H594z"/></clipPath><clipPath id="t"><path d="M594-304h294v-174H594z"/></clipPath><clipPath id="u"><path d="M594-72h294v-174H594z"/></clipPath></defs><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDA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h3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="120" y="-942" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#a)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUbn6sd0/5TLjuk7JQSTn+cz3PNz7mF4CBA4LDA/IzLbmlCKbun7Jz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zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="436" y="-1174" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#b)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUbn6sd0/5TLjuk7JQSTn+cz3PNz7mF4CBA4LDA/IzLbmlCKbun7Jzy/ipb5oZ1/fQTbcIpu6P5STcB9dv54dzrIECAwFGB7JgmcxJK2TnNL7Fkz+XPRHPTXMhWan7S5bMJqISSYFoIDgIE7hZIMOVIKCVbkjHZKU3urNPv4TTBdLlwvilBNQGVB2ft9+cZBwECBI4ITJZMIE3W5Dtmg3QKn/1LLx9sN+3X9nudEyBA4B6ByZR5zXfs50+C6Z7/iGcIECDwvwrk55qDAAECVQKCqaodiiFAIAKCyRwQIFAnIJjqWqIgAgQEkxkgQKBOQDDVtURBBAgIJjNA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1bVEQQQICCYzQIBAnYBgqmuJgggQEExmgACBOgHBVNcSBREgIJjMAAECdQKCqa4lCiJAQDCZAQIE6gQEU11LFESAgGAyAwQI1AkIprqWKIgAAcFkBggQqBMQTHUtURABAoLJDBAgUCcgmOpaoiACBASTGSBAoE5AMNW1REEECAgmM0CAQJ2AYKpriYIIEBBMZoAAgToBwVTXEgURICCYzAABAnUCgqmuJQoiQEAwmQECBOoEBFNdSxREgIBgMgMECNQJCKa6liiIAAHBZAYIEKgTEEx1LVEQAQKCyQwQIFAnIJjqWqIgAgRug+lxI5nzed0+ckqAAIG7BSZT5jVftJ8/vN6+ej74dr4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="436" y="-942" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#c)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAK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QIFAnIJjqWqIgAgRug+lxI5nzed0+ckqAAIG7BSZT5jVftJ8/vN6+ej74dr4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="120" y="-1825" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#d)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U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EQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="120" y="-1593" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#e)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUbn6sd0/5TLjuk7JQSTn+cz3PNz7mF4CBA4LDA/IzLbmlCKbun7Jzy/ipb5oZ1/fQTbcIpu6P5STcB9dv54dzrIECAwFGB7JgmcxJK2TnNL7Fkz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GtIHZbED5wAAAABJRU5ErkJggg==" x="436" y="-1825" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#f)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUbn6sd0/5TLjuk7JQSTn+cz3PNz7mF4CBA4LDA/IzLbmlCKbun7Jzy/ipb5oZ1/fQTbcIpu6P5STcB9dv54dzrIECAwFGB7JgmcxJK2TnNL7Fkz+XPRHPTXMhWan7S5bMJqISSYFoIDgIE7hZIMOVIKCVbkjHZKU3urNPv4TTBdLlwvilBNQGVB2ft9+cZBwECBI4ITJZMIE3W5Dtmg3QKn/1LLx9sN+3X9nudEyBA4B6ByZR5zXfs50+C6Z7/iGcIECDwvwrk55qDAAECVQKCqaodiiFAIAKCyRwQIFAnIJjqWqIgAgQEkxkgQKBOQDDVtURBBAgIJjNAgECdgGCqa4mCCBAQTGaAAIE6AcFU1xIFESAgmMwAAQJ1AoKpriUKIkBAMJk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lCiJAQDCZAQIE6gQEU11LFESAgGAyAwQI1AkIprqWKIgAAcFkBggQqBMQTHUtURABAoLJDBAgUCcgmOpaoiACBASTGSBAoE5AMNW1REEECAgmM0CAQJ2AYKpriYIIEBBMZoAAgToBwVTXEgURICCYzAABAnUCgqmuJQoiQEAwmQECBOoEBFNdSxREgIBgMgMECNQJCKa6liiIAAHBZAYIEKgTEEx1LVEQAQKCyQwQIFAnIJjqWqIgAgRug+lxI5nzed0+ckqAAIG7BSZT5jVftJ8/vN6+ej74dr4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="752" y="-2057" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#g)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhA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4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="752" y="-1825" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#h)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJc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gMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="1068" y="-1825" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#i)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUbn6sd0/5TLjuk7JQSTn+cz3PNz7mF4CBA4LDA/IzLbmlCKbun7Jzy/ipb5oZ1/fQTbcIpu6P5STcB9dv54dzrIECAwFGB7JgmcxJK2TnNL7Fkz+XPRHPTXMhWan7S5bMJqISSYFoIDgIE7hZIMOVIKCVbkjHZKU3urNPv4TT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EkxkgQKBOQDDVtURBBAgIJjNAgECdgGCqa4mCCBAQTGaAAIE6AcFU1xIFESAgmMwAAQJ1AoKpriUKIkBAMJkBAgTqBARTXUsURICAYDIDBAjUCQimupYoiAABwWQGCBCoExBMdS1REAECgskMECBQJyCY6lqiIAIEBJMZIECgTkAw1bVEQQQICCYzQIBAnYBgqmuJgggQEExmgACBOgHBVNcSBREgIJjMAAECdQKCqa4lCiJAQDCZAQIE6gQEU11LFESAgGAyAwQI1AkIprqWKIgAAcFkBggQqBMQTHUtURABAoLJDBAgUCcgmOpaoiACBASTGSBAoE5AMNW1REEECAgmM0CAQJ2AYKpriYIIEBBMZoAAgToBwVTXEgURICCYzAABAnUCgqmuJQoiQEAwmQECBOoEBFNdSxREgIBgMgMECNQJCKa6liiIAAHBZAYIEKgTEEx1LVEQAQKCyQwQIFAnIJjqWqIgAgRug+lxI5nzed0+ckqAAIG7BSZT5jVftJ8/vN6+ej74dr4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="752" y="-1593" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#j)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUbn6sd0/5TLjuk7JQSTn+cz3PNz7mF4CBA4LDA/IzLbmlCKbun7Jzy/ipb5oZ1/fQTbcIpu6P5STcB9dv54dzrIECAwFGB7JgmcxJK2TnNL7Fkz+XPRHPTXMhWan7S5bMJqISSYFoIDgIE7hZIMOVIKCVbkjHZKU3urNPv4TTBdLlwvilBNQGVB2ft9+cZBwECBI4ITJZMIE3W5Dtmg3QKn/1LLx9sN+3X9nudEyBA4B6ByZR5zXfs50+C6Z7/iGcIECDwvwrk55qDAAECVQKCqaodiiFAIAKCyRwQIFAnIJjqWqIgAgQEkxkgQKBOQDDVtURBBAgIJjNAgECdgGCqa4mCCBAQTGaAAIE6AcFU1xIFESAgmMwAAQJ1AoKpriUKIkBAMJkBAgTqBARTXUsURICAYDIDBAjUCQimupYoiAABwWQGCBCoExBMdS1REAECgskMECBQJ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UtURABAoLJDBAgUCcgmOpaoiACBASTGSBAoE5AMNW1REEECAgmM0CAQJ2AYKpriYIIEBBMZoAAgToBwVTXEgURICCYzAABAnUCgqmuJQoiQEAwmQECBOoEBFNdSxREgIBgMgMECNQJCKa6liiIAAHBZAYIEKgTEEx1LVEQAQKCyQwQIFAnIJjqWqIgAgRug+lxI5nzed0+ckqAAIG7BSZT5jVftJ8/vN6+ej74dr4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="1384" y="-2057" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#k)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIE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IE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="1384" y="-1825" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#l)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZj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OHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="1700" y="-2057" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#m)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUbn6sd0/5TLjuk7JQSTn+cz3PNz7mF4CBA4LDA/IzLbmlCKbun7Jzy/ipb5oZ1/fQTbcIpu6P5STcB9dv54dzrIECAwFGB7JgmcxJK2TnNL7Fkz+XPRHPTXMhWan7S5bMJqISSYFoIDgIE7hZIMOVIKCVbkjHZKU3urNPv4TTBdLlwvilBNQGVB2ft9+cZBwECBI4ITJZMIE3W5Dtmg3QKn/1LLx9sN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IFESAgmMwAAQJ1AoKpriUKIkBAMJkBAgTqBARTXUsURICAYDIDBAjUCQimupYoiAABwWQGCBCoExBMdS1REAECgskMECBQJyCY6lqiIAIEBJMZIECgTkAw1bVEQQQICCYzQIBAnYBgqmuJgggQEExmgACBOgHBVNcSBREgIJjMAAECdQKCqa4lCiJAQDCZAQIE6gQEU11LFESAgGAyAwQI1AkIprqWKIgAAcFkBggQqBMQTHUtURABAoLJDBAgUCcgmOpaoiACBASTGSBAoE5AMNW1REEECAgmM0CAQJ2AYKpriYIIEBBMZoAAgToBwVTXEgURICCYzAABAnUCgqmuJQoiQEAwmQECBOoEBFNdSxREgIBgMgMECNQJCKa6liiIAAHBZAYIEKgTEEx1LVEQAQKCyQwQIFAnIJjqWqIgAgRug+lxI5nzed0+ckqAAIG7BSZT5jVftJ8/vN6+ej74dr4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="1700" y="-1825" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#n)"/><image xlink:href="data:image/png;base64,iVBORw0KGg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AYKpriYIIEBBMZoAAgToBwVTXEgURICCYzAABAnUCgqmuJQoiQEAwmQECBOoEBFNdSxREgIBgMgMECNQJCKa6liiIAAHBZAYIEKgTEEx1LVEQAQKCyQwQIFAnIJjqWqIgAgRug+lxI5nzed0+ckqAAIG7BSZT5jVftJ8/vN6+ej74dr4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="1384" y="-1593" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#o)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+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QcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="752" y="-1174" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#p)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUb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BE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="752" y="-942" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#q)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUbn6sd0/5TLjuk7JQSTn+cz3PNz7mF4CBA4LDA/IzLbmlCKbun7Jzy/ipb5oZ1/fQTbcIpu6P5STcB9dv54dzrIECAwFGB7JgmcxJK2TnNL7Fkz+XPRHPTXMhWan7S5bMJqISSYFoIDgIE7hZIMOVIKCVbkjHZKU3urNPv4TTBdLlwvilBNQGVB2ft9+cZBwECBI4ITJZMIE3W5Dtmg3QKn/1LLx9sN+3X9nudEyBA4B6ByZR5zXfs50+C6Z7/iGcIECDwvwrk55qDAAECVQKCqaodi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oiAABwWQGCBCoExBMdS1REAECgskMECBQJyCY6lqiIAIEBJMZIECgTkAw1bVEQQQICCYzQIBAnYBgqmuJgggQEExmgACBOgHBVNcSBREgIJjMAAECdQKCqa4lCiJAQDCZAQIE6gQEU11LFESAgGAyAwQI1AkIprqWKIgAAcFkBggQqBMQTHUtURABAoLJDBAgUCcgmOpaoiACBASTGSBAoE5AMNW1REEECAgmM0CAQJ2AYKpriYIIEBBMZoAAgToBwVTXEgURICCYzAABAnUCgqmuJQoiQEAwmQECBOoEBFNdSxREgIBgMgMECNQJCKa6liiIAAHBZAYIEKgTEEx1LVEQAQKCyQwQIFAnIJjqWqIgAgRug+lxI5nzed0+ckqAAIG7BSZT5jVftJ8/vN6+ej74dr4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="1068" y="-942" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#r)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmT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FNdSxREgIBgMgMECNQJCKa6liiIAAHBZAYIEKgTEEx1LVEQAQKCyQwQIFAnIJjqWqIgAgRug+lxI5nzed0+ckqAAIG7BSZT5jVftJ8/vN6+ej74dr4pr19v1na7UwIECBwSuM2TPWvyRZNBl2CaC7lxAunLOv+81qe1JsBerXMHAQIE7hFIMP29VjIl2ZKMybXJnXX6PZwmcOZCAio3TiB9XOdzT74kwfRiLQcBAgSOCEy2JJQ+rJVsmYBK5uTz2SBdQmddO13MDQmgeXgPpTfruh3TQnAQIHCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="594" y="-710" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#s)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJG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HCXwGx6Ekp/rZWAStbMzulJMOXC/ITLbikPJohy5KHZOeWP5XZMUXEQIHBEYDJm3/gknJItyZyEVjLoFE6zI1rvL8GUBJv/W5cHkmqzWxJKC8NBgMBdAgmd2TUlZxJKWTmfYFqn//79KA/MQwmf3Jz0SjAlvPITLmE1gbVOHQQIEDgkMH/kTghl55R8uf0p92THlAt5MA/MeR6cP3hPKNk1LRQHAQKHBE6Bs56Yn2sJp33N9dOX3oZM3s+aHdK8zwO395++xD8ECBD4CYEJp7zO5mcCaa6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="594" y="-478" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#t)"/><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAACuCAYAAACbUKDbAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABJqADAAQAAAABAAAArgAAAADqNm3pAAAICElEQVR4Ae3Z247bRhAE0PU1jpH8/5/Gjm+bKVmtjLTY2BQCox4OgbEoilQapxuF0ebhwUGAAIEygRfP1DPX5zW37efPPOYyAQIE/lPgcft0zuf18tFt2OT9rJfrPGve56Hb+3PNQYAAgZ8RmADKa9a385r38/lV0CR0JoxerfN9zWfr8tUzee8gQIDAjwQmdBJGOf96s/aQeni9fduET65lvV3rzfk8ITWhtU4dBAgQOCww4ZNQ+rLW57U+rZXsyfvZOV2CKR9kJYASSu+2NQGVz3KPgwABAvcIzE5pAunj+pJsePKazxJcyZjHfceUGxI+CaIE059rvV/r97VyLffmHuG0EBwECBwSmODJzii7pA9r5RdZjn0nlfOrHdMEU25OMCWUJpzyPtcTXA4CBAjcI5CfcNktZYc0m6K8nzUbn6sd0/5TLjuk7JQSTn+cz3PNz7mF4CBA4LDA/IzLbmlCKbun7Jzy/ipb5oZ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6dvua5oJnr85qb9/PTw/4hQIDAQYEJpzw25/N68KvcToAAgV8o8A+mGtIHZbED5wAAAABJRU5ErkJggg==" x="594" y="-246" width="294" height="174" preserveAspectRatio="none" transform="scale(.5 -.5)" clip-path="url(#u)"/><path d="M64 386h140v80H64zm-.5-.5" fill="#E6FFE6"/><path d="M64.5 386.5h140v80h-140zm-.5-.5" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(133.504 418.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(133.502 432.5)"><tspan x="-16.678" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-9.67" y="4" font-family="Helvetica" font-size="12">i</tspan> <tspan x="-7.002" y="4" font-family="Helvetica" font-size="12">m</tspan> <tspan x="2.994" y="4" font-family="Helvetica" font-size="12">g</tspan> <tspan x="9.67" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M222 502h140v80H222zm-.5-.5" fill="#E6E6FF"/><path d="M222.5 502.5h140v80h-140zm-.5-.5" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(291.5 534.5)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(291.505 548.5)"><tspan x="-61.511" y="4" font-family="Helvetica" font-size="12">"</tspan> <tspan x="-57.251" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-49.924" y="4" font-family="Helvetica" font-size="12">he</tspan> <tspan x="-36.571" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="-33.24" y="4" font-family="Helvetica" font-size="12">Ul</tspan> <tspan x="-21.903" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-18.571" y="4" font-family="Helvetica" font-size="12">i</tspan> <tspan x="-15.903" y="4" font-family="Helvetica" font-size="12">m</tspan> <tspan x="-5.907" y="4" font-family="Helvetica" font-size="12">a</tspan> <tspan x=".77" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="4.101" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="10.777" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="14.109" y="4" font-family="Helvetica" font-size="12">W</tspan> <tspan x="25.117" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="31.899" y="4" font-family="Helvetica" font-size="12">b</tspan> <tspan x="38.575" y="4" font-family="Helvetica" font-size="12">s</tspan> <tspan x="44.575" y="4" font-family="Helvetica" font-size="12">i</tspan> <tspan x="47.244" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="50.575" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="57.251" y="4" font-family="Helvetica" font-size="12">"</tspan></text><path d="M222 386h140v80H222zm-.5-.5" fill="#E6FFE6"/><path d="M222.5 386.5h140v80h-140zm-.5-.5" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(291.504 418.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(291.502 432.5)"><tspan x="-13.684" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-6.676" y="4" font-family="Helvetica" font-size="12">h1</tspan> <tspan x="6.676" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M64 827h140v80H64zm-.5 0" fill="#E6E6FF"/><path d="M64.5 827.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(133.5 853)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(133.338 867)"><tspan x="-37.329" y="4" font-family="Helvetica" font-size="12">"S</tspan> <tspan x="-25.066" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-18.39" y="4" font-family="Helvetica" font-size="12">c</tspan> <tspan x="-12.39" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-9.058" y="4" font-family="Helvetica" font-size="12">ion</tspan> <tspan x="6.963" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="10.294" y="4" font-family="Helvetica" font-size="12">1</tspan> <tspan x="16.971" y="4" font-family="Helvetica" font-size="12">:</tspan> <tspan x="20.302" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="22.649" y="4" font-family="Helvetica" font-size="12">A</tspan> <tspan x="30.653" y="4" font-family="Helvetica" font-size="12">n</tspan></text><text transform="translate(133.505 881)"><tspan x="-49.496" y="4" font-family="Helvetica" font-size="12">in</tspan> <tspan x="-40.151" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-36.82" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-30.144" y="4" font-family="Helvetica" font-size="12">r</tspan> <tspan x="-26.147" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-19.471" y="4" font-family="Helvetica" font-size="12">s</tspan> <tspan x="-13.471" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-10.14" y="4" font-family="Helvetica" font-size="12">ing</tspan> <tspan x="5.881" y="4" font-family="Helvetica" font-size="12"> t</tspan> <tspan x="12.544" y="4" font-family="Helvetica" font-size="12">hing</tspan> <tspan x="35.241" y="4" font-family="Helvetica" font-size="12">...</tspan> <tspan x="45.236" y="4" font-family="Helvetica" font-size="12">"</tspan></text><path d="M64 711h140v80H64zm-.5 0" fill="#E6FFE6"/><path d="M64.5 711.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(133.504 744)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(133.502 758)"><tspan x="-13.684" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-6.676" y="4" font-family="Helvetica" font-size="12">h2</tspan> <tspan x="6.676" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M222 827h140v80H222zm-.5 0" fill="#E6E6FF"/><path d="M222.5 827.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(291.5 860)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(291.499 874)"><tspan x="-9.599" y="4" font-family="Helvetica" font-size="12">"</tspan> <tspan x="-5.34" y="4" font-family="Helvetica" font-size="12">A</tspan> <tspan x="1.68" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="5.34" y="4" font-family="Helvetica" font-size="12">"</tspan></text><path d="M380 943h140v80H380zm-.5 0" fill="#E6E6FF"/><path d="M380.5 943.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(449.5 976)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(449.501 990)"><tspan x="-15.596" y="4" font-family="Helvetica" font-size="12">"v</tspan> <tspan x="-5.336" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="1.34" y="4" font-family="Helvetica" font-size="12">ry</tspan> <tspan x="11.336" y="4" font-family="Helvetica" font-size="12">"</tspan></text><path d="M380 827h140v80H380zm-.5 0" fill="#E6FFE6"/><path d="M380.5 827.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(449.504 860)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(449.501 874)"><tspan x="-15.344" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-8.336" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-1.66" y="4" font-family="Helvetica" font-size="12">m</tspan> <tspan x="8.336" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M538 827h140v80H538zm-.5 0" fill="#E6E6FF"/><path d="M538.5 827.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(607.5 846)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(607.507 860)"><tspan x="-46.164" y="4" font-family="Helvetica" font-size="12">"</tspan> <tspan x="-41.905" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="-38.573" y="4" font-family="Helvetica" font-size="12">in</tspan> <tspan x="-29.228" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-25.897" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-19.221" y="4" font-family="Helvetica" font-size="12">r</tspan> <tspan x="-15.225" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-8.548" y="4" font-family="Helvetica" font-size="12">s</tspan> <tspan x="-2.548" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x=".783" y="4" font-family="Helvetica" font-size="12">ing</tspan> <tspan x="16.804" y="4" font-family="Helvetica" font-size="12"> t</tspan> <tspan x="23.467" y="4" font-family="Helvetica" font-size="12">hing</tspan></text><text transform="translate(607.511 874)"><tspan x="-64.063" y="4" font-family="Helvetica" font-size="12">happened</tspan> <tspan x="-10.653" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="-7.321" y="4" font-family="Helvetica" font-size="12">on</tspan> <tspan x="6.031" y="4" font-family="Helvetica" font-size="12"> t</tspan> <tspan x="12.694" y="4" font-family="Helvetica" font-size="12">he</tspan> <tspan x="26.047" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="29.379" y="4" font-family="Helvetica" font-size="12">wa</tspan> <tspan x="44.723" y="4" font-family="Helvetica" font-size="12">y</tspan> <tspan x="50.723" y="4" font-family="Helvetica" font-size="12"> t</tspan> <tspan x="57.386" y="4" font-family="Helvetica" font-size="12">o</tspan></text><text transform="translate(607.498 888)"><tspan x="-32.473" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-29.142" y="4" font-family="Helvetica" font-size="12">he</tspan> <tspan x="-15.789" y="4" font-family="Helvetica" font-size="12"> f</tspan> <tspan x="-9.126" y="4" font-family="Helvetica" font-size="12">o</tspan> <tspan x="-2.45" y="4" font-family="Helvetica" font-size="12">r</tspan> <tspan x="1.546" y="4" font-family="Helvetica" font-size="12">u</tspan> <tspan x="8.223" y="4" font-family="Helvetica" font-size="12">m</tspan> <tspan x="18.219" y="4" font-family="Helvetica" font-size="12">...</tspan> <tspan x="28.213" y="4" font-family="Helvetica" font-size="12">"</tspan></text><path d="M380 711h140v80H380zm-.5 0" fill="#E6FFE6"/><path d="M380.5 711.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(449.504 744)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(449.501 758)"><tspan x="-10.346" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-3.338" y="4" font-family="Helvetica" font-size="12">p</tspan> <tspan x="3.338" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M696 943h140v80H696zm-.5 0" fill="#E6E6FF"/><path d="M696.5 943.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(765.5 976)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(765.504 990)"><tspan x="-19.272" y="4" font-family="Helvetica" font-size="12">"As</tspan> <tspan x="-1.008" y="4" font-family="Helvetica" font-size="12">ide</tspan> <tspan x="15.012" y="4" font-family="Helvetica" font-size="12">"</tspan></text><path d="M696 827h140v80H696zm-.5 0" fill="#E6FFE6"/><path d="M696.5 827.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(765.504 860)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(765.502 874)"><tspan x="-13.684" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-6.676" y="4" font-family="Helvetica" font-size="12">h2</tspan> <tspan x="6.676" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M854 943h140v80H854zm-.5 0" fill="#E6E6FF"/><path d="M854.5 943.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(923.5 969)"><tspan x="-36.006" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-28.678" y="4" font-family="Helvetica" font-size="12">EX</tspan> <tspan x="-12.67" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="-5.343" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="10.002" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="19.334" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="28.002" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(923.508 983)"><tspan x="-61.508" y="4" font-family="Helvetica" font-size="12">"A</tspan> <tspan x="-49.245" y="4" font-family="Helvetica" font-size="12">n</tspan> <tspan x="-42.569" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="-39.237" y="4" font-family="Helvetica" font-size="12">in</tspan> <tspan x="-29.892" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-26.561" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-19.884" y="4" font-family="Helvetica" font-size="12">r</tspan> <tspan x="-15.888" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-9.212" y="4" font-family="Helvetica" font-size="12">s</tspan> <tspan x="-3.212" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x=".119" y="4" font-family="Helvetica" font-size="12">ing</tspan> <tspan x="16.14" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="19.472" y="4" font-family="Helvetica" font-size="12">a</tspan> <tspan x="26.148" y="4" font-family="Helvetica" font-size="12">s</tspan> <tspan x="32.148" y="4" font-family="Helvetica" font-size="12">ide</tspan> <tspan x="48.169" y="4" font-family="Helvetica" font-size="12"> t</tspan> <tspan x="54.832" y="4" font-family="Helvetica" font-size="12">o</tspan></text><text transform="translate(923.502 997)"><tspan x="-45.82" y="4" font-family="Helvetica" font-size="12">s</tspan> <tspan x="-39.82" y="4" font-family="Helvetica" font-size="12">ha</tspan> <tspan x="-26.467" y="4" font-family="Helvetica" font-size="12">r</tspan> <tspan x="-22.471" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-15.795" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="-12.463" y="4" font-family="Helvetica" font-size="12">wi</tspan> <tspan x="-1.127" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="2.205" y="4" font-family="Helvetica" font-size="12">h</tspan> <tspan x="8.881" y="4" font-family="Helvetica" font-size="12"> </tspan> <tspan x="12.213" y="4" font-family="Helvetica" font-size="12">y</tspan> <tspan x="18.213" y="4" font-family="Helvetica" font-size="12">ou</tspan> <tspan x="31.565" y="4" font-family="Helvetica" font-size="12">...</tspan> <tspan x="41.56" y="4" font-family="Helvetica" font-size="12">"</tspan></text><path d="M854 827h140v80H854zm-.5 0" fill="#E6FFE6"/><path d="M854.5 827.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(923.504 860)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(923.501 874)"><tspan x="-10.346" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-3.338" y="4" font-family="Helvetica" font-size="12">p</tspan> <tspan x="3.338" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M696 711h140v80H696zm-.5 0" fill="#E6FFE6"/><path d="M696.5 711.5h140v80h-140zm-.5 0" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(765.504 744)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(765.505 758)"><tspan x="-21.356" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-14.349" y="4" font-family="Helvetica" font-size="12">a</tspan> <tspan x="-7.672" y="4" font-family="Helvetica" font-size="12">s</tspan> <tspan x="-1.672" y="4" font-family="Helvetica" font-size="12">ide</tspan> <tspan x="14.349" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M380 502h140v80H380zm-.5-.5" fill="#E6FFE6"/><path d="M380.5 502.5h140v80h-140zm-.5-.5" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(449.504 534.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(449.504 548.5)"><tspan x="-26.022" y="4" font-family="Helvetica" font-size="12"><s</tspan> <tspan x="-13.014" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="-6.338" y="4" font-family="Helvetica" font-size="12">c</tspan> <tspan x="-.338" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="2.993" y="4" font-family="Helvetica" font-size="12">ion</tspan> <tspan x="19.014" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M380 386h140v80H380zm-.5-.5" fill="#E6FFE6"/><path d="M380.5 386.5h140v80h-140zm-.5-.5" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(449.504 418.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(449.504 432.5)"><tspan x="-23.016" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-16.008" y="4" font-family="Helvetica" font-size="12">a</tspan> <tspan x="-9.332" y="4" font-family="Helvetica" font-size="12">r</tspan> <tspan x="-5.336" y="4" font-family="Helvetica" font-size="12">t</tspan> <tspan x="-2.005" y="4" font-family="Helvetica" font-size="12">i</tspan> <tspan x=".664" y="4" font-family="Helvetica" font-size="12">c</tspan> <tspan x="6.664" y="4" font-family="Helvetica" font-size="12">le</tspan> <tspan x="16.008" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M538 386h140v80H538zm-.5-.5" fill="#E6FFE6"/><path d="M538.5 386.5h140v80h-140zm-.5-.5" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(607.504 418.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(607.502 432.5)"><tspan x="-15.682" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-8.674" y="4" font-family="Helvetica" font-size="12">p</tspan> <tspan x="-1.998" y="4" font-family="Helvetica" font-size="12">r</tspan> <tspan x="1.998" y="4" font-family="Helvetica" font-size="12">e</tspan> <tspan x="8.674" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M301 270h140v80H301zm-.5-.5" fill="#E6FFE6"/><path d="M301.5 270.5h140v80h-140zm-.5-.5" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(370.504 302.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(370.502 316.5)"><tspan x="-14.68" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-7.672" y="4" font-family="Helvetica" font-size="12">di</tspan> <tspan x="1.672" y="4" font-family="Helvetica" font-size="12">v</tspan> <tspan x="7.672" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M301 154h140v80H301zm-.5-.5" fill="#E6FFE6"/><path d="M301.5 154.5h140v80h-140zm-.5-.5" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(370.504 186.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(370.502 200.5)"><tspan x="-14.68" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-7.672" y="4" font-family="Helvetica" font-size="12">di</tspan> <tspan x="1.672" y="4" font-family="Helvetica" font-size="12">v</tspan> <tspan x="7.672" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M301 38h140v80H301zm-.5-.5" fill="#E6FFE6"/><path d="M301.5 38.5h140v80h-140zm-.5-.5" stroke="#000" stroke-linecap="round" stroke-linejoin="round" fill="none"/><text transform="translate(370.504 70.5)"><tspan x="-49.014" y="4" font-family="Helvetica" font-size="12">E</tspan> <tspan x="-41.01" y="4" font-family="Helvetica" font-size="12">L</tspan> <tspan x="-34.334" y="4" font-family="Helvetica" font-size="12">EME</tspan> <tspan x="-8.33" y="4" font-family="Helvetica" font-size="12">N</tspan> <tspan x=".338" y="4" font-family="Helvetica" font-size="12">T</tspan> <tspan x="7.666" y="4" font-family="Helvetica" font-size="12">_N</tspan> <tspan x="23.01" y="4" font-family="Helvetica" font-size="12">O</tspan> <tspan x="32.342" y="4" font-family="Helvetica" font-size="12">D</tspan> <tspan x="41.01" y="4" font-family="Helvetica" font-size="12">E</tspan></text><text transform="translate(370.504 84.5)"><tspan x="-20.022" y="4" font-family="Helvetica" font-size="12"><</tspan> <tspan x="-13.014" y="4" font-family="Helvetica" font-size="12">bod</tspan> <tspan x="7.014" y="4" font-family="Helvetica" font-size="12">y</tspan> <tspan x="13.014" y="4" font-family="Helvetica" font-size="12">></tspan></text><path d="M371.5 118v36m0 80v36m69.5 74.262l97 47.476M398.241 350l24.518 36m27.741 80v36m59.834 80l195.332 129.5m114.817 80l49.034 36m54.983 80v36m-158-152v36m0 80v36M450.5 582v129.5m53.983 80l49.034 36m-103.017-36v36m0 80v36m-54.983-152l-49.034 36M389.666 582L194.334 711.5m-59.834 80v36M343.759 350l-24.518 36M292.5 466v36m8.5-157.738l-97 47.476" stroke="#000" stroke-linecap="round" fill="none"/></svg> | 0 |
data/mdn-content/files/en-us/web/api/abstractrange | data/mdn-content/files/en-us/web/api/abstractrange/startcontainer/index.md | ---
title: "AbstractRange: startContainer property"
short-title: startContainer
slug: Web/API/AbstractRange/startContainer
page-type: web-api-instance-property
browser-compat: api.AbstractRange.startContainer
---
{{APIRef("DOM")}}
The read-only **`startContainer`** property of the {{domxref("AbstractRange")}} interface returns the start {{domxref("Node")}} for the range.
## Value
The {{domxref("Node")}} inside which the start position of the range is found.
## Example
```js
let startNode = range.startContainer;
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/abstractrange | data/mdn-content/files/en-us/web/api/abstractrange/startoffset/index.md | ---
title: "AbstractRange: startOffset property"
short-title: startOffset
slug: Web/API/AbstractRange/startOffset
page-type: web-api-instance-property
browser-compat: api.AbstractRange.startOffset
---
{{APIRef("DOM")}}
The read-only **`startOffset`** property of the {{domxref("AbstractRange")}} interface returns the offset into the start node of the range's start position.
## Value
An integer value indicating the number of characters into the {{domxref("Node")}} indicated by {{domxref("AbstractRange.startContainer", "startContainer")}} at which the first character of the range is located.
## Example
```js
let startOffset = range.startOffset;
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/abstractrange | data/mdn-content/files/en-us/web/api/abstractrange/endoffset/index.md | ---
title: "AbstractRange: endOffset property"
short-title: endOffset
slug: Web/API/AbstractRange/endOffset
page-type: web-api-instance-property
browser-compat: api.AbstractRange.endOffset
---
{{APIRef("DOM")}}
The **`endOffset`** property of the {{domxref("AbstractRange")}} interface returns the offset into the end node of the range's end position.
## Value
An integer value indicating the number of characters into the {{domxref("Node")}} indicated by {{domxref("AbstractRange.endContainer", "endContainer")}} at which the final character of the range is located.
## Example
```js
let endOffset = range.endOffset;
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/abstractrange | data/mdn-content/files/en-us/web/api/abstractrange/endcontainer/index.md | ---
title: "AbstractRange: endContainer property"
short-title: endContainer
slug: Web/API/AbstractRange/endContainer
page-type: web-api-instance-property
browser-compat: api.AbstractRange.endContainer
---
{{APIRef("DOM")}}
The read-only **`endContainer`** property of the {{domxref("AbstractRange")}} interface returns the {{domxref("Node")}} in which the end of the range is located.
## Value
The {{domxref("Node")}} which contains the last character of the range.
## Example
```js
let endNode = range.endContainer;
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/abstractrange | data/mdn-content/files/en-us/web/api/abstractrange/collapsed/index.md | ---
title: "AbstractRange: collapsed property"
short-title: collapsed
slug: Web/API/AbstractRange/collapsed
page-type: web-api-instance-property
browser-compat: api.AbstractRange.collapsed
---
{{APIRef("DOM")}}
The read-only **`collapsed`** property of the {{domxref("AbstractRange")}} interface returns `true` if the range's start position and end position are the same.
## Value
A boolean value which is `true` if the range is _collapsed_. A collapsed range is one in which the start and end positions are the same, resulting in a zero-character-long range.
## Example
```js
let isCollapsed = range.collapsed;
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/rtcrtpreceiver/index.md | ---
title: RTCRtpReceiver
slug: Web/API/RTCRtpReceiver
page-type: web-api-interface
browser-compat: api.RTCRtpReceiver
---
{{APIRef("WebRTC")}}
The **`RTCRtpReceiver`** interface of the [WebRTC API](/en-US/docs/Web/API/WebRTC_API) manages the reception and decoding of data for a {{domxref("MediaStreamTrack")}} on an {{domxref("RTCPeerConnection")}}.
## Instance properties
- {{domxref("RTCRtpReceiver.track")}} {{ReadOnlyInline}}
- : Returns the {{domxref("MediaStreamTrack")}} associated with the current `RTCRtpReceiver` instance.
- {{domxref("RTCRtpReceiver.transport")}} {{ReadOnlyInline}}
- : Returns the {{domxref("RTCDtlsTransport")}} instance over which the media for the receiver's track is received.
- {{domxref("RTCRtpReceiver.transform")}}
- : An {{domxref("RTCRtpScriptTransform")}} is used to insert a transform stream ({{domxref("TransformStream")}}) running in a worker thread into the receiver pipeline, allowing stream transforms to be applied to incoming encoded video and audio frames.
### Obsolete properties
- `rtcpTransport` {{deprecated_inline}}
- : This property has been removed; the RTP and RTCP transports have been combined into a single transport. Use the {{domxref("RTCRtpReceiver.transport", "transport")}} property instead.
## Static methods
- {{domxref("RTCRtpReceiver.getCapabilities_static", "RTCRtpReceiver.getCapabilities()")}}
- : Returns the most optimistic view of the capabilities of the system for receiving media of the given kind.
## Instance methods
- {{domxref("RTCRtpReceiver.getContributingSources()")}}
- : Returns an array that contains an object for each unique CSRC (contributing source) identifier received by the current `RTCRtpReceiver` in the last ten seconds.
- {{domxref("RTCRtpReceiver.getParameters()")}}
- : Returns an object that contains information about how the RTC data is to be decoded.
- {{domxref("RTCRtpReceiver.getStats()")}}
- : Returns a {{jsxref("Promise")}} whose fulfillment handler receives a {{domxref("RTCStatsReport")}} which contains statistics about the incoming streams and their dependencies.
- {{domxref("RTCRtpReceiver.getSynchronizationSources()")}}
- : Returns an array that contains an object for each unique SSRC (synchronization source) identifier received by the current `RTCRtpReceiver` in the last ten seconds.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [WebRTC](/en-US/docs/Web/API/WebRTC_API)
- {{domxref("RTCStatsReport")}}
- {{domxref("RTCRtpSender")}}
- {{domxref("RTCPeerConnection.getStats()")}}
| 0 |
data/mdn-content/files/en-us/web/api/rtcrtpreceiver | data/mdn-content/files/en-us/web/api/rtcrtpreceiver/getcapabilities_static/index.md | ---
title: "RTCRtpReceiver: getCapabilities() static method"
short-title: getCapabilities()
slug: Web/API/RTCRtpReceiver/getCapabilities_static
page-type: web-api-static-method
browser-compat: api.RTCRtpReceiver.getCapabilities_static
---
{{DefaultAPISidebar("WebRTC")}}
The _static method_ **`RTCRtpReceiver.getCapabilities()`** returns an object describing the codec and header extension capabilities supported by {{domxref("RTCRtpReceiver")}} objects on the current device.
You can, similarly, obtain the capabilities of {{domxref("RTCRtpSender")}} objects by calling the static function {{domxref("RTCRtpSender.getCapabilities_static", "RTCRtpSender.getCapabilities()")}}.
## Syntax
```js-nolint
RTCRtpReceiver.getCapabilities(kind)
```
### Parameters
- `kind`
- : A string indicating the type of media for which the browser's receiver capabilities are requested.
The supported media kinds are: `audio` and `video`.
### Return value
A new object that indicates what capabilities the browser has for receiving the specified media kind over an {{domxref("RTCPeerConnection")}}.
If the browser doesn't have any support for the given media `kind`, the returned value is `null`.
The returned object has the following properties:
- `codecs`
- : An array of objects, each describing the basic capabilities of a single [media codec](/en-US/docs/Web/Media/Formats/WebRTC_codecs) supported by the {{domxref("RTCRtpReceiver")}}.
> **Note:** The array contains special entries that represent the underlying components of the transport — these may be ignored if you're only interested in the actual codecs used for the media itself.
> These are described below in the section [The codecs array](#the_codecs_array).
Each codec object has the following properties:
- `channels` {{optional_inline}}
- : A positive integer value indicating the maximum number of channels supported by the codec; for example, a codec that supports only mono sound would have a value of 1; stereo codecs would have a 2, etc.
- `clockRate`
- : A positive integer specifying the codec's clock rate in Hertz (Hz).
The IANA maintains a [list of codecs and their parameters](https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-1), including their clock rates.
- `mimeType`
- : A string indicating the codec's MIME media type and subtype.
The MIME type strings used by RTP differ from those used elsewhere.
See {{RFC(3555, "", 4)}} for the complete IANA registry of these types.
Also see [Codecs used by WebRTC](/en-US/docs/Web/Media/Formats/WebRTC_codecs) for details about potential codecs that might be referenced here.
- `sdpFmtpLine` {{optional_inline}}
- : A string giving the format specific parameters field from the `a=fmtp` line in the SDP which corresponds to the codec, if such a line exists.
If there is no parameters field, this property is left out.
- `headerExtensions`
- : An array of objects, each providing the URI of a [header extension](https://datatracker.ietf.org/doc/html/rfc3550#section-5.3.1) supported for the current `kind` of media.
Each object has the following property:
- `uri`
- : A string, specifying the URI of a header extension.
The URI is formatted as described in {{RFC(5285)}}.
## Description
As a static function, this is always called using the form:
```js
capabilities = RTCRtpReceiver.getCapabilities("audio");
```
The returned set of capabilities is the most optimistic possible list.
It is entirely possible that certain combinations of options may fail to work when you actually try to use them.
Calling `RTCRtpReceiver.getCapabilities()` doesn't prime the browser in any way to handle media. Nothing is loaded, fetched, or otherwise prepared.
It's a means of determining what might be usable before starting to try to access media.
Because the set of capabilities available tend to be stable for a length of time (people don't install and uninstall codecs and the like very often), the media capabilities can in whole or in part provide a cross-origin method for identifying a user.
For that reason, in privacy-sensitive contexts, the browser may choose to obscure the capabilities; this might be done, for example, by leaving out rarely-used codec configurations.
### The codecs array
The `codecs` array is an array of objects that describes a single codec and its basic capabilities.
The browser will only report distinct capability combinations separately.
If two sets of capabilities can be described as one, they will be.
That means that, for instance, if there are two entries for the H.264 codec (as identified by the [`mimeType`](#mimetype) being "video/H264"), there are other values in the capabilities objects indicating how they're different in some way.
There are three special entries that should always be present, representing underlying components of the transport. Those components are:
- RED (REDundant Audio Data)
- : The media type of an RED entry may vary due to there being several versions of it, but it will end with `red`, such as `video/red` or `video/fwdred`.
The base RED standard can be found in {{RFC(2198)}}. There may be multiple entries for RED if different forms are supported; each will have a unique media type in that case.
- FEC (Forward Error Correction)
- : An FEC component handles error correction data; its media type may also vary due to there being advanced versions of the standard available, but it will always end with `fec`.
One possible value is `video/ulpfec` (a generic error connection model).
There may also be multiple FEC entries if more than one form is supported.
- RTX (Retransmission)
- : This component is responsible for retransmission of data; it's media type should be `video/rtx`.
There will only be one entry for RTX, and it will not have an [`sdpFmtpLine`](#sdpfmtpline) property.
These entries should be ignored if only codecs related to the media are of interest.
## Examples
### Feature support
You can use [`Object.hasOwn()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn) to check that `RTCRtpReceiver.getCapabilities()` is supported:
```html hidden
<p id="log"></p>
```
```js hidden
const log = document.querySelector("#log");
```
```js
log.textContent = `RTCRtpReceiver.getCapabilities() supported: ${Object.hasOwn(
RTCRtpReceiver,
"getCapabilities",
)}`;
```
{{ EmbedLiveSample('Feature support', '100%', '30px') }}
### Checking support for a particular codec
The function below returns a Boolean indicating whether or not the device supports receiving H.264 video on a WebRTC connection.
> **Note:** Since `RTCRtpReceiver.getCapabilities()` actually only indicates > _probable_ support, attempting to receive H.264 video might still fail even after getting a positive response from this function.
```js
function canReceiveH264() {
let capabilities = RTCRtpReceiver.getCapabilities("video");
capabilities.codecs.forEach((codec) => {
if (codec.mimeType === "video/H264") {
return true;
}
});
return false;
}
```
### Getting all capabilities
This code example shows how we might get all supported codecs and headers.
The HTML defines a selection list for the two kinds of capabilities, and a log area.
```html
<select id="kind">
<option value="audio">audio</option>
<option value="video">video</option>
</select>
<textarea rows="40" cols="100" id="log"></textarea>
```
The JavaScript defines a function to log the capabilities for a particular "kind".
This is called initially with the value `audio`.
A listener updates the value when the selection list `kind` is changed.
```js
const log = document.querySelector("#log");
const kindSelector = document.querySelector("#kind");
logMediaCapabilities("audio");
kindSelector.addEventListener("click", () => {
log.textContent = "";
logMediaCapabilities(kindSelector.value);
});
function logMediaCapabilities(kind) {
if (!Object.hasOwn(RTCRtpReceiver, "getCapabilities")) {
log.textContent = "RTCRtpReceiver.getCapabilities() not supported";
return;
}
const capabilities = RTCRtpReceiver.getCapabilities(`${kind}`);
log.textContent += "Headers\n";
capabilities.headerExtensions.forEach((header) => {
log.textContent += ` uri: ${header.uri}\n`;
});
log.textContent += "\nCodecs\n";
capabilities.codecs.forEach((codec) => {
log.textContent += ` mime type: ${codec.mimeType}\n`;
log.textContent += ` channels: ${codec.channels}\n`; //max channels - e.g. 2 is stereo
log.textContent += ` clockRate: ${codec.clockRate}\n`; // clock rate in Hz
log.textContent += ` sdpFmtpLine: ${codec.sdpFmtpLine}\n`; // mime media type and subtype
});
}
```
#### Result
{{ EmbedLiveSample('Getting all capabilities', '100%', '500px') }}
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/rtcrtpreceiver | data/mdn-content/files/en-us/web/api/rtcrtpreceiver/getcontributingsources/index.md | ---
title: "RTCRtpReceiver: getContributingSources() method"
short-title: getContributingSources()
slug: Web/API/RTCRtpReceiver/getContributingSources
page-type: web-api-instance-method
browser-compat: api.RTCRtpReceiver.getContributingSources
---
{{APIRef("WebRTC API")}}
The **`getContributingSources()`** method of the {{domxref("RTCRtpReceiver")}} interface returns an array of objects, each corresponding to one CSRC (contributing source) identifier received by the current `RTCRtpReceiver` in the last ten seconds.
## Syntax
```js-nolint
getContributingSources()
```
### Parameters
None.
### Return value
An array of objects, each describing one of the contributing sources that provided data to the incoming stream in the past ten seconds.
These objects contain the following properties:
- `audioLevel` {{optional_inline}}
- : A floating-point value between 0.0 and 1.0 specifying the audio level contained in the last RTP packet played from the contributing source.
The value is on a linear scale and is defined in units of dBov, or decibels (overload).
This is the amplitude relative to the point at which clipping of the audio begins to occur.
A value of 1.0 represents 0 dBov (maximum volume), a value of 0.0 represents silence, and a value of 0.5 represents approximately 6 dB SPL (decibels of sound pressure level) change in the sound pressure level from 0 dBov.
If this property is not present then no volume level was provided by the source.
- `rtpTimestamp` {{optional_inline}}
- : The RTP timestamp (an integer {{domxref("DOMHighResTimeStamp")}}) of the media.
This source-generated timestamp indicates the time at which the media in this packet, scheduled for play out at the time indicated by `timestamp`, was initially sampled or generated.
It may be useful for sequencing and synchronization purposes.
- `source` {{optional_inline}}
- : A positive integer value specifying the CSRC identifier of the contributing source.
This uniquely identifies the source of the particular stream RTP packets.
- `timestamp` {{optional_inline}}
- : A {{domxref("DOMHighResTimeStamp")}} indicating the most recent time at which a frame originating from this source was delivered to the receiver's {{domxref("MediaStreamTrack")}}
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/rtcrtpreceiver | data/mdn-content/files/en-us/web/api/rtcrtpreceiver/getstats/index.md | ---
title: "RTCRtpReceiver: getStats() method"
short-title: getStats()
slug: Web/API/RTCRtpReceiver/getStats
page-type: web-api-instance-method
browser-compat: api.RTCRtpReceiver.getStats
---
{{APIRef("WebRTC")}}
The {{domxref("RTCRtpReceiver")}} method **`getStats()`** asynchronously requests an {{domxref("RTCStatsReport")}} object which provides statistics about incoming traffic on the owning {{domxref("RTCPeerConnection")}}, returning a {{jsxref("Promise")}} whose fulfillment handler will be called once the results are available.
## Syntax
```js-nolint
getStats()
```
### Parameters
None.
### Return value
A JavaScript {{jsxref("Promise")}} which is fulfilled once the statistics are available.
The promise's fulfillment handler receives as a parameter a {{domxref("RTCStatsReport")}} object containing the collected statistics.
The returned statistics include those from all streams which are coming in through the `RTCRtpReceiver`, as well as any of their dependencies.
These might include, for example, statistics with [types](/en-US/docs/Web/API/RTCStatsReport#the_statistic_types): [`inbound-rtp`](/en-US/docs/Web/API/RTCInboundRtpStreamStats), [`candidate-pair`](/en-US/docs/Web/API/RTCIceCandidatePairStats), [`local-candidate`](/en-US/docs/Web/API/RTCIceCandidateStats), [`remote-candidate`](/en-US/docs/Web/API/RTCIceCandidateStats).
## Examples
This simple example obtains the statistics for an `RTCRtpReceiver` and updates an element's {{domxref("HTMLElement/innerText", "innerText")}} to display the number of packets lost.
```js
receiver.getStats().then((stats) => {
document.getElementById("lostpackets").innerText = stats.packetsLost;
});
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [WebRTC API](/en-US/docs/Web/API/WebRTC_API)
- {{domxref("RTCStatsReport")}}
- {{domxref("RTCRtpSender.getStats()")}}
- {{domxref("RTCPeerConnection.getStats()")}}
| 0 |
data/mdn-content/files/en-us/web/api/rtcrtpreceiver | data/mdn-content/files/en-us/web/api/rtcrtpreceiver/transform/index.md | ---
title: "RTCRtpReceiver: transform property"
short-title: transform
slug: Web/API/RTCRtpReceiver/transform
page-type: web-api-instance-property
browser-compat: api.RTCRtpReceiver.transform
---
{{APIRef("WebRTC")}}
The **`transform`** property of the {{domxref("RTCRtpReceiver")}} object is used to insert a transform stream ({{domxref("TransformStream")}}) running in a worker thread into the receiver pipeline.
This allows stream transforms to be applied to encoded video and audio frames as they arrive from the packetizer (before they are played/rendered).
The transform that is to be added is defined using an {{domxref("RTCRtpScriptTransform")}} and its associated {{domxref("Worker")}}.
If the transform is set in the peer connection [`track` event](/en-US/docs/Web/API/RTCPeerConnection/track_event) handler, the transform stream will receive the first full incoming frame for the track.
### Value
A {{domxref("RTCRtpScriptTransform")}}<!-- or {{domxref("SFrameTransform")}} -->, or `null` if the receiver has no associated transform stream.
## Example
Note that this is part of a larger example in the guide topic [Using WebRTC Encoded Transforms](/en-US/docs/Web/API/WebRTC_API/Using_Encoded_Transforms).
## Adding a transform for incoming frames
This example shows how you add a WebRTC encoded transform to modify an incoming stream.
The code assumes that there is an {{domxref("RTCPeerConnection")}} called `peerConnection` that is already connected to a remote peer.
To add a transform stream into the pipeline for incoming frames we need to construct an {{domxref("RTCRtpScriptTransform")}} and assign it to the receiver's `transform` property.
We can do this in the [`track` event](/en-US/docs/Web/API/RTCPeerConnection/track_event) handler as shown.
This event is fired on the peer connection whenever the remote end sends a track.
The `event.receiver` property is an {{domxref("RTCRtpReceiver")}}.
```js
const worker = new Worker("worker.js");
peerConnection.ontrack = (event) => {
event.receiver.transform = new RTCRtpScriptTransform(worker, {
someOption: "receiverTransform",
});
};
```
Because the transform is constructed immediately after creation of the {{domxref("RTCRtpReceiver")}}, it will receive the first incoming frame.
The object passed as the second parameter in the {{domxref("RTCRtpScriptTransform")}} constructor is sent to the worker thread, and can be used by worker code to provide a different transform for the incoming frames than is used for outgoing frames.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Using WebRTC Encoded Transforms](/en-US/docs/Web/API/WebRTC_API/Using_Encoded_Transforms)
- {{domxref("RTCRtpSender.transform")}}
| 0 |
data/mdn-content/files/en-us/web/api/rtcrtpreceiver | data/mdn-content/files/en-us/web/api/rtcrtpreceiver/track/index.md | ---
title: "RTCRtpReceiver: track property"
short-title: track
slug: Web/API/RTCRtpReceiver/track
page-type: web-api-instance-property
browser-compat: api.RTCRtpReceiver.track
---
{{APIRef("WebRTC API")}}
The **`track`** read-only property of the
{{domxref("RTCRtpReceiver")}} interface returns the {{domxref("MediaStreamTrack")}}
associated with the current {{domxref("RTCRtpReceiver")}} instance.
## Value
A {{domxref("MediaStreamTrack")}} instance.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/rtcrtpreceiver | data/mdn-content/files/en-us/web/api/rtcrtpreceiver/getparameters/index.md | ---
title: "RTCRtpReceiver: getParameters() method"
short-title: getParameters()
slug: Web/API/RTCRtpReceiver/getParameters
page-type: web-api-instance-method
browser-compat: api.RTCRtpReceiver.getParameters
---
{{APIRef("WebRTC API")}}
The **`getParameters()`** method of the {{domxref("RTCRtpReceiver")}} interface returns an object describing the current configuration for the encoding and transmission of media on the receiver's {{domxref("RTCRtpReceiver.track", "track")}}.
## Syntax
```js-nolint
getParameters()
```
### Parameters
None.
### Return value
An object indicating the current configuration of the receiver.
<!-- Spec defines as RTCRtpReceiveParameters, which is just a RTCRtpParameters -->
- `codecs`
- : An array of {{domxref("RTCRtpCodecParameters")}} objects describing the set of codecs from which the sender or receiver will choose.
This parameter cannot be changed once initially set.
- `headerExtensions`
- : An array of zero or more RTP header extensions, each identifying an extension supported by the sender or receiver.
Header extensions are described in {{RFC(3550, "", "5.3.1")}}. This parameter cannot be changed once initially set.
- `rtcp`
- : An {{domxref("RTCRtcpParameters")}} object providing the configuration parameters used for {{Glossary("RTCP")}} on the sender or receiver.
This parameter cannot be changed once initially set.
## Examples
This example obtains the canonical name (CNAME) being used for {{Glossary("RTCP")}} on an {{domxref("RTCRtpReceiver")}}.
```js
function getRtcpCNAME(receiver) {
let parameters = receiver.getParameters();
return parameters.rtcp.cname;
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/rtcrtpreceiver | data/mdn-content/files/en-us/web/api/rtcrtpreceiver/getsynchronizationsources/index.md | ---
title: "RTCRtpReceiver: getSynchronizationSources() method"
short-title: getSynchronizationSources()
slug: Web/API/RTCRtpReceiver/getSynchronizationSources
page-type: web-api-instance-method
browser-compat: api.RTCRtpReceiver.getSynchronizationSources
---
{{APIRef("WebRTC API")}}
The **`getSynchronizationSources()`** method of the {{domxref("RTCRtpReceiver")}} interface returns an array of objects, each corresponding to one SSRC (synchronization source) identifier received by the current `RTCRtpReceiver` in the last ten seconds.
## Syntax
```js-nolint
getSynchronizationSources()
```
### Parameters
None.
### Return value
An array of objects, each describing one of the synchronization sources that provided data to the incoming stream in the past ten seconds.
These objects contain the following properties:
- `audioLevel`
- : A floating-point value between 0.0 and 1.0 specifying the audio level contained in the last RTP packet played from the synchronization source.
The value is on a linear scale and is defined in units of dBov, or decibels (overload).
This is the amplitude relative to the point at which clipping of the audio begins to occur.
A value of 1.0 represents 0 dBov (maximum volume), a value of 0.0 represents silence, and a value of 0.5 represents approximately 6 dB SPL (decibels of sound pressure level) change in the sound pressure level from 0 dBov.
This value is required and always present.
- `rtpTimestamp` {{optional_inline}}
- : The RTP timestamp (an integer {{domxref("DOMHighResTimeStamp")}}) of the media.
This source-generated timestamp indicates the time at which the media in this packet, scheduled for play out at the time indicated by `timestamp`, was initially sampled or generated.
It may be useful for sequencing and synchronization purposes.
- `source` {{optional_inline}}
- : A positive integer value specifying the SSRC identifier of the synchronization source.
This uniquely identifies the source of the particular stream RTP packets.
- `timestamp` {{optional_inline}}
- : A {{domxref("DOMHighResTimeStamp")}} indicating the most recent time at which a frame originating from this source was delivered to the receiver's {{domxref("MediaStreamTrack")}}
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/rtcrtpreceiver | data/mdn-content/files/en-us/web/api/rtcrtpreceiver/transport/index.md | ---
title: "RTCRtpReceiver: transport property"
short-title: transport
slug: Web/API/RTCRtpReceiver/transport
page-type: web-api-instance-property
browser-compat: api.RTCRtpReceiver.transport
---
{{DefaultAPISidebar("WebRTC")}}
The read-only **`transport`** property of an
{{domxref("RTCRtpReceiver")}} object provides the {{domxref("RTCDtlsTransport")}} object
used to interact with the underlying transport over which the receiver is exchanging
Real-time Transport Control Protocol ({{Glossary("RTCP")}}) packets.
This transport is responsible for receiving the data for the media on the receiver's
{{domxref("RTCRtpReceiver.track", "track")}}.
## Syntax
```js-nolint
rtcRtpReceiver.transport
```
### Value
An {{domxref("RTCDtlsTransport")}} object representing the underlying transport being
used by the receiver to exchange packets with the remote peer, or `null` if
the receiver isn't yet connected to a transport.
## Description
When the `RTCRtpReceiver` is first created, the value of
`transport` is `null`. This is replaced with an
`RTCDtlsTransport` once the receiver's transport has been established.
Note that when bundling is in effect—that is, when the {{domxref("RTCPeerConnection")}}
was created with a configuration object whose `bundlePolicy` is `max-compat`
or `max-bundle`—multiple receivers may be sharing the same transport; in this
case, all of them are using the same connection to transmit and/or receive
{{Glossary("RTP")}} and {{Glossary("RTCP")}} packets.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/canvas_api/index.md | ---
title: Canvas API
slug: Web/API/Canvas_API
page-type: web-api-overview
browser-compat: html.elements.canvas
---
{{DefaultAPISidebar("Canvas API")}}
The **Canvas API** provides a means for drawing graphics via [JavaScript](/en-US/docs/Web/JavaScript) and the [HTML](/en-US/docs/Web/HTML) {{HtmlElement("canvas")}} element. Among other things, it can be used for animation, game graphics, data visualization, photo manipulation, and real-time video processing.
The Canvas API largely focuses on 2D graphics. The [WebGL API](/en-US/docs/Web/API/WebGL_API), which also uses the `<canvas>` element, draws hardware-accelerated 2D and 3D graphics.
## Basic example
This simple example draws a green rectangle onto a canvas.
### HTML
```html
<canvas id="canvas"></canvas>
```
### JavaScript
The {{domxref("Document.getElementById()")}} method gets a reference to the HTML `<canvas>` element. Next, the {{domxref("HTMLCanvasElement.getContext()")}} method gets that element's context—the thing onto which the drawing will be rendered.
The actual drawing is done using the {{domxref("CanvasRenderingContext2D")}} interface. The {{domxref("CanvasRenderingContext2D.fillStyle", "fillStyle")}} property makes the rectangle green. The {{domxref("CanvasRenderingContext2D.fillRect()", "fillRect()")}} method places its top-left corner at (10, 10), and gives it a size of 150 units wide by 100 tall.
```js
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
ctx.fillStyle = "green";
ctx.fillRect(10, 10, 150, 100);
```
### Result
{{ EmbedLiveSample('Basic_example', 700, 180) }}
## Reference
- {{domxref("HTMLCanvasElement")}}
- {{domxref("CanvasRenderingContext2D")}}
- {{domxref("CanvasGradient")}}
- {{domxref("CanvasPattern")}}
- {{domxref("ImageBitmap")}}
- {{domxref("ImageData")}}
- {{domxref("TextMetrics")}}
- {{domxref("OffscreenCanvas")}}
- {{domxref("Path2D")}} {{experimental_inline}}
- {{domxref("ImageBitmapRenderingContext")}} {{experimental_inline}}
> **Note:** The interfaces related to the `WebGLRenderingContext` are referenced under [WebGL](/en-US/docs/Web/API/WebGL_API).
> **Note:** {{domxref("OffscreenCanvas")}} is also available in web workers.
{{domxref("CanvasCaptureMediaStreamTrack")}} is a related interface.
## Guides and tutorials
- [Canvas tutorial](/en-US/docs/Web/API/Canvas_API/Tutorial)
- : A comprehensive tutorial covering both the basic usage of the Canvas API and its advanced features.
- [HTML5 Canvas Deep Dive](https://joshondesign.com/p/books/canvasdeepdive/title.html)
- : A hands-on, book-length introduction to the Canvas API and WebGL.
- [Canvas Handbook](https://bucephalus.org/text/CanvasHandbook/CanvasHandbook.html)
- : A handy reference for the Canvas API.
- [Manipulating video using canvas](/en-US/docs/Web/API/Canvas_API/Manipulating_video_using_canvas)
- : Combining {{HTMLElement("video")}} and {{HTMLElement("canvas")}} to manipulate video data in real time.
## Libraries
The Canvas API is extremely powerful, but not always simple to use. The libraries listed below can make the creation of canvas-based projects faster and easier.
- [EaselJS](https://www.createjs.com/easeljs) is an open-source canvas library that makes creating games, generative art, and other highly graphical experiences easy.
- [Fabric.js](http://fabricjs.com) is an open-source canvas library with SVG parsing capabilities.
- [heatmap.js](https://www.patrick-wied.at/static/heatmapjs/) is an open-source library for creating canvas-based data heat maps.
- [JavaScript InfoVis Toolkit](https://philogb.github.io/jit/) creates interactive data visualizations.
- [Konva.js](https://konvajs.org/) is a 2D canvas library for desktop and mobile applications.
- [p5.js](https://p5js.org/) has a full set of canvas drawing functionality for artists, designers, educators, and beginners.
- [Paper.js](http://paperjs.org/) is an open-source vector graphics scripting framework that runs on top of the HTML Canvas.
- [Phaser](https://phaser.io/) is a fast, free and fun open source framework for Canvas and WebGL powered browser games.
- [Pts.js](https://ptsjs.org) is a library for creative coding and visualization in canvas and SVG.
- [Rekapi](https://github.com/jeremyckahn/rekapi) is an animation key-framing API for Canvas.
- [Scrawl-canvas](https://scrawl.rikweb.org.uk/) is an open-source JavaScript library for creating and manipulating 2D canvas elements.
- The [ZIM](https://zimjs.com) framework provides conveniences, components, and controls for coding creativity on the canvas — includes accessibility and hundreds of colorful tutorials.
- [Sprig](https://github.com/hackclub/sprig) is a beginner-friendly, open-source, tile-based game development library that uses Canvas.
> **Note:** See the [WebGL API](/en-US/docs/Web/API/WebGL_API) for 2D and 3D libraries that use WebGL.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [WebGL](/en-US/docs/Web/API/WebGL_API)
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/index.md | ---
title: Canvas tutorial
slug: Web/API/Canvas_API/Tutorial
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}}
This tutorial describes how to use the [**`<canvas>`**](/en-US/docs/Web/HTML/Element/canvas) element to draw 2D graphics, starting with the basics. The examples provided should give you some clear ideas about what you can do with canvas, and will provide code snippets that may get you started in building your own content.
`<canvas>` is an [HTML](/en-US/docs/Web/HTML) element which can be used to draw graphics via scripting (usually [JavaScript](/en-US/docs/Glossary/JavaScript)). This can, for instance, be used to draw graphs, combine photos, or create simple animations.
First introduced in WebKit by Apple for the macOS Dashboard, `<canvas>` has since been implemented in browsers. Today, all major browsers support it.
## Before you start
Using the `<canvas>` element is not very difficult, but you do need a basic understanding of [HTML](/en-US/docs/Web/HTML) and [JavaScript](/en-US/docs/Web/JavaScript). The `<canvas>` element is not supported in some older browsers, but is supported in recent versions of all major browsers. The default size of the canvas is 300 pixels × 150 pixels (width × height). But custom sizes can be defined using the HTML `height` and `width` property. In order to draw graphics on the canvas we use a JavaScript context object, which creates graphics on the fly.
## In this tutorial
1. [Basic usage](/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_usage)
2. [Drawing shapes](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes)
3. [Applying styles and colors](/en-US/docs/Web/API/Canvas_API/Tutorial/Applying_styles_and_colors)
4. [Drawing text](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text)
5. [Using images](/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images)
6. [Transformations](/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations)
7. [Compositing and clipping](/en-US/docs/Web/API/Canvas_API/Tutorial/Compositing)
8. [Basic animations](/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations)
9. [Advanced animations](/en-US/docs/Web/API/Canvas_API/Tutorial/Advanced_animations)
10. [Pixel manipulation](/en-US/docs/Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas)
11. [Optimizing the canvas](/en-US/docs/Web/API/Canvas_API/Tutorial/Optimizing_canvas)
12. [Finale](/en-US/docs/Web/API/Canvas_API/Tutorial/Finale)
## See also
- [Canvas topic page](/en-US/docs/Web/API/Canvas_API)
- [HTML5CanvasTutorials](https://www.html5canvastutorials.com/)
## A note to contributors
Due to an unfortunate technical error that occurred the week of June 17, 2013, we lost the history of this tutorial, including attributions to all past contributors to its content. We apologize for this, and hope you'll forgive this unfortunate mishap.
{{ Next("Web/API/Canvas_API/Tutorial/Basic_usage") }}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/basic_animations/index.md | ---
title: Basic animations
slug: Web/API/Canvas_API/Tutorial/Basic_animations
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Compositing", "Web/API/Canvas_API/Tutorial/Advanced_animations")}}
Since we're using JavaScript to control {{HTMLElement("canvas")}} elements, it's also very easy to make (interactive) animations. In this chapter we will take a look at how to do some basic animations.
Probably the biggest limitation is, that once a shape gets drawn, it stays that way. If we need to move it we have to redraw it and everything that was drawn before it. It takes a lot of time to redraw complex frames and the performance depends highly on the speed of the computer it's running on.
## Basic animation steps
These are the steps you need to take to draw a frame:
1. **Clear the canvas**
Unless the shapes you'll be drawing fill the complete canvas (for instance a backdrop image), you need to clear any shapes that have been drawn previously. The easiest way to do this is using the {{domxref("CanvasRenderingContext2D.clearRect", "clearRect()")}} method.
2. **Save the canvas state**
If you're changing any setting (such as styles, transformations, etc.) which affect the canvas state and you want to make sure the original state is used each time a frame is drawn, you need to save that original state.
3. **Draw animated shapes**
The step where you do the actual frame rendering.
4. **Restore the canvas state**
If you've saved the state, restore it before drawing a new frame.
## Controlling an animation
Shapes are drawn to the canvas by using the canvas methods directly or by calling custom functions. In normal circumstances, we only see these results appear on the canvas when the script finishes executing. For instance, it isn't possible to do an animation from within a `for` loop.
That means we need a way to execute our drawing functions over a period of time. There are two ways to control an animation like this.
### Scheduled updates
First there's the {{domxref("setInterval()")}}, {{domxref("setTimeout()")}}, and {{domxref("window.requestAnimationFrame()")}} functions, which can be used to call a specific function over a set period of time.
- {{domxref("setInterval()")}}
- : Starts repeatedly executing the function specified by `function` every `delay` milliseconds.
- {{domxref("setTimeout()")}}
- : Executes the function specified by `function` in `delay` milliseconds.
- {{domxref("Window.requestAnimationFrame()", "requestAnimationFrame(callback)")}}
- : Tells the browser that you wish to perform an animation and requests that the browser call a specified function to update an animation before the next repaint.
If you don't want any user interaction you can use the `setInterval()` function, which repeatedly executes the supplied code. If we wanted to make a game, we could use keyboard or mouse events to control the animation and use `setTimeout()`. By setting listeners using {{domxref("EventTarget/addEventListener", "addEventListener()")}}, we catch any user interaction and execute our animation functions.
> **Note:** In the examples below, we'll use the {{domxref("window.requestAnimationFrame()")}} method to control the animation. The `requestAnimationFrame` method provides a smoother and more efficient way for animating by calling the animation frame when the system is ready to paint the frame. The number of callbacks is usually 60 times per second and may be reduced to a lower rate when running in background tabs. For more information about the animation loop, especially for games, see the article [Anatomy of a video game](/en-US/docs/Games/Anatomy) in our [Game development zone](/en-US/docs/Games).
## An animated solar system
This example animates a small model of our solar system.
### HTML
```html
<canvas id="canvas" width="300" height="300"></canvas>
```
### JavaScript
```js
const sun = new Image();
const moon = new Image();
const earth = new Image();
function init() {
sun.src = "canvas_sun.png";
moon.src = "canvas_moon.png";
earth.src = "canvas_earth.png";
window.requestAnimationFrame(draw);
}
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.globalCompositeOperation = "destination-over";
ctx.clearRect(0, 0, 300, 300); // clear canvas
ctx.fillStyle = "rgb(0 0 0 / 40%)";
ctx.strokeStyle = "rgb(0 153 255 / 40%)";
ctx.save();
ctx.translate(150, 150);
// Earth
const time = new Date();
ctx.rotate(
((2 * Math.PI) / 60) * time.getSeconds() +
((2 * Math.PI) / 60000) * time.getMilliseconds(),
);
ctx.translate(105, 0);
ctx.fillRect(0, -12, 40, 24); // Shadow
ctx.drawImage(earth, -12, -12);
// Moon
ctx.save();
ctx.rotate(
((2 * Math.PI) / 6) * time.getSeconds() +
((2 * Math.PI) / 6000) * time.getMilliseconds(),
);
ctx.translate(0, 28.5);
ctx.drawImage(moon, -3.5, -3.5);
ctx.restore();
ctx.restore();
ctx.beginPath();
ctx.arc(150, 150, 105, 0, Math.PI * 2, false); // Earth orbit
ctx.stroke();
ctx.drawImage(sun, 0, 0, 300, 300);
window.requestAnimationFrame(draw);
}
init();
```
### Result
{{EmbedLiveSample("An_animated_solar_system", "310", "340")}}
## An animated clock
This example draws an animated clock, showing your current time.
### HTML
```html
<canvas id="canvas" width="150" height="150">The current time</canvas>
```
### JavaScript
```js
function clock() {
const now = new Date();
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
ctx.save();
ctx.clearRect(0, 0, 150, 150);
ctx.translate(75, 75);
ctx.scale(0.4, 0.4);
ctx.rotate(-Math.PI / 2);
ctx.strokeStyle = "black";
ctx.fillStyle = "white";
ctx.lineWidth = 8;
ctx.lineCap = "round";
// Hour marks
ctx.save();
for (let i = 0; i < 12; i++) {
ctx.beginPath();
ctx.rotate(Math.PI / 6);
ctx.moveTo(100, 0);
ctx.lineTo(120, 0);
ctx.stroke();
}
ctx.restore();
// Minute marks
ctx.save();
ctx.lineWidth = 5;
for (let i = 0; i < 60; i++) {
if (i % 5 !== 0) {
ctx.beginPath();
ctx.moveTo(117, 0);
ctx.lineTo(120, 0);
ctx.stroke();
}
ctx.rotate(Math.PI / 30);
}
ctx.restore();
const sec = now.getSeconds();
// To display a clock with a sweeping second hand, use:
// const sec = now.getSeconds() + now.getMilliseconds() / 1000;
const min = now.getMinutes();
const hr = now.getHours() % 12;
ctx.fillStyle = "black";
// Write image description
canvas.innerText = `The time is: ${hr}:${min}`;
// Write Hours
ctx.save();
ctx.rotate(
(Math.PI / 6) * hr + (Math.PI / 360) * min + (Math.PI / 21600) * sec,
);
ctx.lineWidth = 14;
ctx.beginPath();
ctx.moveTo(-20, 0);
ctx.lineTo(80, 0);
ctx.stroke();
ctx.restore();
// Write Minutes
ctx.save();
ctx.rotate((Math.PI / 30) * min + (Math.PI / 1800) * sec);
ctx.lineWidth = 10;
ctx.beginPath();
ctx.moveTo(-28, 0);
ctx.lineTo(112, 0);
ctx.stroke();
ctx.restore();
// Write seconds
ctx.save();
ctx.rotate((sec * Math.PI) / 30);
ctx.strokeStyle = "#D40000";
ctx.fillStyle = "#D40000";
ctx.lineWidth = 6;
ctx.beginPath();
ctx.moveTo(-30, 0);
ctx.lineTo(83, 0);
ctx.stroke();
ctx.beginPath();
ctx.arc(0, 0, 10, 0, Math.PI * 2, true);
ctx.fill();
ctx.beginPath();
ctx.arc(95, 0, 10, 0, Math.PI * 2, true);
ctx.stroke();
ctx.fillStyle = "rgb(0 0 0 / 0%)";
ctx.arc(0, 0, 3, 0, Math.PI * 2, true);
ctx.fill();
ctx.restore();
ctx.beginPath();
ctx.lineWidth = 14;
ctx.strokeStyle = "#325FA2";
ctx.arc(0, 0, 142, 0, Math.PI * 2, true);
ctx.stroke();
ctx.restore();
window.requestAnimationFrame(clock);
}
window.requestAnimationFrame(clock);
```
### Result
> **Note:** Although the clock updates only once every second, the animated image is updated at 60 frames per second (or at the display refresh rate of your web browser).
> To display the clock with a sweeping second hand, replace the definition of `const sec` above with the version that has been commented out.
{{EmbedLiveSample("An_animated_clock", "180", "200")}}
## A looping panorama
In this example, a panorama is scrolled left-to-right. We're using [an image of Yosemite National Park](https://commons.wikimedia.org/wiki/File:Capitan_Meadows,_Yosemite_National_Park.jpg) we took from Wikipedia, but you could use any image that's larger than the canvas.
### HTML
The HTML includes the {{HTMLElement("canvas")}} in which the image is scrolled. Note that the width and height specified here must match the values of the `canvasXSize` and `canvasYSize` variables in the JavaScript code.
```html
<canvas id="canvas" width="800" height="200"
>Yosemite National Park, meadow at the base of El Capitan</canvas
>
```
### JavaScript
```js
const img = new Image();
// User Variables - customize these to change the image being scrolled, its
// direction, and the speed.
img.src = "capitan_meadows_yosemite_national_park.jpg";
const canvasXSize = 800;
const canvasYSize = 200;
const speed = 30; // lower is faster
const scale = 1.05;
const y = -4.5; // vertical offset
// Main program
const dx = 0.75;
let imgW;
let imgH;
let x = 0;
let clearX;
let clearY;
let ctx;
img.onload = () => {
imgW = img.width * scale;
imgH = img.height * scale;
if (imgW > canvasXSize) {
// Image larger than canvas
x = canvasXSize - imgW;
}
// Check if image dimension is larger than canvas
clearX = Math.max(imgW, canvasXSize);
clearY = Math.max(imgH, canvasYSize);
// Get canvas context
ctx = document.getElementById("canvas").getContext("2d");
// Set refresh rate
return setInterval(draw, speed);
};
function draw() {
ctx.clearRect(0, 0, clearX, clearY); // clear the canvas
// If image is <= canvas size
if (imgW <= canvasXSize) {
// Reset, start from beginning
if (x > canvasXSize) {
x = -imgW + x;
}
// Draw additional image1
if (x > 0) {
ctx.drawImage(img, -imgW + x, y, imgW, imgH);
}
// Draw additional image2
if (x - imgW > 0) {
ctx.drawImage(img, -imgW * 2 + x, y, imgW, imgH);
}
} else {
// Image is > canvas size
// Reset, start from beginning
if (x > canvasXSize) {
x = canvasXSize - imgW;
}
// Draw additional image
if (x > canvasXSize - imgW) {
ctx.drawImage(img, x - imgW + 1, y, imgW, imgH);
}
}
// Draw image
ctx.drawImage(img, x, y, imgW, imgH);
// Amount to move
x += dx;
}
```
### Result
{{EmbedLiveSample("A_looping_panorama", "830", "250")}}
## Mouse following animation
### HTML
```html
<canvas id="cw"
>Animation creating multi-colored disappearing stream of light that follow the
cursor as it moves over the image
</canvas>
```
### CSS
```css
#cw {
position: fixed;
z-index: -1;
}
body {
margin: 0;
padding: 0;
background-color: rgb(0 0 0 / 5%);
}
```
### JavaScript
```js
const canvas = document.getElementById("cw");
const context = canvas.getContext("2d");
context.globalAlpha = 0.5;
const cursor = {
x: innerWidth / 2,
y: innerHeight / 2,
};
let particlesArray = [];
generateParticles(101);
setSize();
anim();
addEventListener("mousemove", (e) => {
cursor.x = e.clientX;
cursor.y = e.clientY;
});
addEventListener(
"touchmove",
(e) => {
e.preventDefault();
cursor.x = e.touches[0].clientX;
cursor.y = e.touches[0].clientY;
},
{ passive: false },
);
addEventListener("resize", () => setSize());
function generateParticles(amount) {
for (let i = 0; i < amount; i++) {
particlesArray[i] = new Particle(
innerWidth / 2,
innerHeight / 2,
4,
generateColor(),
0.02,
);
}
}
function generateColor() {
let hexSet = "0123456789ABCDEF";
let finalHexString = "#";
for (let i = 0; i < 6; i++) {
finalHexString += hexSet[Math.ceil(Math.random() * 15)];
}
return finalHexString;
}
function setSize() {
canvas.height = innerHeight;
canvas.width = innerWidth;
}
function Particle(x, y, particleTrailWidth, strokeColor, rotateSpeed) {
this.x = x;
this.y = y;
this.particleTrailWidth = particleTrailWidth;
this.strokeColor = strokeColor;
this.theta = Math.random() * Math.PI * 2;
this.rotateSpeed = rotateSpeed;
this.t = Math.random() * 150;
this.rotate = () => {
const ls = {
x: this.x,
y: this.y,
};
this.theta += this.rotateSpeed;
this.x = cursor.x + Math.cos(this.theta) * this.t;
this.y = cursor.y + Math.sin(this.theta) * this.t;
context.beginPath();
context.lineWidth = this.particleTrailWidth;
context.strokeStyle = this.strokeColor;
context.moveTo(ls.x, ls.y);
context.lineTo(this.x, this.y);
context.stroke();
};
}
function anim() {
requestAnimationFrame(anim);
context.fillStyle = "rgb(0 0 0 / 5%)";
context.fillRect(0, 0, canvas.width, canvas.height);
particlesArray.forEach((particle) => particle.rotate());
}
```
### Result
{{EmbedLiveSample("Mouse_following_animation", "500", "500")}}
## Other examples
- [Advanced animations](/en-US/docs/Web/API/Canvas_API/Tutorial/Advanced_animations)
- : We will have a look at some advanced animation techniques and physics in the next chapter.
{{PreviousNext("Web/API/Canvas_API/Tutorial/Compositing", "Web/API/Canvas_API/Tutorial/Advanced_animations")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/using_images/index.md | ---
title: Using images
slug: Web/API/Canvas_API/Tutorial/Using_images
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Drawing_text", "Web/API/Canvas_API/Tutorial/Transformations" )}}
Until now we have created our own [shapes](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes) and [applied styles](/en-US/docs/Web/API/Canvas_API/Tutorial/Applying_styles_and_colors) to them. One of the more exciting features of {{HTMLElement("canvas")}} is the ability to use images. These can be used to do dynamic photo compositing or as backdrops of graphs, for sprites in games, and so forth. External images can be used in any format supported by the browser, such as PNG, GIF, or JPEG. You can even use the image produced by other canvas elements on the same page as the source!
Importing images into a canvas is basically a two step process:
1. Get a reference to an {{domxref("HTMLImageElement")}} object or to another canvas element as a source. It is also possible to use images by providing a URL.
2. Draw the image on the canvas using the `drawImage()` function.
Let's take a look at how to do this.
## Getting images to draw
The canvas API is able to use any of the following data types as an image source:
- {{domxref("HTMLImageElement")}}
- : These are images created using the `Image()` constructor, as well as any {{HTMLElement("img")}} element.
- {{domxref("SVGImageElement")}}
- : These are images embedded using the {{SVGElement("image")}} element.
- {{domxref("HTMLVideoElement")}}
- : Using an HTML {{HTMLElement("video")}} element as your image source grabs the current frame from the video and uses it as an image.
- {{domxref("HTMLCanvasElement")}}
- : You can use another {{HTMLElement("canvas")}} element as your image source.
- {{domxref("ImageBitmap")}}
- : A bitmap image, eventually cropped. Such type are used to extract part of an image, a _sprite_, from a larger image
- {{domxref("OffscreenCanvas")}}
- : A special kind of `<canvas>` that is not displayed and is prepared without being displayed. Using such an image source allows to switch to it without the composition of the content to be visible to the user.
- {{domxref("VideoFrame")}}
- : An image representing one single frame of a video.
There are several ways to get images for use on a canvas.
### Using images from the same page
We can obtain a reference to images on the same page as the canvas by using one of:
- The {{domxref("document.images")}} collection
- The {{domxref("document.getElementsByTagName()")}} method
- If you know the ID of the specific image you wish to use, you can use {{domxref("document.getElementById()")}} to retrieve that specific image
### Using images from other domains
Using the [`crossorigin`](/en-US/docs/Web/HTML/Element/img#crossorigin) attribute of an {{HTMLElement("img")}} element (reflected by the {{domxref("HTMLImageElement.crossOrigin")}} property), you can request permission to load an image from another domain for use in your call to `drawImage()`. If the hosting domain permits cross-domain access to the image, the image can be used in your canvas without tainting it; otherwise using the image will [taint the canvas](/en-US/docs/Web/HTML/CORS_enabled_image#what_is_a_.22tainted.22_canvas.3f).
### Using other canvas elements
Just as with normal images, we access other canvas elements using either the {{domxref("document.getElementsByTagName()")}} or {{domxref("document.getElementById()")}} method. Be sure you've drawn something to the source canvas before using it in your target canvas.
One of the more practical uses of this would be to use a second canvas element as a thumbnail view of the other larger canvas.
### Creating an image from scratch
Another option is to create new {{domxref("HTMLImageElement")}} objects in our script. To do this, you can use the convenient `Image()` constructor:
```js
const img = new Image(); // Create new img element
img.src = "myImage.png"; // Set source path
```
When this script gets executed, the image starts loading.
If you try to call `drawImage()` before the image has finished loading, it won't do anything (or, in older browsers, may even throw an exception). So you need to be sure to use the load event so you don't try this before the image has loaded:
```js
const img = new Image(); // Create new img element
img.addEventListener("load", () => {
// execute drawImage statements here
});
img.src = "myImage.png"; // Set source path
```
If you're only using one external image this can be a good approach, but once you need to track more than one we need to resort to something more clever. It's beyond the scope of this tutorial to look at image pre-loading tactics, but you should keep that in mind.
### Embedding an image via data: URL
Another possible way to include images is via the [data: URL](/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs). Data URLs allow you to completely define an image as a Base64 encoded string of characters directly in your code.
```js
const img = new Image(); // Create new img element
img.src =
"data:image/gif;base64,R0lGODlhCwALAIAAAAAA3pn/ZiH5BAEAAAEALAAAAAALAAsAAAIUhA+hkcuO4lmNVindo7qyrIXiGBYAOw==";
```
One advantage of data URLs is that the resulting image is available immediately without another round trip to the server. Another potential advantage is that it is also possible to encapsulate in one file all of your [CSS](/en-US/docs/Web/CSS), [JavaScript](/en-US/docs/Web/JavaScript), [HTML](/en-US/docs/Web/HTML), and images, making it more portable to other locations.
Some disadvantages of this method are that your image is not cached, and for larger images the encoded URL can become quite long.
### Using frames from a video
You can also use frames from a video being presented by a {{HTMLElement("video")}} element (even if the video is not visible). For example, if you have a {{HTMLElement("video")}} element with the ID "myvideo", you can do this:
```js
function getMyVideo() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
return document.getElementById("myvideo");
}
}
```
This returns the {{domxref("HTMLVideoElement")}} object for the video, which, as covered earlier, can be used as an image source for the canvas.
## Drawing images
Once we have a reference to our source image object we can use the `drawImage()` method to render it to the canvas. As we will see later the `drawImage()` method is overloaded and has several variants. In its most basic form it looks like this:
- {{domxref("CanvasRenderingContext2D.drawImage", "drawImage(image, x, y)")}}
- : Draws the image specified by the `image` parameter at the coordinates (`x`, `y`).
> **Note:** SVG images must specify a width and height in the root \<svg> element.
### Example: A simple line graph
In the following example, we will use an external image as the backdrop for a small line graph. Using backdrops can make your script considerably smaller because we can avoid the need for code to generate the background. In this example, we're only using one image, so I use the image object's `load` event handler to execute the drawing statements. The `drawImage()` method places the backdrop at the coordinate (0, 0), which is the top-left corner of the canvas.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="180" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
const img = new Image();
img.onload = () => {
ctx.drawImage(img, 0, 0);
ctx.beginPath();
ctx.moveTo(30, 96);
ctx.lineTo(70, 66);
ctx.lineTo(103, 76);
ctx.lineTo(170, 15);
ctx.stroke();
};
img.src = "backdrop.png";
}
```
```js
draw();
```
The resulting graph looks like this:
{{EmbedLiveSample("Example_A_simple_line_graph", 220, 160, "canvas_backdrop.png")}}
## Scaling
The second variant of the `drawImage()` method adds two new parameters and lets us place scaled images on the canvas.
- {{domxref("CanvasRenderingContext2D.drawImage", "drawImage(image, x, y, width, height)")}}
- : This adds the `width` and `height` parameters, which indicate the size to which to scale the image when drawing it onto the canvas.
### Example: Tiling an image
In this example, we'll use an image as a wallpaper and repeat it several times on the canvas. This is done by looping and placing the scaled images at different positions. In the code below, the first `for` loop iterates over the rows. The second `for` loop iterates over the columns. The image is scaled to one third of its original size, which is 50x38 pixels.
> **Note:** Images can become blurry when scaling up or grainy if they're scaled down too much. Scaling is probably best not done if you've got some text in it which needs to remain legible.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
const img = new Image();
img.onload = () => {
for (let i = 0; i < 4; i++) {
for (let j = 0; j < 3; j++) {
ctx.drawImage(img, j * 50, i * 38, 50, 38);
}
}
};
img.src = "rhino.jpg";
}
```
```js hidden
draw();
```
The resulting canvas looks like this:
{{EmbedLiveSample("Example_Tiling_an_image", 160, 160, "canvas_scale_image.png")}}
## Slicing
The third and last variant of the `drawImage()` method has eight parameters in addition to the image source. It lets us cut out a section of the source image, then scale and draw it on our canvas.
- {{domxref("CanvasRenderingContext2D.drawImage", "drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight)")}}
- : Given an `image`, this function takes the area of the source image specified by the rectangle whose top-left corner is (`sx`, `sy`) and whose width and height are `sWidth` and `sHeight` and draws it into the canvas, placing it on the canvas at (`dx`, `dy`) and scaling it to the size specified by `dWidth` and `dHeight`.
To really understand what this does, it may help to look at this image:

The first four parameters define the location and size of the slice on the source image. The last four parameters define the rectangle into which to draw the image on the destination canvas.
Slicing can be a useful tool when you want to make compositions. You could have all elements in a single image file and use this method to composite a complete drawing. For instance, if you want to make a chart you could have a PNG image containing all the necessary text in a single file and depending on your data could change the scale of your chart fairly easily. Another advantage is that you don't need to load every image individually, which can improve load performance.
### Example: Framing an image
In this example, we'll use the same rhino as in the previous example, but we'll slice out its head and composite it into a picture frame. The picture frame image is a 24-bit PNG which includes a drop shadow. Because 24-bit PNG images include a full 8-bit alpha channel, unlike GIF and 8-bit PNG images, it can be placed onto any background without worrying about a matte color.
```html
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
<div style="display:none;">
<img id="source" src="rhino.jpg" width="300" height="227" />
<img id="frame" src="canvas_picture_frame.png" width="132" height="150" />
</div>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
// Draw slice
ctx.drawImage(
document.getElementById("source"),
33,
71,
104,
124,
21,
20,
87,
104,
);
// Draw frame
ctx.drawImage(document.getElementById("frame"), 0, 0);
}
draw();
```
We took a different approach to loading the images this time. Instead of loading them by creating new {{domxref("HTMLImageElement")}} objects, we included them as {{HTMLElement("img")}} tags directly in our HTML source and retrieved the images from those. The images are hidden from output by setting the CSS property {{cssxref("display")}} to none for those images.
{{EmbedLiveSample("Example_Framing_an_image", 160, 160, "canvas_drawimage2.jpg")}}
The script itself is very simple. Each {{HTMLElement("img")}} is assigned an ID attribute, which makes them easy to select using {{domxref("document.getElementById()")}}. We then use `drawImage()` to slice the rhino out of the first image and scale him onto the canvas, then draw the frame on top using a second `drawImage()` call.
## Art gallery example
In the final example of this chapter, we'll build a little art gallery. The gallery consists of a table containing several images. When the page is loaded, a {{HTMLElement("canvas")}} element is inserted for each image and a frame is drawn around it.
In this case, every image has a fixed width and height, as does the frame that's drawn around them. You could enhance the script so that it uses the image's width and height to make the frame fit perfectly around it.
The code below should be self-explanatory. We loop through the {{domxref("document.images")}} container and add new canvas elements accordingly. Probably the only thing to note, for those not so familiar with the DOM, is the use of the {{domxref("Node.insertBefore")}} method. `insertBefore()` is a method of the parent node (a table cell) of the element (the image) before which we want to insert our new node (the canvas element).
```html
<html lang="en">
<body>
<table>
<tr>
<td><img src="gallery_1.jpg" /></td>
<td><img src="gallery_2.jpg" /></td>
<td><img src="gallery_3.jpg" /></td>
<td><img src="gallery_4.jpg" /></td>
</tr>
<tr>
<td><img src="gallery_5.jpg" /></td>
<td><img src="gallery_6.jpg" /></td>
<td><img src="gallery_7.jpg" /></td>
<td><img src="gallery_8.jpg" /></td>
</tr>
</table>
<img id="frame" src="canvas_picture_frame.png" width="132" height="150" />
</body>
</html>
```
And here's some CSS to make things look nice:
```css
body {
background: 0 -100px repeat-x url(bg_gallery.png) #4f191a;
margin: 10px;
}
img {
display: none;
}
table {
margin: 0 auto;
}
td {
padding: 15px;
}
```
Tying it all together is the JavaScript to draw our framed images:
```js
function draw() {
// Loop through all images
for (const image of document.images) {
// Don't add a canvas for the frame image
if (image.getAttribute("id") !== "frame") {
// Create canvas element
const canvas = document.createElement("canvas");
canvas.setAttribute("width", 132);
canvas.setAttribute("height", 150);
// Insert before the image
image.parentNode.insertBefore(canvas, image);
ctx = canvas.getContext("2d");
// Draw image to canvas
ctx.drawImage(image, 15, 20);
// Add frame
ctx.drawImage(document.getElementById("frame"), 0, 0);
}
}
}
draw();
```
{{EmbedLiveSample("Art_gallery_example", 725, 400)}}
## Controlling image scaling behavior
As mentioned previously, scaling images can result in fuzzy or blocky artifacts due to the scaling process. You can use the drawing context's {{domxref("CanvasRenderingContext2D.imageSmoothingEnabled", "imageSmoothingEnabled")}} property to control the use of image smoothing algorithms when scaling images within your context. By default, this is `true`, meaning images will be smoothed when scaled.
{{PreviousNext("Web/API/Canvas_API/Tutorial/Drawing_text", "Web/API/Canvas_API/Tutorial/Transformations")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/drawing_shapes/index.md | ---
title: Drawing shapes with canvas
slug: Web/API/Canvas_API/Tutorial/Drawing_shapes
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Basic_usage", "Web/API/Canvas_API/Tutorial/Applying_styles_and_colors")}}
Now that we have set up our [canvas environment](/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_usage), we can get into the details of how to draw on the canvas. By the end of this article, you will have learned how to draw rectangles, triangles, lines, arcs and curves, providing familiarity with some of the basic shapes. Working with paths is essential when drawing objects onto the canvas and we will see how that can be done.
## The grid
Before we can start drawing, we need to talk about the canvas grid or **coordinate space**. Our HTML skeleton from the previous page had a canvas element 150 pixels wide and 150 pixels high.

Normally 1 unit in the grid corresponds to 1 pixel on the canvas. The origin of this grid is positioned in the _top left_ corner at coordinate (0,0). All elements are placed relative to this origin. So the position of the top left corner of the blue square becomes x pixels from the left and y pixels from the top, at coordinate (x,y). Later in this tutorial we'll see how we can translate the origin to a different position, rotate the grid and even scale it, but for now we'll stick to the default.
## Drawing rectangles
Unlike {{Glossary("SVG")}}, {{HTMLElement("canvas")}} only supports two primitive shapes: rectangles and paths (lists of points connected by lines). All other shapes must be created by combining one or more paths. Luckily, we have an assortment of path drawing functions which make it possible to compose very complex shapes.
First let's look at the rectangle. There are three functions that draw rectangles on the canvas:
- {{domxref("CanvasRenderingContext2D.fillRect", "fillRect(x, y, width, height)")}}
- : Draws a filled rectangle.
- {{domxref("CanvasRenderingContext2D.strokeRect", "strokeRect(x, y, width, height)")}}
- : Draws a rectangular outline.
- {{domxref("CanvasRenderingContext2D.clearRect", "clearRect(x, y, width, height)")}}
- : Clears the specified rectangular area, making it fully transparent.
Each of these three functions takes the same parameters. `x` and `y` specify the position on the canvas (relative to the origin) of the top-left corner of the rectangle. `width` and `height` provide the rectangle's size.
Below is the `draw()` function from the previous page, but now it is making use of these three functions.
### Rectangular shape example
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
ctx.fillRect(25, 25, 100, 100);
ctx.clearRect(45, 45, 60, 60);
ctx.strokeRect(50, 50, 50, 50);
}
}
```
```js hidden
draw();
```
This example's output is shown below.
{{EmbedLiveSample("Rectangular_shape_example", 160, 160, "canvas_rect.png")}}
The `fillRect()` function draws a large black square 100 pixels on each side. The `clearRect()` function then erases a 60x60 pixel square from the center, and then `strokeRect()` is called to create a rectangular outline 50x50 pixels within the cleared square.
In upcoming pages we'll see two alternative methods for `clearRect()`, and we'll also see how to change the color and stroke style of the rendered shapes.
Unlike the path functions we'll see in the next section, all three rectangle functions draw immediately to the canvas.
## Drawing paths
Now let's look at paths. A path is a list of points, connected by segments of lines that can be of different shapes, curved or not, of different width and of different color. A path, or even a subpath, can be closed. To make shapes using paths, we take some extra steps:
1. First, you create the path.
2. Then you use [drawing commands](/en-US/docs/Web/API/CanvasRenderingContext2D#paths) to draw into the path.
3. Once the path has been created, you can stroke or fill the path to render it.
Here are the functions used to perform these steps:
- {{domxref("CanvasRenderingContext2D.beginPath", "beginPath()")}}
- : Creates a new path. Once created, future drawing commands are directed into the path and used to build the path up.
- [Path methods](/en-US/docs/Web/API/CanvasRenderingContext2D#paths)
- : Methods to set different paths for objects.
- {{domxref("CanvasRenderingContext2D.closePath", "closePath()")}}
- : Adds a straight line to the path, going to the start of the current sub-path.
- {{domxref("CanvasRenderingContext2D.stroke", "stroke()")}}
- : Draws the shape by stroking its outline.
- {{domxref("CanvasRenderingContext2D.fill", "fill()")}}
- : Draws a solid shape by filling the path's content area.
The first step to create a path is to call the `beginPath()`. Internally, paths are stored as a list of sub-paths (lines, arcs, etc.) which together form a shape. Every time this method is called, the list is reset and we can start drawing new shapes.
> **Note:** When the current path is empty, such as immediately after calling `beginPath()`, or on a newly created canvas, the first path construction command is always treated as a `moveTo()`, regardless of what it actually is. For that reason, you will almost always want to specifically set your starting position after resetting a path.
The second step is calling the methods that actually specify the paths to be drawn. We'll see these shortly.
The third, and an optional step, is to call `closePath()`. This method tries to close the shape by drawing a straight line from the current point to the start. If the shape has already been closed or there's only one point in the list, this function does nothing.
> **Note:** When you call `fill()`, any open shapes are closed automatically, so you don't have to call `closePath()`. This is **not** the case when you call `stroke()`.
### Drawing a triangle
For example, the code for drawing a triangle would look something like this:
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="100" height="100"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(75, 50);
ctx.lineTo(100, 75);
ctx.lineTo(100, 25);
ctx.fill();
}
}
```
```js hidden
draw();
```
The result looks like this:
{{EmbedLiveSample("Drawing_a_triangle", 110, 110, "triangle.png")}}
### Moving the pen
One very useful function, which doesn't actually draw anything but becomes part of the path list described above, is the `moveTo()` function. You can probably best think of this as lifting a pen or pencil from one spot on a piece of paper and placing it on the next.
- {{domxref("CanvasRenderingContext2D.moveTo", "moveTo(x, y)")}}
- : Moves the pen to the coordinates specified by `x` and `y`.
When the canvas is initialized or `beginPath()` is called, you typically will want to use the `moveTo()` function to place the starting point somewhere else. We could also use `moveTo()` to draw unconnected paths. Take a look at the smiley face below.
To try this for yourself, you can use the code snippet below. Just paste it into the `draw()` function we saw earlier.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc(75, 75, 50, 0, Math.PI * 2, true); // Outer circle
ctx.moveTo(110, 75);
ctx.arc(75, 75, 35, 0, Math.PI, false); // Mouth (clockwise)
ctx.moveTo(65, 65);
ctx.arc(60, 65, 5, 0, Math.PI * 2, true); // Left eye
ctx.moveTo(95, 65);
ctx.arc(90, 65, 5, 0, Math.PI * 2, true); // Right eye
ctx.stroke();
}
}
```
```js hidden
draw();
```
The result looks like this:
{{EmbedLiveSample("Moving_the_pen", 160, 160, "canvas_smiley.png")}}
If you'd like to see the connecting lines, you can remove the lines that call `moveTo()`.
> **Note:** To learn more about the `arc()` function, see the [Arcs](#arcs) section below.
### Lines
For drawing straight lines, use the `lineTo()` method.
- {{domxref("CanvasRenderingContext2D.lineTo", "lineTo(x, y)")}}
- : Draws a line from the current drawing position to the position specified by `x` and `y`.
This method takes two arguments, `x` and `y`, which are the coordinates of the line's end point. The starting point is dependent on previously drawn paths, where the end point of the previous path is the starting point for the following, etc. The starting point can also be changed by using the `moveTo()` method.
The example below draws two triangles, one filled and one outlined.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
// Filled triangle
ctx.beginPath();
ctx.moveTo(25, 25);
ctx.lineTo(105, 25);
ctx.lineTo(25, 105);
ctx.fill();
// Stroked triangle
ctx.beginPath();
ctx.moveTo(125, 125);
ctx.lineTo(125, 45);
ctx.lineTo(45, 125);
ctx.closePath();
ctx.stroke();
}
}
```
```js hidden
draw();
```
This starts by calling `beginPath()` to start a new shape path. We then use the `moveTo()` method to move the starting point to the desired position. Below this, two lines are drawn which make up two sides of the triangle.
{{EmbedLiveSample("Lines", 160, 160, "canvas_lineto.png")}}
You'll notice the difference between the filled and stroked triangle. This is, as mentioned above, because shapes are automatically closed when a path is filled, but not when they are stroked. If we left out the `closePath()` for the stroked triangle, only two lines would have been drawn, not a complete triangle.
### Arcs
To draw arcs or circles, we use the `arc()` or `arcTo()` methods.
- {{domxref("CanvasRenderingContext2D.arc", "arc(x, y, radius, startAngle, endAngle, counterclockwise)")}}
- : Draws an arc which is centered at _(x, y)_ position with radius _r_ starting at _startAngle_ and ending at _endAngle_ going in the given direction indicated by _counterclockwise_ (defaulting to clockwise).
- {{domxref("CanvasRenderingContext2D.arcTo", "arcTo(x1, y1, x2, y2, radius)")}}
- : Draws an arc with the given control points and radius, connected to the previous point by a straight line.
Let's have a more detailed look at the `arc` method, which takes six parameters: `x` and `y` are the coordinates of the center of the circle on which the arc should be drawn. `radius` is self-explanatory. The `startAngle` and `endAngle` parameters define the start and end points of the arc in radians, along the curve of the circle. These are measured from the x axis. The `counterclockwise` parameter is a Boolean value which, when `true`, draws the arc counterclockwise; otherwise, the arc is drawn clockwise.
> **Note:** Angles in the `arc` function are measured in radians, not degrees. To convert degrees to radians you can use the following JavaScript expression: `radians = (Math.PI/180)*degrees`.
The following example is a little more complex than the ones we've seen above. It draws 12 different arcs all with different angles and fills.
The two [`for` loops](/en-US/docs/Web/JavaScript/Reference/Statements/for) are for looping through the rows and columns of arcs. For each arc, we start a new path by calling `beginPath()`. In the code, each of the parameters for the arc is in a variable for clarity, but you wouldn't necessarily do that in real life.
The `x` and `y` coordinates should be clear enough. `radius` and `startAngle` are fixed. The `endAngle` starts at 180 degrees (half a circle) in the first column and is increased by steps of 90 degrees, culminating in a complete circle in the last column.
The statement for the `clockwise` parameter results in the first and third row being drawn as clockwise arcs and the second and fourth row as counterclockwise arcs. Finally, the `if` statement makes the top half stroked arcs and the bottom half filled arcs.
> **Note:** This example requires a slightly larger canvas than the others on this page: 150 x 200 pixels.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="200"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
for (let i = 0; i < 4; i++) {
for (let j = 0; j < 3; j++) {
ctx.beginPath();
const x = 25 + j * 50; // x coordinate
const y = 25 + i * 50; // y coordinate
const radius = 20; // Arc radius
const startAngle = 0; // Starting point on circle
const endAngle = Math.PI + (Math.PI * j) / 2; // End point on circle
const counterclockwise = i % 2 !== 0; // clockwise or counterclockwise
ctx.arc(x, y, radius, startAngle, endAngle, counterclockwise);
if (i > 1) {
ctx.fill();
} else {
ctx.stroke();
}
}
}
}
}
```
```js hidden
draw();
```
{{EmbedLiveSample("Arcs", 160, 210, "canvas_arc.png")}}
### Bezier and quadratic curves
The next type of paths available are [Bézier curves](/en-US/docs/Glossary/Bezier_curve), available in both cubic and quadratic varieties. These are generally used to draw complex organic shapes.
- {{domxref("CanvasRenderingContext2D.quadraticCurveTo", "quadraticCurveTo(cp1x, cp1y, x, y)")}}
- : Draws a quadratic Bézier curve from the current pen position to the end point specified by `x` and `y`, using the control point specified by `cp1x` and `cp1y`.
- {{domxref("CanvasRenderingContext2D.bezierCurveTo", "bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y)")}}
- : Draws a cubic Bézier curve from the current pen position to the end point specified by `x` and `y`, using the control points specified by (`cp1x`, `cp1y`) and (`cp2x`, `cp2y`).
The difference between these is that a quadratic Bézier curve has a start and an end point (blue dots) and just one **control point** (indicated by the red dot) while a cubic Bézier curve uses two control points.

The `x` and `y` parameters in both of these methods are the coordinates of the end point. `cp1x` and `cp1y` are the coordinates of the first control point, and `cp2x` and `cp2y` are the coordinates of the second control point.
Using quadratic and cubic Bézier curves can be quite challenging, because unlike vector drawing software like Adobe Illustrator, we don't have direct visual feedback as to what we're doing. This makes it pretty hard to draw complex shapes. In the following example, we'll be drawing some simple organic shapes, but if you have the time and, most of all, the patience, much more complex shapes can be created.
There's nothing very difficult in these examples. In both cases we see a succession of curves being drawn which finally result in a complete shape.
#### Quadratic Bezier curves
This example uses multiple quadratic Bézier curves to render a speech balloon.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
// Quadratic curves example
ctx.beginPath();
ctx.moveTo(75, 25);
ctx.quadraticCurveTo(25, 25, 25, 62.5);
ctx.quadraticCurveTo(25, 100, 50, 100);
ctx.quadraticCurveTo(50, 120, 30, 125);
ctx.quadraticCurveTo(60, 120, 65, 100);
ctx.quadraticCurveTo(125, 100, 125, 62.5);
ctx.quadraticCurveTo(125, 25, 75, 25);
ctx.stroke();
}
}
```
```js hidden
draw();
```
{{EmbedLiveSample("Quadratic_Bezier_curves", 160, 160, "canvas_quadratic.png")}}
#### Cubic Bezier curves
This example draws a heart using cubic Bézier curves.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
// Cubic curves example
ctx.beginPath();
ctx.moveTo(75, 40);
ctx.bezierCurveTo(75, 37, 70, 25, 50, 25);
ctx.bezierCurveTo(20, 25, 20, 62.5, 20, 62.5);
ctx.bezierCurveTo(20, 80, 40, 102, 75, 120);
ctx.bezierCurveTo(110, 102, 130, 80, 130, 62.5);
ctx.bezierCurveTo(130, 62.5, 130, 25, 100, 25);
ctx.bezierCurveTo(85, 25, 75, 37, 75, 40);
ctx.fill();
}
}
```
```js hidden
draw();
```
{{EmbedLiveSample("Cubic_Bezier_curves", 160, 160, "canvas_bezier.png")}}
### Rectangles
In addition to the three methods we saw in [Drawing rectangles](#drawing_rectangles), which draw rectangular shapes directly to the canvas, there's also the `rect()` method, which adds a rectangular path to a currently open path.
- {{domxref("CanvasRenderingContext2D.rect", "rect(x, y, width, height)")}}
- : Draws a rectangle whose top-left corner is specified by (`x`, `y`) with the specified `width` and `height`.
Before this method is executed, the `moveTo()` method is automatically called with the parameters (x,y). In other words, the current pen position is automatically reset to the default coordinates.
### Making combinations
So far, each example on this page has used only one type of path function per shape. However, there's no limitation to the number or types of paths you can use to create a shape. So in this final example, let's combine all of the path functions to make a set of very famous game characters.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
roundedRect(ctx, 12, 12, 150, 150, 15);
roundedRect(ctx, 19, 19, 150, 150, 9);
roundedRect(ctx, 53, 53, 49, 33, 10);
roundedRect(ctx, 53, 119, 49, 16, 6);
roundedRect(ctx, 135, 53, 49, 33, 10);
roundedRect(ctx, 135, 119, 25, 49, 10);
ctx.beginPath();
ctx.arc(37, 37, 13, Math.PI / 7, -Math.PI / 7, false);
ctx.lineTo(31, 37);
ctx.fill();
for (let i = 0; i < 8; i++) {
ctx.fillRect(51 + i * 16, 35, 4, 4);
}
for (let i = 0; i < 6; i++) {
ctx.fillRect(115, 51 + i * 16, 4, 4);
}
for (let i = 0; i < 8; i++) {
ctx.fillRect(51 + i * 16, 99, 4, 4);
}
ctx.beginPath();
ctx.moveTo(83, 116);
ctx.lineTo(83, 102);
ctx.bezierCurveTo(83, 94, 89, 88, 97, 88);
ctx.bezierCurveTo(105, 88, 111, 94, 111, 102);
ctx.lineTo(111, 116);
ctx.lineTo(106.333, 111.333);
ctx.lineTo(101.666, 116);
ctx.lineTo(97, 111.333);
ctx.lineTo(92.333, 116);
ctx.lineTo(87.666, 111.333);
ctx.lineTo(83, 116);
ctx.fill();
ctx.fillStyle = "white";
ctx.beginPath();
ctx.moveTo(91, 96);
ctx.bezierCurveTo(88, 96, 87, 99, 87, 101);
ctx.bezierCurveTo(87, 103, 88, 106, 91, 106);
ctx.bezierCurveTo(94, 106, 95, 103, 95, 101);
ctx.bezierCurveTo(95, 99, 94, 96, 91, 96);
ctx.moveTo(103, 96);
ctx.bezierCurveTo(100, 96, 99, 99, 99, 101);
ctx.bezierCurveTo(99, 103, 100, 106, 103, 106);
ctx.bezierCurveTo(106, 106, 107, 103, 107, 101);
ctx.bezierCurveTo(107, 99, 106, 96, 103, 96);
ctx.fill();
ctx.fillStyle = "black";
ctx.beginPath();
ctx.arc(101, 102, 2, 0, Math.PI * 2, true);
ctx.fill();
ctx.beginPath();
ctx.arc(89, 102, 2, 0, Math.PI * 2, true);
ctx.fill();
}
}
// A utility function to draw a rectangle with rounded corners.
function roundedRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x, y + radius);
ctx.arcTo(x, y + height, x + radius, y + height, radius);
ctx.arcTo(x + width, y + height, x + width, y + height - radius, radius);
ctx.arcTo(x + width, y, x + width - radius, y, radius);
ctx.arcTo(x, y, x, y + radius, radius);
ctx.stroke();
}
```
```js hidden
draw();
```
The resulting image looks like this:
{{EmbedLiveSample("Making_combinations", 160, 160, "combinations.png")}}
We won't go over this in detail, since it's actually surprisingly simple. The most important things to note are the use of the `fillStyle` property on the drawing context, and the use of a utility function (in this case `roundedRect()`). Using utility functions for bits of drawing you do often can be very helpful and reduce the amount of code you need, as well as its complexity.
We'll take another look at `fillStyle`, in more detail, later in this tutorial. Here, all we're doing is using it to change the fill color for paths from the default color of black to white, and then back again.
### Shapes with holes
To draw a shape with a hole in it, we need to draw the hole in different clock directions as we draw the outer shape. We either draw the outer shape clockwise and the inner shape anticlockwise or the outer shape clockwise and the inner shape anticlockwise.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
ctx.beginPath();
// Outter shape clockwise ⟳
ctx.moveTo(0, 0);
ctx.lineTo(150, 0);
ctx.lineTo(75, 129.9);
// Inner shape anticlockwise ↺
ctx.moveTo(75, 20);
ctx.lineTo(50, 60);
ctx.lineTo(100, 60);
ctx.fill();
}
}
```
```js hidden
draw();
```
{{EmbedLiveSample("Shapes_with_holes", 160, 160, "shape_with_hole.png")}}
In the example above the outer triangle goes clockwise (move to the top-left corner, then draw a line to the right-left corner, and finish at the bottom) and the inner triangle goes anticlockwise (move to the top, then line to the bottom-left corner, and finish at the bottom-right).
## Path2D objects
As we have seen in the last example, there can be a series of paths and drawing commands to draw objects onto your canvas. To simplify the code and to improve performance, the {{domxref("Path2D")}} object, available in recent versions of browsers, lets you cache or record these drawing commands. You are able to play back your paths quickly.
Let's see how we can construct a `Path2D` object:
- {{domxref("Path2D.Path2D", "Path2D()")}}
- : The **`Path2D()`** constructor returns a newly instantiated `Path2D` object, optionally with another path as an argument (creates a copy), or optionally with a string consisting of [SVG path](/en-US/docs/Web/SVG/Tutorial/Paths) data.
```js
new Path2D(); // empty path object
new Path2D(path); // copy from another Path2D object
new Path2D(d); // path from SVG path data
```
All [path methods](/en-US/docs/Web/API/CanvasRenderingContext2D#paths) like `moveTo`, `rect`, `arc` or `quadraticCurveTo`, etc., which we got to know above, are available on `Path2D` objects.
The `Path2D` API also adds a way to combine paths using the `addPath` method. This can be useful when you want to build objects from several components, for example.
- {{domxref("Path2D.addPath", "Path2D.addPath(path [, transform])")}}
- : Adds a path to the current path with an optional transformation matrix.
### Path2D example
In this example, we are creating a rectangle and a circle. Both are stored as a `Path2D` object, so that they are available for later usage. With the new `Path2D` API, several methods got updated to optionally accept a `Path2D` object to use instead of the current path. Here, `stroke` and `fill` are used with a path argument to draw both objects onto the canvas, for example.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="130" height="100"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
const rectangle = new Path2D();
rectangle.rect(10, 10, 50, 50);
const circle = new Path2D();
circle.arc(100, 35, 25, 0, 2 * Math.PI);
ctx.stroke(rectangle);
ctx.fill(circle);
}
}
```
```js hidden
draw();
```
{{EmbedLiveSample("Path2D_example", 130, 110, "path2d.png")}}
### Using SVG paths
Another powerful feature of the new canvas `Path2D` API is using [SVG path data](/en-US/docs/Web/SVG/Tutorial/Paths) to initialize paths on your canvas. This might allow you to pass around path data and re-use them in both, SVG and canvas.
The path will move to point (`M10 10`) and then move horizontally 80 points to the right (`h 80`), then 80 points down (`v 80`), then 80 points to the left (`h -80`), and then back to the start (`z`). You can see this example on the [`Path2D` constructor](/en-US/docs/Web/API/Path2D/Path2D#using_svg_paths) page.
```js
const p = new Path2D("M10 10 h 80 v 80 h -80 Z");
```
{{PreviousNext("Web/API/Canvas_API/Tutorial/Basic_usage", "Web/API/Canvas_API/Tutorial/Applying_styles_and_colors")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/drawing_text/index.md | ---
title: Drawing text
slug: Web/API/Canvas_API/Tutorial/Drawing_text
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Applying_styles_and_colors", "Web/API/Canvas_API/Tutorial/Using_images")}}
After having seen how to [apply styles and colors](/en-US/docs/Web/API/Canvas_API/Tutorial/Applying_styles_and_colors) in the previous chapter, we will now have a look at how to draw text onto the canvas.
## Drawing text
The canvas rendering context provides two methods to render text:
- {{domxref("CanvasRenderingContext2D.fillText", "fillText(text, x, y [, maxWidth])")}}
- : Fills a given text at the given (x,y) position. Optionally with a maximum width to draw.
- {{domxref("CanvasRenderingContext2D.strokeText", "strokeText(text, x, y [, maxWidth])")}}
- : Strokes a given text at the given (x,y) position. Optionally with a maximum width to draw.
### A `fillText` example
The text is filled using the current `fillStyle`.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.font = "48px serif";
ctx.fillText("Hello world", 10, 50);
}
```
```html hidden
<canvas id="canvas" width="300" height="100"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_fillText_example", 310, 110)}}
### A `strokeText` example
The text is filled using the current `strokeStyle`.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.font = "48px serif";
ctx.strokeText("Hello world", 10, 50);
}
```
```html hidden
<canvas id="canvas" width="300" height="100"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_strokeText_example", 310, 110)}}
## Styling text
In the examples above we are already making use of the `font` property to make the text a bit larger than the default size. There are some more properties which let you adjust the way the text gets displayed on the canvas:
- {{domxref("CanvasRenderingContext2D.font", "font = value")}}
- : The current text style being used when drawing text. This string uses the same syntax as the [CSS](/en-US/docs/Web/CSS) {{cssxref("font")}} property. The default font is 10px sans-serif.
- {{domxref("CanvasRenderingContext2D.textAlign", "textAlign = value")}}
- : Text alignment setting. Possible values: `start`, `end`, `left`, `right` or `center`. The default value is `start`.
- {{domxref("CanvasRenderingContext2D.textBaseline", "textBaseline = value")}}
- : Baseline alignment setting. Possible values: `top`, `hanging`, `middle`, `alphabetic`, `ideographic`, `bottom`. The default value is `alphabetic`.
- {{domxref("CanvasRenderingContext2D.direction", "direction = value")}}
- : Directionality. Possible values: `ltr`, `rtl`, `inherit`. The default value is `inherit`.
These properties might be familiar to you, if you have worked with CSS before.
The following diagram from the [WHATWG](https://whatwg.org/) demonstrates the various baselines supported by the `textBaseline` property.
### A textBaseline example
Edit the code below and see your changes update live in the canvas:
```html hidden
<canvas id="canvas" width="400" height="200" class="playable-canvas"></canvas>
<div class="playable-buttons">
<input id="edit" type="button" value="Edit" />
<input id="reset" type="button" value="Reset" />
</div>
<textarea id="code" class="playable-code">
ctx.font = "48px serif";
ctx.textBaseline = "hanging";
ctx.strokeText("Hello world", 0, 100);
</textarea>
```
```js hidden
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
const textarea = document.getElementById("code");
const reset = document.getElementById("reset");
const edit = document.getElementById("edit");
const code = textarea.value;
function drawCanvas() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
eval(textarea.value);
}
reset.addEventListener("click", () => {
textarea.value = code;
drawCanvas();
});
edit.addEventListener("click", () => {
textarea.focus();
});
textarea.addEventListener("input", drawCanvas);
window.addEventListener("load", drawCanvas);
```
{{ EmbedLiveSample('A_textBaseline_example', 700, 400) }}
## Advanced text measurements
In the case you need to obtain more details about the text, the following method allows you to measure it.
- {{domxref("CanvasRenderingContext2D.measureText", "measureText()")}}
- : Returns a {{domxref("TextMetrics")}} object containing the width, in pixels, that the specified text will be when drawn in the current text style.
The following code snippet shows how you can measure a text and get its width.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
const text = ctx.measureText("foo"); // TextMetrics object
text.width; // 16;
}
```
## Accessibility concerns
The `<canvas>` element is just a bitmap and does not provide information about any drawn objects. Text written on canvas can cause legibility issues with users relying on screen magnification. The pixels within a canvas element do not scale and can become blurry with magnification. This is because they are not a vector but letter-shaped collection of pixels. When zooming in on it, the pixels become bigger.
Canvas content is not exposed to accessibility tools like semantic HTML is. In general, you should avoid using canvas in an accessible website or app. An alternative is to use HTML elements or SVG instead of canvas.
## Gecko-specific notes
In Gecko (the rendering engine of Firefox, Firefox OS and other Mozilla based applications), some [prefixed APIs](/en-US/docs/Web/API/CanvasRenderingContext2D#prefixed_apis) were implemented in earlier versions to draw text on a canvas. These are now deprecated and removed, and are no longer guaranteed to work.
{{PreviousNext("Web/API/Canvas_API/Tutorial/Applying_styles_and_colors", "Web/API/Canvas_API/Tutorial/Using_images")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/transformations/index.md | ---
title: Transformations
slug: Web/API/Canvas_API/Tutorial/Transformations
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Using_images", "Web/API/Canvas_API/Tutorial/Compositing")}}
Earlier in this tutorial we've learned about the [canvas grid](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes) and the **coordinate space**. Until now, we only used the default grid and changed the size of the overall canvas for our needs. With transformations there are more powerful ways to translate the origin to a different position, rotate the grid and even scale it.
## Saving and restoring state
Before we look at the transformation methods, let's look at two other methods which are indispensable once you start generating ever more complex drawings.
- {{domxref("CanvasRenderingContext2D.save", "save()")}}
- : Saves the entire state of the canvas.
- {{domxref("CanvasRenderingContext2D.restore", "restore()")}}
- : Restores the most recently saved canvas state.
Canvas states are stored on a stack. Every time the `save()` method is called, the current drawing state is pushed onto the stack. A drawing state consists of
- The transformations that have been applied (i.e. `translate`, `rotate` and `scale` – see below).
- The current values of the following attributes:
- {{domxref("CanvasRenderingContext2D.strokeStyle", "strokeStyle")}}
- {{domxref("CanvasRenderingContext2D.fillStyle", "fillStyle")}}
- {{domxref("CanvasRenderingContext2D.globalAlpha", "globalAlpha")}}
- {{domxref("CanvasRenderingContext2D.lineWidth", "lineWidth")}}
- {{domxref("CanvasRenderingContext2D.lineCap", "lineCap")}}
- {{domxref("CanvasRenderingContext2D.lineJoin", "lineJoin")}}
- {{domxref("CanvasRenderingContext2D.miterLimit", "miterLimit")}}
- {{domxref("CanvasRenderingContext2D.lineDashOffset", "lineDashOffset")}}
- {{domxref("CanvasRenderingContext2D.shadowOffsetX", "shadowOffsetX")}}
- {{domxref("CanvasRenderingContext2D.shadowOffsetY", "shadowOffsetY")}}
- {{domxref("CanvasRenderingContext2D.shadowBlur", "shadowBlur")}}
- {{domxref("CanvasRenderingContext2D.shadowColor", "shadowColor")}}
- {{domxref("CanvasRenderingContext2D.globalCompositeOperation", "globalCompositeOperation")}}
- {{domxref("CanvasRenderingContext2D.font", "font")}}
- {{domxref("CanvasRenderingContext2D.textAlign", "textAlign")}}
- {{domxref("CanvasRenderingContext2D.textBaseline", "textBaseline")}}
- {{domxref("CanvasRenderingContext2D.direction", "direction")}}
- {{domxref("CanvasRenderingContext2D.imageSmoothingEnabled", "imageSmoothingEnabled")}}.
- The current [clipping path](/en-US/docs/Web/API/Canvas_API/Tutorial/Compositing#clipping_paths), which we'll see in the next section.
You can call the `save()` method as many times as you like. Each time the `restore()` method is called, the last saved state is popped off the stack and all saved settings are restored.
### A `save` and `restore` canvas state example
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.fillRect(0, 0, 150, 150); // Draw a Black rectangle with default settings
ctx.save(); // Save the original default state
ctx.fillStyle = "#09F"; // Make changes to saved settings
ctx.fillRect(15, 15, 120, 120); // Draw a Blue rectangle with new settings
ctx.save(); // Save the current state
ctx.fillStyle = "#FFF"; // Make changes to saved settings
ctx.globalAlpha = 0.5;
ctx.fillRect(30, 30, 90, 90); // Draw a 50%-White rectangle with newest settings
ctx.restore(); // Restore to previous state
ctx.fillRect(45, 45, 60, 60); // Draw a rectangle with restored Blue setting
ctx.restore(); // Restore to original state
ctx.fillRect(60, 60, 30, 30); // Draw a rectangle with restored Black setting
}
```
```html hidden
<canvas id="canvas" width="150" height="150"></canvas>
```
```js hidden
draw();
```
The first step is to draw a large rectangle with the default settings. Next we save this state and make changes to the fill color. We then draw the second and smaller blue rectangle and save the state. Again we change some drawing settings and draw the third semi-transparent white rectangle.
So far this is pretty similar to what we've done in previous sections. However once we call the first `restore()` statement, the top drawing state is removed from the stack, and settings are restored. If we hadn't saved the state using `save()`, we would need to change the fill color and transparency manually in order to return to the previous state. This would be easy for two properties, but if we have more than that, our code would become very long, very fast.
When the second `restore()` statement is called, the original state (the one we set up before the first call to `save`) is restored and the last rectangle is once again drawn in black.
{{EmbedLiveSample("A_save_and_restore_canvas_state_example", "180", "190", "canvas_savestate.png")}}
## Translating
The first of the transformation methods we'll look at is `translate()`. This method is used to move the canvas and its origin to a different point in the grid.
- {{domxref("CanvasRenderingContext2D.translate", "translate(x, y)")}}
- : Moves the canvas and its origin on the grid. `x` indicates the horizontal distance to move, and `y` indicates how far to move the grid vertically.

It's a good idea to save the canvas state before doing any transformations. In most cases, it is just easier to call the `restore` method than having to do a reverse translation to return to the original state. Also if you're translating inside a loop and don't save and restore the canvas state, you might end up missing part of your drawing, because it was drawn outside the canvas edge.
### A `translate` example
This example demonstrates some of the benefits of translating the canvas origin. Without the `translate()` method, all of the rectangles would be drawn at the same position (0,0). The `translate()` method also gives us the freedom to place the rectangle anywhere on the canvas without having to manually adjust coordinates in the `fillRect()` function. This makes it a little easier to understand and use.
In the `draw()` function, we call the `fillRect()` function nine times using two `for` loops. In each loop, the canvas is translated, the rectangle is drawn, and the canvas is returned back to its original state. Note how the call to `fillRect()` uses the same coordinates each time, relying on `translate()` to adjust the drawing position.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
for (let i = 0; i < 3; i++) {
for (let j = 0; j < 3; j++) {
ctx.save();
ctx.fillStyle = `rgb(${51 * i} ${255 - 51 * i} 255)`;
ctx.translate(10 + j * 50, 10 + i * 50);
ctx.fillRect(0, 0, 25, 25);
ctx.restore();
}
}
}
```
```html hidden
<canvas id="canvas" width="150" height="150"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_translate_example", "160", "190", "translate.png")}}
## Rotating
The second transformation method is `rotate()`. We use it to rotate the canvas around the current origin.
- {{domxref("CanvasRenderingContext2D.rotate", "rotate(angle)")}}
- : Rotates the canvas clockwise around the current origin by the `angle` number of radians.

The rotation center point is always the canvas origin. To change the center point, we will need to move the canvas by using the `translate()` method.
### A `rotate` example
In this example, we'll use the `rotate()` method to first rotate a rectangle from the canvas origin and then from the center of the rectangle itself with the help of `translate()`.
> **Note:** Angles are in radians, not degrees. To convert, we are using: `radians = (Math.PI/180)*degrees`.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// left rectangles, rotate from canvas origin
ctx.save();
// blue rect
ctx.fillStyle = "#0095DD";
ctx.fillRect(30, 30, 100, 100);
ctx.rotate((Math.PI / 180) * 25);
// grey rect
ctx.fillStyle = "#4D4E53";
ctx.fillRect(30, 30, 100, 100);
ctx.restore();
// right rectangles, rotate from rectangle center
// draw blue rect
ctx.fillStyle = "#0095DD";
ctx.fillRect(150, 30, 100, 100);
ctx.translate(200, 80); // translate to rectangle center
// x = x + 0.5 * width
// y = y + 0.5 * height
ctx.rotate((Math.PI / 180) * 25); // rotate
ctx.translate(-200, -80); // translate back
// draw grey rect
ctx.fillStyle = "#4D4E53";
ctx.fillRect(150, 30, 100, 100);
}
```
To rotate the rectangle around its own center, we translate the canvas to the center of the rectangle, then rotate the canvas, then translate the canvas back to 0,0, and then draw the rectangle.
```html hidden
<canvas id="canvas" width="300" height="200"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_rotate_example", "310", "260", "rotate.png")}}
## Scaling
The next transformation method is scaling. We use it to increase or decrease the units in our canvas grid. This can be used to draw scaled down or enlarged shapes and bitmaps.
- {{domxref("CanvasRenderingContext2D.scale", "scale(x, y)")}}
- : Scales the canvas units by x horizontally and by y vertically. Both parameters are real numbers. Values that are smaller than 1.0 reduce the unit size and values above 1.0 increase the unit size. Values of 1.0 leave the units the same size.
Using negative numbers you can do axis mirroring (for example using `translate(0,canvas.height); scale(1,-1);` you will have the well-known Cartesian coordinate system, with the origin in the bottom left corner).
By default, one unit on the canvas is exactly one pixel. If we apply, for instance, a scaling factor of 0.5, the resulting unit would become 0.5 pixels and so shapes would be drawn at half size. In a similar way setting the scaling factor to 2.0 would increase the unit size and one unit now becomes two pixels. This results in shapes being drawn twice as large.
### A `scale` example
In this last example, we'll draw shapes with different scaling factors.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// draw a simple rectangle, but scale it.
ctx.save();
ctx.scale(10, 3);
ctx.fillRect(1, 10, 10, 10);
ctx.restore();
// mirror horizontally
ctx.scale(-1, 1);
ctx.font = "48px serif";
ctx.fillText("MDN", -135, 120);
}
```
```html hidden
<canvas id="canvas" width="150" height="150"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_scale_example", "160", "190", "scale.png")}}
## Transforms
Finally, the following transformation methods allow modifications directly to the transformation matrix.
- {{domxref("CanvasRenderingContext2D.transform", "transform(a, b, c, d, e, f)")}}
- : Multiplies the current transformation matrix with the matrix described by its arguments. The transformation matrix is described by:
<math><semantics><mrow><mo>[</mo><mtable columnalign="center center center" rowspacing="0.5ex"><mtr><mtd><mi>a</mi></mtd><mtd><mi>c</mi></mtd><mtd><mi>e</mi></mtd></mtr><mtr><mtd><mi>b</mi></mtd><mtd><mi>d</mi></mtd><mtd><mi>f</mi></mtd></mtr><mtr><mtd><mn>0</mn></mtd><mtd><mn>0</mn></mtd><mtd><mn>1</mn></mtd></mtr></mtable><mo>]</mo></mrow><annotation encoding="TeX">\left[ \begin{array}{ccc} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{array} \right]</annotation></semantics></math>
If any of the arguments are [`Infinity`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity) the transformation matrix must be marked as infinite instead of the method throwing an exception.
The parameters of this function are:
- `a (m11)`
- : Horizontal scaling.
- `b (m12)`
- : Horizontal skewing.
- `c (m21)`
- : Vertical skewing.
- `d (m22)`
- : Vertical scaling.
- `e (dx)`
- : Horizontal moving.
- `f (dy)`
- : Vertical moving.
- {{domxref("CanvasRenderingContext2D.setTransform", "setTransform(a, b, c, d, e, f)")}}
- : Resets the current transform to the identity matrix, and then invokes the `transform()` method with the same arguments. This basically undoes the current transformation, then sets the specified transform, all in one step.
- {{domxref("CanvasRenderingContext2D.resetTransform", "resetTransform()")}}
- : Resets the current transform to the identity matrix. This is the same as calling: `ctx.setTransform(1, 0, 0, 1, 0, 0);`
### Example for `transform` and `setTransform`
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
const sin = Math.sin(Math.PI / 6);
const cos = Math.cos(Math.PI / 6);
ctx.translate(100, 100);
let c = 0;
for (let i = 0; i <= 12; i++) {
c = Math.floor((255 / 12) * i);
ctx.fillStyle = `rgb(${c} ${c} ${c})`;
ctx.fillRect(0, 0, 100, 10);
ctx.transform(cos, sin, -sin, cos, 0, 0);
}
ctx.setTransform(-1, 0, 0, 1, 100, 100);
ctx.fillStyle = "rgb(255 128 255 / 50%)";
ctx.fillRect(0, 50, 100, 100);
}
```
```html hidden
<canvas id="canvas" width="200" height="250"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("Example_for_transform_and_setTransform", "230", "290", "canvas_transform.png")}}
{{PreviousNext("Web/API/Canvas_API/Tutorial/Using_images", "Web/API/Canvas_API/Tutorial/Compositing")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/advanced_animations/index.md | ---
title: Advanced animations
slug: Web/API/Canvas_API/Tutorial/Advanced_animations
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Basic_animations", "Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas")}}
In the last chapter we made some [basic animations](/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations) and got to know ways to get things moving. In this part we will have a closer look at the motion itself and are going to add some physics to make our animations more advanced.
## Drawing a ball
We are going to use a ball for our animation studies, so let's first draw that ball onto the canvas. The following code will set us up.
```html
<canvas id="canvas" width="600" height="300"></canvas>
```
As usual, we need a drawing context first. To draw the ball, we will create a `ball` object which contains properties and a `draw()` method to paint it on the canvas.
```js
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
const ball = {
x: 100,
y: 100,
radius: 25,
color: "blue",
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fillStyle = this.color;
ctx.fill();
},
};
ball.draw();
```
Nothing special here, the ball is actually a simple circle and gets drawn with the help of the {{domxref("CanvasRenderingContext2D.arc()", "arc()")}} method.
## Adding velocity
Now that we have a ball, we are ready to add a basic animation like we have learned in the [last chapter](/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations) of this tutorial. Again, {{domxref("window.requestAnimationFrame()")}} helps us to control the animation. The ball gets moving by adding a velocity vector to the position. For each frame, we also {{domxref("CanvasRenderingContext2D.clearRect", "clear", "", 1)}} the canvas to remove old circles from prior frames.
```js
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
let raf;
const ball = {
x: 100,
y: 100,
vx: 5,
vy: 2,
radius: 25,
color: "blue",
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fillStyle = this.color;
ctx.fill();
},
};
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ball.draw();
ball.x += ball.vx;
ball.y += ball.vy;
raf = window.requestAnimationFrame(draw);
}
canvas.addEventListener("mouseover", (e) => {
raf = window.requestAnimationFrame(draw);
});
canvas.addEventListener("mouseout", (e) => {
window.cancelAnimationFrame(raf);
});
ball.draw();
```
## Boundaries
Without any boundary collision testing our ball runs out of the canvas quickly. We need to check if the `x` and `y` position of the ball is out of the canvas dimensions and invert the direction of the velocity vectors. To do so, we add the following checks to the `draw` method:
```js
if (
ball.y + ball.vy > canvas.height - ball.radius ||
ball.y + ball.vy < ball.radius
) {
ball.vy = -ball.vy;
}
if (
ball.x + ball.vx > canvas.width - ball.radius ||
ball.x + ball.vx < ball.radius
) {
ball.vx = -ball.vx;
}
```
### First demo
Let's see how it looks in action so far.
#### HTML
```html
<canvas id="canvas" style="border: 1px solid" width="600" height="300"></canvas>
```
#### JavaScript
```js
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
let raf;
const ball = {
x: 100,
y: 100,
vx: 5,
vy: 2,
radius: 25,
color: "blue",
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fillStyle = this.color;
ctx.fill();
},
};
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ball.draw();
ball.x += ball.vx;
ball.y += ball.vy;
if (
ball.y + ball.vy > canvas.height - ball.radius ||
ball.y + ball.vy < ball.radius
) {
ball.vy = -ball.vy;
}
if (
ball.x + ball.vx > canvas.width - ball.radius ||
ball.x + ball.vx < ball.radius
) {
ball.vx = -ball.vx;
}
raf = window.requestAnimationFrame(draw);
}
canvas.addEventListener("mouseover", (e) => {
raf = window.requestAnimationFrame(draw);
});
canvas.addEventListener("mouseout", (e) => {
window.cancelAnimationFrame(raf);
});
ball.draw();
```
#### Result
Move your mouse into the canvas to start the animation.
{{EmbedLiveSample("First_demo", "610", "340")}}
## Acceleration
To make the motion more real, you can play with the velocity like this, for example:
```js
ball.vy *= 0.99;
ball.vy += 0.25;
```
This slows down the vertical velocity each frame, so that the ball will just bounce on the floor in the end.
### Second demo
#### HTML
```html
<canvas id="canvas" style="border: 1px solid" width="600" height="300"></canvas>
```
#### JavaScript
```js
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
let raf;
const ball = {
x: 100,
y: 100,
vx: 5,
vy: 2,
radius: 25,
color: "blue",
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fillStyle = this.color;
ctx.fill();
},
};
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ball.draw();
ball.x += ball.vx;
ball.y += ball.vy;
ball.vy *= 0.99;
ball.vy += 0.25;
if (
ball.y + ball.vy > canvas.height - ball.radius ||
ball.y + ball.vy < ball.radius
) {
ball.vy = -ball.vy;
}
if (
ball.x + ball.vx > canvas.width - ball.radius ||
ball.x + ball.vx < ball.radius
) {
ball.vx = -ball.vx;
}
raf = window.requestAnimationFrame(draw);
}
canvas.addEventListener("mouseover", (e) => {
raf = window.requestAnimationFrame(draw);
});
canvas.addEventListener("mouseout", (e) => {
window.cancelAnimationFrame(raf);
});
ball.draw();
```
#### Result
{{EmbedLiveSample("Second_demo", "610", "340")}}
## Trailing effect
Until now we have made use of the {{domxref("CanvasRenderingContext2D.clearRect", "clearRect")}} method when clearing prior frames. If you replace this method with a semi-transparent {{domxref("CanvasRenderingContext2D.fillRect", "fillRect")}}, you can easily create a trailing effect.
```js
ctx.fillStyle = "rgb(255 255 255 / 30%)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
```
### Third demo
#### HTML
```html
<canvas id="canvas" style="border: 1px solid" width="600" height="300"></canvas>
```
#### JavaScript
```js
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
let raf;
const ball = {
x: 100,
y: 100,
vx: 5,
vy: 2,
radius: 25,
color: "blue",
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fillStyle = this.color;
ctx.fill();
},
};
function draw() {
ctx.fillStyle = "rgb(255 255 255 / 30%)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ball.draw();
ball.x += ball.vx;
ball.y += ball.vy;
ball.vy *= 0.99;
ball.vy += 0.25;
if (
ball.y + ball.vy > canvas.height - ball.radius ||
ball.y + ball.vy < ball.radius
) {
ball.vy = -ball.vy;
}
if (
ball.x + ball.vx > canvas.width - ball.radius ||
ball.x + ball.vx < ball.radius
) {
ball.vx = -ball.vx;
}
raf = window.requestAnimationFrame(draw);
}
canvas.addEventListener("mouseover", (e) => {
raf = window.requestAnimationFrame(draw);
});
canvas.addEventListener("mouseout", (e) => {
window.cancelAnimationFrame(raf);
});
ball.draw();
```
#### Result
{{EmbedLiveSample("Third_demo", "610", "340")}}
## Adding mouse control
To get some control over the ball, we can make it follow our mouse using the [`mousemove`](/en-US/docs/Web/API/Element/mousemove_event) event, for example. The [`click`](/en-US/docs/Web/API/Element/click_event) event releases the ball and lets it bounce again.
### Fourth demo
#### HTML
```html
<canvas id="canvas" style="border: 1px solid" width="600" height="300"></canvas>
```
#### JavaScript
```js
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
let raf;
let running = false;
const ball = {
x: 100,
y: 100,
vx: 5,
vy: 1,
radius: 25,
color: "blue",
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fillStyle = this.color;
ctx.fill();
},
};
function clear() {
ctx.fillStyle = "rgb(255 255 255 / 30%)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
function draw() {
clear();
ball.draw();
ball.x += ball.vx;
ball.y += ball.vy;
if (
ball.y + ball.vy > canvas.height - ball.radius ||
ball.y + ball.vy < ball.radius
) {
ball.vy = -ball.vy;
}
if (
ball.x + ball.vx > canvas.width - ball.radius ||
ball.x + ball.vx < ball.radius
) {
ball.vx = -ball.vx;
}
raf = window.requestAnimationFrame(draw);
}
canvas.addEventListener("mousemove", (e) => {
if (!running) {
clear();
ball.x = e.clientX;
ball.y = e.clientY;
ball.draw();
}
});
canvas.addEventListener("click", (e) => {
if (!running) {
raf = window.requestAnimationFrame(draw);
running = true;
}
});
canvas.addEventListener("mouseout", (e) => {
window.cancelAnimationFrame(raf);
running = false;
});
ball.draw();
```
#### Result
Move the ball using your mouse and release it with a click.
{{EmbedLiveSample("Fourth_demo", "610", "340")}}
## Breakout
This short chapter only explains some techniques to create more advanced animations. There are many more! How about adding a paddle, some bricks, and turn this demo into a [Breakout](https://en.wikipedia.org/wiki/Breakout_%28video_game%29) game? Check out our [Game development](/en-US/docs/Games) area for more gaming related articles.
## See also
- {{domxref("window.requestAnimationFrame()")}}
{{PreviousNext("Web/API/Canvas_API/Tutorial/Basic_animations", "Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/finale/index.md | ---
title: Finale
slug: Web/API/Canvas_API/Tutorial/Finale
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Optimizing_canvas")}}
Congratulations! You finished the [Canvas tutorial](/en-US/docs/Web/API/Canvas_API/Tutorial)! This knowledge will help you to make great 2D graphics on the web.
## More examples and tutorials
There are a variety of demos and further explanations about canvas on these sites:
- [Canvas Codepens](https://codepen.io/search/pens?q=canvas)
- : Front End Developer Playground & Code Editor in the Browser.
- [Canvas Tutorials](https://www.html5canvastutorials.com/)
- : Examples for most canvas APIs.
- [Game development](/en-US/docs/Games)
- : Gaming is one of the most popular computer activities. New technologies are constantly arriving to make it possible to develop better and more powerful games that can be run in any standards-compliant web browser.
## Other Web APIs
These APIs might be useful when working further with canvas and graphics:
- [WebGL](/en-US/docs/Web/API/WebGL_API)
- : Advanced API for rendering complex graphics, including 3D.
- [SVG](/en-US/docs/Web/SVG)
- : Scalable Vector Graphics let you describe images as sets of vectors (lines) and shapes in order to allow them to scale smoothly regardless of the size at which they're drawn.
- [Web Audio](/en-US/docs/Web/API/Web_Audio_API)
- : The Web Audio API provides a powerful and versatile system for controlling audio on the Web, allowing developers to choose audio sources, add effects to audio, create audio visualizations, apply spatial effects (such as panning) and much more.
## Questions
- [Stack Overflow](https://stackoverflow.com/questions/tagged/canvas)
- : Questions tagged with "canvas".
- [Comments about this tutorial – the MDN documentation community](/en-US/docs/MDN)
- : If you have any comments about this tutorial or want to thank us, feel free to reach out to us!
{{PreviousNext("Web/API/Canvas_API/Tutorial/Optimizing_canvas")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/optimizing_canvas/index.md | ---
title: Optimizing canvas
slug: Web/API/Canvas_API/Tutorial/Optimizing_canvas
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas", "Web/API/Canvas_API/Tutorial/Finale")}}
The {{HTMLElement("canvas")}} element is one of the most widely used tools for rendering 2D graphics on the web. However, when websites and apps push the Canvas API to its limits, performance begins to suffer. This article provides suggestions for optimizing your use of the canvas element to ensure that your graphics perform well.
## Performance tips
The following is a collection of tips to improve canvas performance.
### Pre-render similar primitives or repeating objects on an offscreen canvas
If you find yourself repeating some of the same drawing operations on each animation frame, consider offloading them to an offscreen canvas. You can then render the offscreen image to your primary canvas as often as needed, without unnecessarily repeating the steps needed to generate it in the first place.
```js
myCanvas.offscreenCanvas = document.createElement("canvas");
myCanvas.offscreenCanvas.width = myCanvas.width;
myCanvas.offscreenCanvas.height = myCanvas.height;
myCanvas.getContext("2d").drawImage(myCanvas.offScreenCanvas, 0, 0);
```
### Avoid floating-point coordinates and use integers instead
Sub-pixel rendering occurs when you render objects on a canvas without whole values.
```js
ctx.drawImage(myImage, 0.3, 0.5);
```
This forces the browser to do extra calculations to create the anti-aliasing effect. To avoid this, make sure to round all co-ordinates used in calls to {{domxref("CanvasRenderingContext2D.drawImage", "drawImage()")}} using {{jsxref("Math.floor()")}}, for example.
### Don't scale images in `drawImage`
Cache various sizes of your images on an offscreen canvas when loading as opposed to constantly scaling them in {{domxref("CanvasRenderingContext2D.drawImage", "drawImage()")}}.
### Use multiple layered canvases for complex scenes
In your application, you may find that some objects need to move or change frequently, while others remain relatively static. A possible optimization in this situation is to layer your items using multiple `<canvas>` elements.
For example, let's say you have a game with a UI on top, the gameplay action in the middle, and a static background on the bottom. In this case, you could split your game into three `<canvas>` layers. The UI would change only upon user input, the gameplay layer would change with every new frame, and the background would remain generally unchanged.
```html
<div id="stage">
<canvas id="ui-layer" width="480" height="320"></canvas>
<canvas id="game-layer" width="480" height="320"></canvas>
<canvas id="background-layer" width="480" height="320"></canvas>
</div>
<style>
#stage {
width: 480px;
height: 320px;
position: relative;
border: 2px solid black;
}
canvas {
position: absolute;
}
#ui-layer {
z-index: 3;
}
#game-layer {
z-index: 2;
}
#background-layer {
z-index: 1;
}
</style>
```
### Use plain CSS for large background images
If you have a static background image, you can draw it onto a plain {{HTMLElement("div")}} element using the CSS {{cssxref("background")}} property and position it under the canvas. This will negate the need to render the background to the canvas on every tick.
### Scaling canvas using CSS transforms
[CSS transforms](/en-US/docs/Web/CSS/CSS_transforms/Using_CSS_transforms) are faster since they use the GPU. The best case is to not scale the canvas, or have a smaller canvas and scale up rather than a bigger canvas and scale down.
```js
const scaleX = window.innerWidth / canvas.width;
const scaleY = window.innerHeight / canvas.height;
const scaleToFit = Math.min(scaleX, scaleY);
const scaleToCover = Math.max(scaleX, scaleY);
stage.style.transformOrigin = "0 0"; //scale from top left
stage.style.transform = `scale(${scaleToFit})`;
```
### Turn off transparency
If your application uses canvas and doesn't need a transparent backdrop, set the `alpha` option to `false` when creating a drawing context with {{domxref("HTMLCanvasElement.getContext()")}}. This information can be used internally by the browser to optimize rendering.
```js
const ctx = canvas.getContext("2d", { alpha: false });
```
### Scaling for high resolution displays
You may find that canvas items appear blurry on higher-resolution displays. While many solutions may exist, a simple first step is to scale the canvas size up and down simultaneously, using its attributes, styling, and its context's scale.
```js
// Get the DPR and size of the canvas
const dpr = window.devicePixelRatio;
const rect = canvas.getBoundingClientRect();
// Set the "actual" size of the canvas
canvas.width = rect.width * dpr;
canvas.height = rect.height * dpr;
// Scale the context to ensure correct drawing operations
ctx.scale(dpr, dpr);
// Set the "drawn" size of the canvas
canvas.style.width = `${rect.width}px`;
canvas.style.height = `${rect.height}px`;
```
### More tips
- Batch canvas calls together. For example, draw a polyline instead of multiple separate lines.
- Avoid unnecessary canvas state changes.
- Render screen differences only, not the whole new state.
- Avoid the {{domxref("CanvasRenderingContext2D.shadowBlur", "shadowBlur")}} property whenever possible.
- Avoid [text rendering](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text) whenever possible.
- Try different ways to clear the canvas ({{domxref("CanvasRenderingContext2D.clearRect", "clearRect()")}} vs. {{domxref("CanvasRenderingContext2D.fillRect", "fillRect()")}} vs. resizing the canvas).
- With animations, use {{domxref("window.requestAnimationFrame()")}} instead of {{domxref("setInterval()")}} .
- Be careful with heavy physics libraries.
## See also
- [Optimizing your JavaScript game for Firefox OS – Mozilla Hacks](https://hacks.mozilla.org/2013/05/optimizing-your-javascript-game-for-firefox-os/)
{{PreviousNext("Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas", "Web/API/Canvas_API/Tutorial/Finale")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/applying_styles_and_colors/index.md | ---
title: Applying styles and colors
slug: Web/API/Canvas_API/Tutorial/Applying_styles_and_colors
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Drawing_shapes", "Web/API/Canvas_API/Tutorial/Drawing_text")}}
In the chapter about [drawing shapes](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes), we used only the default line and fill styles. Here we will explore the canvas options we have at our disposal to make our drawings a little more attractive. You will learn how to add different colors, line styles, gradients, patterns and shadows to your drawings.
> **Note:** Canvas content is not accessible to screen readers. If the canvas is purely decorative, include `role="presentation"` on the `<canvas>` opening tag. Otherwise, include descriptive text as the value of the [`aria-label`](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label) attribute directly on the canvas element itself or include fallback content placed within the opening and closing canvas tag. Canvas content is not part of the DOM, but nested fallback content is.
## Colors
Up until now we have only seen methods of the drawing context. If we want to apply colors to a shape, there are two important properties we can use: `fillStyle` and `strokeStyle`.
- {{domxref("CanvasRenderingContext2D.fillStyle", "fillStyle = color")}}
- : Sets the style used when filling shapes.
- {{domxref("CanvasRenderingContext2D.strokeStyle", "strokeStyle = color")}}
- : Sets the style for shapes' outlines.
`color` is a string representing a CSS {{cssxref("<color>")}}, a gradient object, or a pattern object. We'll look at gradient and pattern objects later. By default, the stroke and fill color are set to black (CSS color value `#000000`).
> **Note:** When you set the `strokeStyle` and/or `fillStyle` property, the new value becomes the default for all shapes being drawn from then on. For every shape you want in a different color, you will need to reassign the `fillStyle` or `strokeStyle` property.
The valid strings you can enter should, according to the specification, be CSS {{cssxref("<color>")}} values. Each of the following examples describe the same color.
```js
// these all set the fillStyle to 'orange'
ctx.fillStyle = "orange";
ctx.fillStyle = "#FFA500";
ctx.fillStyle = "rgb(255 165 0)";
ctx.fillStyle = "rgb(255 165 0 / 100%)";
```
### A `fillStyle` example
In this example, we once again use two `for` loops to draw a grid of rectangles, each in a different color. The resulting image should look something like the screenshot. There is nothing too spectacular happening here. We use the two variables `i` and `j` to generate a unique RGB color for each square, and only modify the red and green values. The blue channel has a fixed value. By modifying the channels, you can generate all kinds of palettes. By increasing the steps, you can achieve something that looks like the color palettes Photoshop uses.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
for (let i = 0; i < 6; i++) {
for (let j = 0; j < 6; j++) {
ctx.fillStyle = `rgb(${Math.floor(255 - 42.5 * i)} ${Math.floor(
255 - 42.5 * j,
)} 0)`;
ctx.fillRect(j * 25, i * 25, 25, 25);
}
}
}
```
```html hidden
<canvas id="canvas" width="150" height="150"
>A 6 by 6 square grid displaying 36 different colors</canvas
>
```
```js hidden
draw();
```
The result looks like this:
{{EmbedLiveSample("A_fillStyle_example", 160, 160, "canvas_fillstyle.png")}}
### A `strokeStyle` example
This example is similar to the one above, but uses the `strokeStyle` property to change the colors of the shapes' outlines. We use the `arc()` method to draw circles instead of squares.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
for (let i = 0; i < 6; i++) {
for (let j = 0; j < 6; j++) {
ctx.strokeStyle = `rgb(0 ${Math.floor(255 - 42.5 * i)} ${Math.floor(
255 - 42.5 * j,
)})`;
ctx.beginPath();
ctx.arc(12.5 + j * 25, 12.5 + i * 25, 10, 0, 2 * Math.PI, true);
ctx.stroke();
}
}
}
```
```html hidden
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
```
```js hidden
draw();
```
The result looks like this:
{{EmbedLiveSample("A_strokeStyle_example", "180", "180", "canvas_strokestyle.png")}}
## Transparency
In addition to drawing opaque shapes to the canvas, we can also draw semi-transparent (or translucent) shapes. This is done by either setting the `globalAlpha` property or by assigning a semi-transparent color to the stroke and/or fill style.
- {{domxref("CanvasRenderingContext2D.globalAlpha", "globalAlpha = transparencyValue")}}
- : Applies the specified transparency value to all future shapes drawn on the canvas. The value must be between 0.0 (fully transparent) to 1.0 (fully opaque). This value is 1.0 (fully opaque) by default.
The `globalAlpha` property can be useful if you want to draw a lot of shapes on the canvas with similar transparency, but otherwise it's generally more useful to set the transparency on individual shapes when setting their colors.
Because the `strokeStyle` and `fillStyle` properties accept CSS rgb color values, we can use the following notation to assign a transparent color to them.
```js
// Assigning transparent colors to stroke and fill style
ctx.strokeStyle = "rgb(255 0 0 / 50%)";
ctx.fillStyle = "rgb(255 0 0 / 50%)";
```
The `rgb()` function has an optional extra parameter. The last parameter sets the transparency value of this particular color. The valid range is specified as a percentage between `0%` (fully transparent) and `100%` (fully opaque) or as a number between `0.0` (equivalent to `0%`) and `1.0` (equivalent to `100%`).
### A `globalAlpha` example
In this example, we'll draw a background of four different colored squares. On top of these, we'll draw a set of semi-transparent circles. The `globalAlpha` property is set at `0.2` which will be used for all shapes from that point on. Every step in the `for` loop draws a set of circles with an increasing radius. The final result is a radial gradient. By overlaying ever more circles on top of each other, we effectively reduce the transparency of the circles that have already been drawn. By increasing the step count and in effect drawing more circles, the background would completely disappear from the center of the image.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// draw background
ctx.fillStyle = "#FD0";
ctx.fillRect(0, 0, 75, 75);
ctx.fillStyle = "#6C0";
ctx.fillRect(75, 0, 75, 75);
ctx.fillStyle = "#09F";
ctx.fillRect(0, 75, 75, 75);
ctx.fillStyle = "#F30";
ctx.fillRect(75, 75, 75, 75);
ctx.fillStyle = "#FFF";
// set transparency value
ctx.globalAlpha = 0.2;
// Draw semi transparent circles
for (let i = 0; i < 7; i++) {
ctx.beginPath();
ctx.arc(75, 75, 10 + 10 * i, 0, Math.PI * 2, true);
ctx.fill();
}
}
```
```html hidden
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_globalAlpha_example", "180", "180", "canvas_globalalpha.png")}}
### An example using `rgb()` with alpha transparency
In this second example, we do something similar to the one above, but instead of drawing circles on top of each other, I've drawn small rectangles with increasing opacity. Using `rgb()` gives you a little more control and flexibility because we can set the fill and stroke style individually.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// Draw background
ctx.fillStyle = "rgb(255 221 0)";
ctx.fillRect(0, 0, 150, 37.5);
ctx.fillStyle = "rgb(102 204 0)";
ctx.fillRect(0, 37.5, 150, 37.5);
ctx.fillStyle = "rgb(0 153 255)";
ctx.fillRect(0, 75, 150, 37.5);
ctx.fillStyle = "rgb(255 51 0)";
ctx.fillRect(0, 112.5, 150, 37.5);
// Draw semi transparent rectangles
for (let i = 0; i < 10; i++) {
ctx.fillStyle = `rgb(255 255 255 / ${(i + 1) / 10})`;
for (let j = 0; j < 4; j++) {
ctx.fillRect(5 + i * 14, 5 + j * 37.5, 14, 27.5);
}
}
}
```
```html hidden
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("An_example_using_rgb_with_alpha_transparency", "180", "180", "canvas_rgb.png")}}
## Line styles
There are several properties which allow us to style lines.
- {{domxref("CanvasRenderingContext2D.lineWidth", "lineWidth = value")}}
- : Sets the width of lines drawn in the future.
- {{domxref("CanvasRenderingContext2D.lineCap", "lineCap = type")}}
- : Sets the appearance of the ends of lines.
- {{domxref("CanvasRenderingContext2D.lineJoin", "lineJoin = type")}}
- : Sets the appearance of the "corners" where lines meet.
- {{domxref("CanvasRenderingContext2D.miterLimit", "miterLimit = value")}}
- : Establishes a limit on the miter when two lines join at a sharp angle, to let you control how thick the junction becomes.
- {{domxref("CanvasRenderingContext2D.getLineDash", "getLineDash()")}}
- : Returns the current line dash pattern array containing an even number of non-negative numbers.
- {{domxref("CanvasRenderingContext2D.setLineDash", "setLineDash(segments)")}}
- : Sets the current line dash pattern.
- {{domxref("CanvasRenderingContext2D.lineDashOffset", "lineDashOffset = value")}}
- : Specifies where to start a dash array on a line.
You'll get a better understanding of what these do by looking at the examples below.
### A `lineWidth` example
This property sets the current line thickness. Values must be positive numbers. By default this value is set to 1.0 units.
The line width is the thickness of the stroke centered on the given path. In other words, the area that's drawn extends to half the line width on either side of the path. Because canvas coordinates do not directly reference pixels, special care must be taken to obtain crisp horizontal and vertical lines.
In the example below, 10 straight lines are drawn with increasing line widths. The line on the far left is 1.0 units wide. However, the leftmost and all other odd-integer-width thickness lines do not appear crisp, because of the path's positioning.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
for (let i = 0; i < 10; i++) {
ctx.lineWidth = 1 + i;
ctx.beginPath();
ctx.moveTo(5 + i * 14, 5);
ctx.lineTo(5 + i * 14, 140);
ctx.stroke();
}
}
```
```html hidden
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_lineWidth_example", "180", "180", "canvas_linewidth.png")}}
Obtaining crisp lines requires understanding how paths are stroked. In the images below, the grid represents the canvas coordinate grid. The squares between gridlines are actual on-screen pixels. In the first grid image below, a rectangle from (2,1) to (5,5) is filled. The entire area between them (light red) falls on pixel boundaries, so the resulting filled rectangle will have crisp edges.

If you consider a path from (3,1) to (3,5) with a line thickness of `1.0`, you end up with the situation in the second image. The actual area to be filled (dark blue) only extends halfway into the pixels on either side of the path. An approximation of this has to be rendered, which means that those pixels being only partially shaded, and results in the entire area (the light blue and dark blue) being filled in with a color only half as dark as the actual stroke color. This is what happens with the `1.0` width line in the previous example code.
To fix this, you have to be very precise in your path creation. Knowing that a `1.0` width line will extend half a unit to either side of the path, creating the path from (3.5,1) to (3.5,5) results in the situation in the third image—the `1.0` line width ends up completely and precisely filling a single pixel vertical line.
> **Note:** Be aware that in our vertical line example, the Y position still referenced an integer gridline position—if it hadn't, we would see pixels with half coverage at the endpoints (but note also that this behavior depends on the current `lineCap` style whose default value is `butt`; you may want to compute consistent strokes with half-pixel coordinates for odd-width lines, by setting the `lineCap` style to `square`, so that the outer border of the stroke around the endpoint will be automatically extended to cover the whole pixel exactly).
>
> Note also that only start and final endpoints of a path are affected: if a path is closed with `closePath()`, there's no start and final endpoint; instead, all endpoints in the path are connected to their attached previous and next segment using the current setting of the `lineJoin` style, whose default value is `miter`, with the effect of automatically extending the outer borders of the connected segments to their intersection point, so that the rendered stroke will exactly cover full pixels centered at each endpoint if those connected segments are horizontal and/or vertical. See the next two sections for demonstrations of these additional line styles.
For even-width lines, each half ends up being an integer amount of pixels, so you want a path that is between pixels (that is, (3,1) to (3,5)), instead of down the middle of pixels.
While slightly painful when initially working with scalable 2D graphics, paying attention to the pixel grid and the position of paths ensures that your drawings will look correct regardless of scaling or any other transformations involved. A 1.0-width vertical line drawn at the correct position will become a crisp 2-pixel line when scaled up by 2, and will appear at the correct position.
### A `lineCap` example
The `lineCap` property determines how the end points of every line are drawn. There are three possible values for this property and those are: `butt`, `round` and `square`. By default this property is set to `butt`:
- `butt`
- : The ends of lines are squared off at the endpoints.
- `round`
- : The ends of lines are rounded.
- `square`
- : The ends of lines are squared off by adding a box with an equal width and half the height of the line's thickness.
In this example, we'll draw three lines, each with a different value for the `lineCap` property. I also added two guides to see the exact differences between the three. Each of these lines starts and ends exactly on these guides.
The line on the left uses the default `butt` option. You'll notice that it's drawn completely flush with the guides. The second is set to use the `round` option. This adds a semicircle to the end that has a radius half the width of the line. The line on the right uses the `square` option. This adds a box with an equal width and half the height of the line thickness.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// Draw guides
ctx.strokeStyle = "#09f";
ctx.beginPath();
ctx.moveTo(10, 10);
ctx.lineTo(140, 10);
ctx.moveTo(10, 140);
ctx.lineTo(140, 140);
ctx.stroke();
// Draw lines
ctx.strokeStyle = "black";
["butt", "round", "square"].forEach((lineCap, i) => {
ctx.lineWidth = 15;
ctx.lineCap = lineCap;
ctx.beginPath();
ctx.moveTo(25 + i * 50, 10);
ctx.lineTo(25 + i * 50, 140);
ctx.stroke();
});
}
```
```html hidden
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_lineCap_example", "180", "180", "Canvas_linecap.png")}}
### A `lineJoin` example
The `lineJoin` property determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together (degenerate segments with zero lengths, whose specified endpoints and control points are exactly at the same position, are skipped).
There are three possible values for this property: `round`, `bevel` and `miter`. By default this property is set to `miter`. Note that the `lineJoin` setting has no effect if the two connected segments have the same direction, because no joining area will be added in this case:
- `round`
- : Rounds off the corners of a shape by filling an additional sector of disc centered at the common endpoint of connected segments. The radius for these rounded corners is equal to half the line width.
- `bevel`
- : Fills an additional triangular area between the common endpoint of connected segments, and the separate outside rectangular corners of each segment.
- `miter`
- : Connected segments are joined by extending their outside edges to connect at a single point, with the effect of filling an additional lozenge-shaped area. This setting is effected by the `miterLimit` property which is explained below.
The example below draws three different paths, demonstrating each of these three `lineJoin` property settings; the output is shown above.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.lineWidth = 10;
["round", "bevel", "miter"].forEach((lineJoin, i) => {
ctx.lineJoin = lineJoin;
ctx.beginPath();
ctx.moveTo(-5, 5 + i * 40);
ctx.lineTo(35, 45 + i * 40);
ctx.lineTo(75, 5 + i * 40);
ctx.lineTo(115, 45 + i * 40);
ctx.lineTo(155, 5 + i * 40);
ctx.stroke();
});
}
```
```html hidden
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_lineJoin_example", "180", "180", "Canvas_linejoin.png")}}
### A demo of the `miterLimit` property
As you've seen in the previous example, when joining two lines with the `miter` option, the outside edges of the two joining lines are extended up to the point where they meet. For lines which are at large angles with each other, this point is not far from the inside connection point. However, as the angles between each line decrease, the distance (miter length) between these points increases exponentially.
The `miterLimit` property determines how far the outside connection point can be placed from the inside connection point. If two lines exceed this value, a bevel join gets drawn instead. Note that the maximum miter length is the product of the line width measured in the current coordinate system, by the value of this `miterLimit` property (whose default value is 10.0 in the HTML {{HTMLElement("canvas")}}), so the `miterLimit` can be set independently from the current display scale or any affine transforms of paths: it only influences the effectively rendered shape of line edges.
More exactly, the miter limit is the maximum allowed ratio of the extension length (in the HTML canvas, it is measured between the outside corner of the joined edges of the line and the common endpoint of connecting segments specified in the path) to half the line width. It can equivalently be defined as the maximum allowed ratio of the distance between the inside and outside points of junction of edges, to the total line width. It is then equal to the cosecant of half the minimum inner angle of connecting segments below which no miter join will be rendered, but only a bevel join:
- `miterLimit` = **max** `miterLength` / `lineWidth` = 1 / **sin** ( **min** _θ_ / 2 )
- The default miter limit of 10.0 will strip all miters for sharp angles below about 11 degrees.
- A miter limit equal to √2 ≈ 1.4142136 (rounded up) will strip miters for all acute angles, keeping miter joins only for obtuse or right angles.
- A miter limit equal to 1.0 is valid but will disable all miters.
- Values below 1.0 are invalid for the miter limit.
Here's a little demo in which you can set `miterLimit` dynamically and see how this effects the shapes on the canvas. The blue lines show where the start and endpoints for each of the lines in the zig-zag pattern are.
If you specify a `miterLimit` value below 4.2 in this demo, none of the visible corners will join with a miter extension, but only with a small bevel near the blue lines; with a `miterLimit` above 10, most corners in this demo should join with a miter far away from the blue lines, and whose height is decreasing between corners from left to right because they connect with growing angles; with intermediate values, the corners on the left side will only join with a bevel near the blue lines, and the corners on the right side with a miter extension (also with a decreasing height).
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// Clear canvas
ctx.clearRect(0, 0, 150, 150);
// Draw guides
ctx.strokeStyle = "#09f";
ctx.lineWidth = 2;
ctx.strokeRect(-5, 50, 160, 50);
// Set line styles
ctx.strokeStyle = "#000";
ctx.lineWidth = 10;
// check input
if (document.getElementById("miterLimit").value.match(/\d+(\.\d+)?/)) {
ctx.miterLimit = parseFloat(document.getElementById("miterLimit").value);
} else {
alert("Value must be a positive number");
}
// Draw lines
ctx.beginPath();
ctx.moveTo(0, 100);
for (let i = 0; i < 24; i++) {
const dy = i % 2 === 0 ? 25 : -25;
ctx.lineTo(Math.pow(i, 1.5) * 2, 75 + dy);
}
ctx.stroke();
return false;
}
```
```html hidden
<table>
<tr>
<td>
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
</td>
<td>
Change the <code>miterLimit</code> by entering a new value below and
clicking the redraw button.<br /><br />
<form onsubmit="return draw();">
<label for="miterLimit">Miter limit</label>
<input type="number" size="3" id="miterLimit" />
<input type="submit" value="Redraw" />
</form>
</td>
</tr>
</table>
```
```js hidden
document.getElementById("miterLimit").value = document
.getElementById("canvas")
.getContext("2d").miterLimit;
draw();
```
{{EmbedLiveSample("A_demo_of_the_miterLimit_property", "400", "180", "canvas_miterlimit.png")}}
### Using line dashes
The `setLineDash` method and the `lineDashOffset` property specify the dash pattern for lines. The `setLineDash` method accepts a list of numbers that specifies distances to alternately draw a line and a gap and the `lineDashOffset` property sets an offset where to start the pattern.
In this example we are creating a marching ants effect. It is an animation technique often found in selection tools of computer graphics programs. It helps the user to distinguish the selection border from the image background by animating the border. In a later part of this tutorial, you can learn how to do this and other [basic animations](/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations).
```html hidden
<canvas id="canvas" width="111" height="111" role="presentation"></canvas>
```
```js
const ctx = document.getElementById("canvas").getContext("2d");
let offset = 0;
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.setLineDash([4, 2]);
ctx.lineDashOffset = -offset;
ctx.strokeRect(10, 10, 100, 100);
}
function march() {
offset++;
if (offset > 5) {
offset = 0;
}
draw();
setTimeout(march, 20);
}
march();
```
{{EmbedLiveSample("Using_line_dashes", "120", "120", "marching-ants.png")}}
## Gradients
Just like any normal drawing program, we can fill and stroke shapes using linear, radial and conic gradients. We create a {{domxref("CanvasGradient")}} object by using one of the following methods. We can then assign this object to the `fillStyle` or `strokeStyle` properties.
- {{domxref("CanvasRenderingContext2D.createLinearGradient", "createLinearGradient(x1, y1, x2, y2)")}}
- : Creates a linear gradient object with a starting point of (`x1`, `y1`) and an end point of (`x2`, `y2`).
- {{domxref("CanvasRenderingContext2D.createRadialGradient", "createRadialGradient(x1, y1, r1, x2, y2, r2)")}}
- : Creates a radial gradient. The parameters represent two circles, one with its center at (`x1`, `y1`) and a radius of `r1`, and the other with its center at (`x2`, `y2`) with a radius of `r2`.
- {{domxref("CanvasRenderingContext2D.createConicGradient", "createConicGradient(angle, x, y)")}}
- : Creates a conic gradient object with a starting angle of `angle` in radians, at the position (`x`, `y`).
For example:
```js
const lineargradient = ctx.createLinearGradient(0, 0, 150, 150);
const radialgradient = ctx.createRadialGradient(75, 75, 0, 75, 75, 100);
```
Once we've created a `CanvasGradient` object we can assign colors to it by using the `addColorStop()` method.
- {{domxref("CanvasGradient.addColorStop", "gradient.addColorStop(position, color)")}}
- : Creates a new color stop on the `gradient` object. The `position` is a number between 0.0 and 1.0 and defines the relative position of the color in the gradient, and the `color` argument must be a string representing a CSS {{cssxref("<color>")}}, indicating the color the gradient should reach at that offset into the transition.
You can add as many color stops to a gradient as you need. Below is a very simple linear gradient from white to black.
```js
const lineargradient = ctx.createLinearGradient(0, 0, 150, 150);
lineargradient.addColorStop(0, "white");
lineargradient.addColorStop(1, "black");
```
### A `createLinearGradient` example
In this example, we'll create two different gradients. As you can see here, both the `strokeStyle` and `fillStyle` properties can accept a `canvasGradient` object as valid input.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// Create gradients
const lingrad = ctx.createLinearGradient(0, 0, 0, 150);
lingrad.addColorStop(0, "#00ABEB");
lingrad.addColorStop(0.5, "#fff");
lingrad.addColorStop(0.5, "#26C000");
lingrad.addColorStop(1, "#fff");
const lingrad2 = ctx.createLinearGradient(0, 50, 0, 95);
lingrad2.addColorStop(0.5, "#000");
lingrad2.addColorStop(1, "rgb(0 0 0 / 0%)");
// assign gradients to fill and stroke styles
ctx.fillStyle = lingrad;
ctx.strokeStyle = lingrad2;
// draw shapes
ctx.fillRect(10, 10, 130, 130);
ctx.strokeRect(50, 50, 50, 50);
}
```
```html hidden
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
```
```js hidden
draw();
```
The first is a background gradient. As you can see, we assigned two colors at the same position. You do this to make very sharp color transitions—in this case from white to green. Normally, it doesn't matter in what order you define the color stops, but in this special case, it does significantly. If you keep the assignments in the order you want them to appear, this won't be a problem.
In the second gradient, we didn't assign the starting color (at position 0.0) since it wasn't strictly necessary, because it will automatically assume the color of the next color stop. Therefore, assigning the black color at position 0.5 automatically makes the gradient, from the start to this stop, black.
{{EmbedLiveSample("A_createLinearGradient_example", "180", "180", "canvas_lineargradient.png")}}
### A `createRadialGradient` example
In this example, we'll define four different radial gradients. Because we have control over the start and closing points of the gradient, we can achieve more complex effects than we would normally have in the "classic" radial gradients we see in, for instance, Photoshop (that is, a gradient with a single center point where the gradient expands outward in a circular shape).
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// Create gradients
const radgrad = ctx.createRadialGradient(45, 45, 10, 52, 50, 30);
radgrad.addColorStop(0, "#A7D30C");
radgrad.addColorStop(0.9, "#019F62");
radgrad.addColorStop(1, "rgb(1 159 98 / 0%)");
const radgrad2 = ctx.createRadialGradient(105, 105, 20, 112, 120, 50);
radgrad2.addColorStop(0, "#FF5F98");
radgrad2.addColorStop(0.75, "#FF0188");
radgrad2.addColorStop(1, "rgb(255 1 136 / 0%)");
const radgrad3 = ctx.createRadialGradient(95, 15, 15, 102, 20, 40);
radgrad3.addColorStop(0, "#00C9FF");
radgrad3.addColorStop(0.8, "#00B5E2");
radgrad3.addColorStop(1, "rgb(0 201 255 / 0%)");
const radgrad4 = ctx.createRadialGradient(0, 150, 50, 0, 140, 90);
radgrad4.addColorStop(0, "#F4F201");
radgrad4.addColorStop(0.8, "#E4C700");
radgrad4.addColorStop(1, "rgb(228 199 0 / 0%)");
// draw shapes
ctx.fillStyle = radgrad4;
ctx.fillRect(0, 0, 150, 150);
ctx.fillStyle = radgrad3;
ctx.fillRect(0, 0, 150, 150);
ctx.fillStyle = radgrad2;
ctx.fillRect(0, 0, 150, 150);
ctx.fillStyle = radgrad;
ctx.fillRect(0, 0, 150, 150);
}
```
```html hidden
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
```
```js hidden
draw();
```
In this case, we've offset the starting point slightly from the end point to achieve a spherical 3D effect. It's best to try to avoid letting the inside and outside circles overlap because this results in strange effects which are hard to predict.
The last color stop in each of the four gradients uses a fully transparent color. If you want to have a nice transition from this to the previous color stop, both colors should be equal. This isn't very obvious from the code because it uses two different CSS color methods as a demonstration, but in the first gradient `#019F62 = rgb(1 159 98 / 100%)`.
{{EmbedLiveSample("A_createRadialGradient_example", "180", "180", "canvas_radialgradient.png")}}
### A `createConicGradient` example
In this example, we'll define two different conic gradients. A conic gradient differs from a radial gradient as, instead of creating circles, it circles around a point.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// Create gradients
const conicGrad1 = ctx.createConicGradient(2, 62, 75);
conicGrad1.addColorStop(0, "#A7D30C");
conicGrad1.addColorStop(1, "#fff");
const conicGrad2 = ctx.createConicGradient(0, 187, 75);
// we multiply our values by Math.PI/180 to convert degrees to radians
conicGrad2.addColorStop(0, "black");
conicGrad2.addColorStop(0.25, "black");
conicGrad2.addColorStop(0.25, "white");
conicGrad2.addColorStop(0.5, "white");
conicGrad2.addColorStop(0.5, "black");
conicGrad2.addColorStop(0.75, "black");
conicGrad2.addColorStop(0.75, "white");
conicGrad2.addColorStop(1, "white");
// draw shapes
ctx.fillStyle = conicGrad1;
ctx.fillRect(12, 25, 100, 100);
ctx.fillStyle = conicGrad2;
ctx.fillRect(137, 25, 100, 100);
}
```
```html hidden
<canvas id="canvas" width="250" height="150" role="presentation"
>A conic gradient</canvas
>
```
```js hidden
draw();
```
The first gradient is positioned in the center of the first rectangle and moves a green color stop at the start, to a white one at the end. The angle starts at 2 radians, which is noticeable because of the beginning/end line pointing south east.
The second gradient is also positioned at the center of it's second rectangle. This one has multiple color stops, alternating from black to white at each quarter of the rotation. This gives us the checkered effect.
{{EmbedLiveSample("A_createConicGradient_example", "180", "180", "canvas_conicgrad.png")}}
## Patterns
In one of the examples on the previous page, we used a series of loops to create a pattern of images. There is, however, a much simpler method: the `createPattern()` method.
- {{domxref("CanvasRenderingContext2D.createPattern", "createPattern(image, type)")}}
- : Creates and returns a new canvas pattern object. `image` is a the source of the image (that is, an {{domxref("HTMLImageElement")}}, a {{domxref("SVGImageElement")}}, another {{domxref("HTMLCanvasElement")}} or a {{domxref("OffscreenCanvas")}}, an {{domxref("HTMLVideoElement")}} or a {{domxref("VideoFrame")}}, or an {{domxref("ImageBitmap")}}). `type` is a string indicating how to use the image.
The type specifies how to use the image in order to create the pattern, and must be one of the following string values:
- `repeat`
- : Tiles the image in both vertical and horizontal directions.
- `repeat-x`
- : Tiles the image horizontally but not vertically.
- `repeat-y`
- : Tiles the image vertically but not horizontally.
- `no-repeat`
- : Doesn't tile the image. It's used only once.
We use this method to create a {{domxref("CanvasPattern")}} object which is very similar to the gradient methods we've seen above. Once we've created a pattern, we can assign it to the `fillStyle` or `strokeStyle` properties. For example:
```js
const img = new Image();
img.src = "someimage.png";
const ptrn = ctx.createPattern(img, "repeat");
```
> **Note:** Like with the `drawImage()` method, you must make sure the image you use is loaded before calling this method or the pattern may be drawn incorrectly.
### A `createPattern` example
In this last example, we'll create a pattern to assign to the `fillStyle` property. The only thing worth noting is the use of the image's `onload` handler. This is to make sure the image is loaded before it is assigned to the pattern.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
// create new image object to use as pattern
const img = new Image();
img.src = "canvas_createpattern.png";
img.onload = () => {
// create pattern
const ptrn = ctx.createPattern(img, "repeat");
ctx.fillStyle = ptrn;
ctx.fillRect(0, 0, 150, 150);
};
}
```
```html hidden
<canvas id="canvas" width="150" height="150" role="presentation"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_createPattern_example", "180", "180", "canvas_createpattern.png")}}
## Shadows
Using shadows involves just four properties:
- {{domxref("CanvasRenderingContext2D.shadowOffsetX", "shadowOffsetX = float")}}
- : Indicates the horizontal distance the shadow should extend from the object. This value isn't affected by the transformation matrix. The default is 0.
- {{domxref("CanvasRenderingContext2D.shadowOffsetY", "shadowOffsetY = float")}}
- : Indicates the vertical distance the shadow should extend from the object. This value isn't affected by the transformation matrix. The default is 0.
- {{domxref("CanvasRenderingContext2D.shadowBlur", "shadowBlur = float")}}
- : Indicates the size of the blurring effect; this value doesn't correspond to a number of pixels and is not affected by the current transformation matrix. The default value is 0.
- {{domxref("CanvasRenderingContext2D.shadowColor", "shadowColor = color")}}
- : A standard CSS color value indicating the color of the shadow effect; by default, it is fully-transparent black.
The properties `shadowOffsetX` and `shadowOffsetY` indicate how far the shadow should extend from the object in the X and Y directions; these values aren't affected by the current transformation matrix. Use negative values to cause the shadow to extend up or to the left, and positive values to cause the shadow to extend down or to the right. These are both 0 by default.
The `shadowBlur` property indicates the size of the blurring effect; this value doesn't correspond to a number of pixels and is not affected by the current transformation matrix. The default value is 0.
The `shadowColor` property is a standard CSS color value indicating the color of the shadow effect; by default, it is fully-transparent black.
> **Note:** Shadows are only drawn for `source-over` [compositing operations](/en-US/docs/Web/API/Canvas_API/Tutorial/Compositing).
### A shadowed text example
This example draws a text string with a shadowing effect.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.shadowOffsetX = 2;
ctx.shadowOffsetY = 2;
ctx.shadowBlur = 2;
ctx.shadowColor = "rgb(0 0 0 / 50%)";
ctx.font = "20px Times New Roman";
ctx.fillStyle = "Black";
ctx.fillText("Sample String", 5, 30);
}
```
```html hidden
<canvas id="canvas" width="150" height="80" role="presentation"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("A_shadowed_text_example", "180", "100", "shadowed-string.png")}}
We will look at the `font` property and `fillText` method in the next chapter about [drawing text](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text).
## Canvas fill rules
When using `fill` (or {{domxref("CanvasRenderingContext2D.clip", "clip")}} and {{domxref("CanvasRenderingContext2D.isPointInPath", "isPointInPath")}}) you can optionally provide a fill rule algorithm by which to determine if a point is inside or outside a path and thus if it gets filled or not. This is useful when a path intersects itself or is nested.
Two values are possible:
- `nonzero`
- : The [non-zero winding rule](https://en.wikipedia.org/wiki/Nonzero-rule), which is the default rule.
- `evenodd`
- : The [even-odd winding rule](https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule).
In this example we are using the `evenodd` rule.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.beginPath();
ctx.arc(50, 50, 30, 0, Math.PI * 2, true);
ctx.arc(50, 50, 15, 0, Math.PI * 2, true);
ctx.fill("evenodd");
}
```
```html hidden
<canvas id="canvas" width="100" height="100" role="presentation"></canvas>
```
```js hidden
draw();
```
{{EmbedLiveSample("Canvas_fill_rules", "110", "110", "fill-rule.png")}}
{{PreviousNext("Web/API/Canvas_API/Tutorial/Drawing_shapes", "Web/API/Canvas_API/Tutorial/Drawing_text")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/compositing/index.md | ---
title: Compositing and clipping
slug: Web/API/Canvas_API/Tutorial/Compositing
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Transformations", "Web/API/Canvas_API/Tutorial/Basic_animations")}}
In all of our [previous examples](/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations), shapes were always drawn one on top of the other. This is more than adequate for most situations, but it limits the order in which composite shapes are built. We can, however, change this behavior by setting the `globalCompositeOperation` property. In addition, the `clip` property allows us to hide unwanted parts of shapes.
## `globalCompositeOperation`
We can not only draw new shapes behind existing shapes but we can also use it to mask off certain areas, clear sections from the canvas (not limited to rectangles like the {{domxref("CanvasRenderingContext2D.clearRect", "clearRect()")}} method does) and more.
- {{domxref("CanvasRenderingContext2D.globalCompositeOperation", "globalCompositeOperation = type")}}
- : This sets the type of compositing operation to apply when drawing new shapes, where type is a string identifying which of the twelve compositing operations to use.
## Clipping paths
A clipping path is like a normal canvas shape but it acts as a mask to hide unwanted parts of shapes. This is visualized in the image below. The red star shape is our clipping path. Everything that falls outside of this path won't get drawn on the canvas.

If we compare clipping paths to the `globalCompositeOperation` property we've seen above, we see two compositing modes that achieve more or less the same effect in `source-in` and `source-atop`. The most important differences between the two are that clipping paths are never actually drawn to the canvas and the clipping path is never affected by adding new shapes. This makes clipping paths ideal for drawing multiple shapes in a restricted area.
In the chapter about [drawing shapes](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes) I only mentioned the `stroke()` and `fill()` methods, but there's a third method we can use with paths, called `clip()`.
- {{domxref("CanvasRenderingContext2D.clip", "clip()")}}
- : Turns the path currently being built into the current clipping path.
You use `clip()` instead of `closePath()` to close a path and turn it into a clipping path instead of stroking or filling the path.
By default the {{HTMLElement("canvas")}} element has a clipping path that's the exact same size as the canvas itself. In other words, no clipping occurs.
### A `clip` example
In this example, we'll use a circular clipping path to restrict the drawing of a set of random stars to a particular region.
```js
function draw() {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.fillRect(0, 0, 150, 150);
ctx.translate(75, 75);
// Create a circular clipping path
ctx.beginPath();
ctx.arc(0, 0, 60, 0, Math.PI * 2, true);
ctx.clip();
// Draw background
const lingrad = ctx.createLinearGradient(0, -75, 0, 75);
lingrad.addColorStop(0, "#232256");
lingrad.addColorStop(1, "#143778");
ctx.fillStyle = lingrad;
ctx.fillRect(-75, -75, 150, 150);
generateStars(ctx);
}
function generateStars(ctx) {
for (let j = 1; j < 50; j++) {
ctx.save();
ctx.fillStyle = "#fff";
ctx.translate(
75 - Math.floor(Math.random() * 150),
75 - Math.floor(Math.random() * 150),
);
drawStar(ctx, Math.floor(Math.random() * 4) + 2);
ctx.restore();
}
}
function drawStar(ctx, r) {
ctx.save();
ctx.beginPath();
ctx.moveTo(r, 0);
for (let i = 0; i < 9; i++) {
ctx.rotate(Math.PI / 5);
if (i % 2 === 0) {
ctx.lineTo((r / 0.525731) * 0.200811, 0);
} else {
ctx.lineTo(r, 0);
}
}
ctx.closePath();
ctx.fill();
ctx.restore();
}
```
```html hidden
<canvas id="canvas" width="150" height="150"></canvas>
```
```js hidden
draw();
```
In the first few lines of code, we draw a black rectangle the size of the canvas as a backdrop, then translate the origin to the center. Next, we create the circular clipping path by drawing an arc and calling `clip()`. Clipping paths are also part of the canvas save state. If we wanted to keep the original clipping path we could have saved the canvas state before creating the new one.
Everything that's drawn after creating the clipping path will only appear inside that path. You can see this clearly in the linear gradient that's drawn next. After this a set of 50 randomly positioned and scaled stars is drawn, using the custom `drawStar()` function. Again the stars only appear inside the defined clipping path.
{{EmbedLiveSample("A_clip_example", "180", "190", "canvas_clip.png")}}
### Inverse clipping path
There is no such thing as an inverse clipping mask. However, we can define a mask that fills the entire canvas with a rectangle and has a hole in it for the parts that you want to skip. When [drawing a shape with a hole](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes#shapes_with_holes), we need to draw the hole in the opposite direction as the outer shape. In the example below we punch a hole into the sky.
A rectangle does not have a drawing direction, but it behaves as if we drew it clockwise. By default, the arc command also goes clockwise, but we can change its direction with the last argument.
```html hidden
<html lang="en">
<body>
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
```
```js
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
ctx.translate(75, 75);
// Clipping path
ctx.beginPath();
ctx.rect(-75, -75, 150, 150); // Outer rectangle
ctx.arc(0, 0, 60, 0, Math.PI * 2, true); // Hole anticlockwise
ctx.clip();
// Draw background
const lingrad = ctx.createLinearGradient(0, -75, 0, 75);
lingrad.addColorStop(0, "#232256");
lingrad.addColorStop(1, "#143778");
ctx.fillStyle = lingrad;
ctx.fillRect(-75, -75, 150, 150);
generateStars(ctx);
}
}
```
```js hidden
function generateStars(ctx) {
for (let j = 1; j < 50; j++) {
ctx.save();
ctx.fillStyle = "#fff";
ctx.translate(
75 - Math.floor(Math.random() * 150),
75 - Math.floor(Math.random() * 150),
);
drawStar(ctx, Math.floor(Math.random() * 4) + 2);
ctx.restore();
}
}
function drawStar(ctx, r) {
ctx.save();
ctx.beginPath();
ctx.moveTo(r, 0);
for (let i = 0; i < 9; i++) {
ctx.rotate(Math.PI / 5);
if (i % 2 === 0) {
ctx.lineTo((r / 0.525731) * 0.200811, 0);
} else {
ctx.lineTo(r, 0);
}
}
ctx.closePath();
ctx.fill();
ctx.restore();
}
draw();
```
{{EmbedLiveSample("Hole_in_rectangle", 160, 160, "inverse_clipping_path.png")}}
{{PreviousNext("Web/API/Canvas_API/Tutorial/Transformations", "Web/API/Canvas_API/Tutorial/Basic_animations")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/basic_usage/index.md | ---
title: Basic usage of canvas
slug: Web/API/Canvas_API/Tutorial/Basic_usage
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial", "Web/API/Canvas_API/Tutorial/Drawing_shapes")}}
Let's start this tutorial by looking at the {{HTMLElement("canvas")}} {{Glossary("HTML")}} element itself. At the end of this page, you will know how to set up a canvas 2D context and have drawn a first example in your browser.
## The `<canvas>` element
```html
<canvas id="tutorial" width="150" height="150"></canvas>
```
At first sight a {{HTMLElement("canvas")}} looks like the {{HTMLElement("img")}} element, with the only clear difference being that it doesn't have the `src` and `alt` attributes. Indeed, the `<canvas>` element has only two attributes, [`width`](/en-US/docs/Web/HTML/Element/canvas#width) and [`height`](/en-US/docs/Web/HTML/Element/canvas#height). These are both optional and can also be set using {{Glossary("DOM")}} [properties](/en-US/docs/Web/API/HTMLCanvasElement). When no `width` and `height` attributes are specified, the canvas will initially be **300 pixels** wide and **150 pixels** high. The element can be sized arbitrarily by {{Glossary("CSS")}}, but during rendering the image is scaled to fit its layout size: if the CSS sizing doesn't respect the ratio of the initial canvas, it will appear distorted.
> **Note:** If your renderings seem distorted, try specifying your `width` and `height` attributes explicitly in the `<canvas>` attributes, and not using CSS.
The [`id`](/en-US/docs/Web/HTML/Global_attributes/id) attribute isn't specific to the `<canvas>` element but is one of the [global HTML attributes](/en-US/docs/Web/HTML/Global_attributes) which can be applied to any HTML element (like [`class`](/en-US/docs/Web/HTML/Global_attributes/class) for instance). It is always a good idea to supply an `id` because this makes it much easier to identify it in a script.
The `<canvas>` element can be styled just like any normal image ({{cssxref("margin")}}, {{cssxref("border")}}, {{cssxref("background")}}…). These rules, however, don't affect the actual drawing on the canvas. We'll see how this is done in a [dedicated chapter](/en-US/docs/Web/API/Canvas_API/Tutorial/Applying_styles_and_colors) of this tutorial. When no styling rules are applied to the canvas it will initially be fully transparent.
### Accessible content
The `<canvas>` element, like the {{HTMLElement("img")}}, {{HTMLElement("video")}}, {{HTMLElement("audio")}}, and {{HTMLElement("picture")}} elements, must be made accessible by providing fallback text to be displayed when the media doesn't load or the user is unable to experience it as intended. You should always provide fallback content, captions, and alternative text, as appropriate for the media type.
Providing fallback content is very straightforward: just insert the alternate content inside the `<canvas>` element to be accessed by screen readers, spiders, and other automated bots. Browsers, by default, will ignore the content inside the container, rendering the canvas normally unless `<canvas>` isn't supported.
For example, we could provide a text description of the canvas content or provide a static image of the dynamically rendered content. This can look something like this:
```html
<canvas id="stockGraph" width="150" height="150">
current stock price: $3.15 + 0.15
</canvas>
<canvas id="clock" width="150" height="150">
<img src="images/clock.png" width="150" height="150" alt="A clock" />
</canvas>
```
Telling the user to use a different browser that supports canvas does not help users who can't read the canvas at all. Providing useful fallback text or sub DOM adds accessibility to an otherwise non-accessible element.
### Required `</canvas>` tag
As a consequence of the way fallback is provided, unlike the {{HTMLElement("img")}} element, the {{HTMLElement("canvas")}} element **requires** the closing tag (`</canvas>`). If this tag is not present, the rest of the document would be considered the fallback content and wouldn't be displayed.
If fallback content is not needed, a simple `<canvas id="foo" role="presentation" …></canvas>` is fully compatible with all browsers that support canvas at all. This should only be used if the canvas is purely presentational.
## The rendering context
The {{HTMLElement("canvas")}} element creates a fixed-size drawing surface that exposes one or more **rendering contexts**, which are used to create and manipulate the content shown. In this tutorial, we focus on the 2D rendering context. Other contexts may provide different types of rendering; for example, [WebGL](/en-US/docs/Web/API/WebGL_API) uses a 3D context based on [OpenGL ES](https://www.khronos.org/opengles/).
The canvas is initially blank. To display something, a script first needs to access the rendering context and draw on it. The {{HTMLElement("canvas")}} element has a method called {{domxref("HTMLCanvasElement.getContext", "getContext()")}}, used to obtain the rendering context and its drawing functions. `getContext()` takes one parameter, the type of context. For 2D graphics, such as those covered by this tutorial, you specify `"2d"` to get a {{domxref("CanvasRenderingContext2D")}}.
```js
const canvas = document.getElementById("tutorial");
const ctx = canvas.getContext("2d");
```
The first line in the script retrieves the node in the DOM representing the {{HTMLElement("canvas")}} element by calling the {{domxref("document.getElementById()")}} method. Once you have the element node, you can access the drawing context using its `getContext()` method.
## Checking for support
The fallback content is displayed in browsers which do not support {{HTMLElement("canvas")}}. Scripts can also check for support programmatically by testing for the presence of the `getContext()` method. Our code snippet from above becomes something like this:
```js
const canvas = document.getElementById("tutorial");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
// drawing code here
} else {
// canvas-unsupported code here
}
```
## A skeleton template
Here is a minimalistic template, which we'll be using as a starting point for later examples.
> **Note:** it is not good practice to embed a script inside HTML. We do it here to keep the example concise.
```html
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>Canvas tutorial</title>
<style>
canvas {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="tutorial" width="150" height="150"></canvas>
<script>
function draw() {
const canvas = document.getElementById("tutorial");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
}
}
window.addEventListener("load", draw);
</script>
</body>
</html>
```
The script includes a function called `draw()`, which is executed once the page finishes loading; this is done by listening for the {{domxref("Window/load_event", "load")}} event on the document. This function, or one like it, could also be called using {{domxref("setTimeout()")}}, {{domxref("setInterval()")}}, or any other event handler, as long as the page has been loaded first.
Here is how a template would look in action. As shown here, it is initially blank.
{{EmbedLiveSample("A_skeleton_template", 160, 160)}}
## A simple example
To begin, let's take a look at a simple example that draws two intersecting rectangles, one of which has alpha transparency. We'll explore how this works in more detail in later examples.
```html
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Canvas experiment</title>
</head>
<body>
<canvas id="canvas" width="150" height="150"></canvas>
<script type="application/javascript">
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(200 0 0)";
ctx.fillRect(10, 10, 50, 50);
ctx.fillStyle = "rgb(0 0 200 / 50%)";
ctx.fillRect(30, 30, 50, 50);
}
}
draw();
</script>
</body>
</html>
```
This example looks like this:
{{EmbedLiveSample("A_simple_example", 160, 160, "canvas_ex1.png")}}
{{PreviousNext("Web/API/Canvas_API/Tutorial", "Web/API/Canvas_API/Tutorial/Drawing_shapes")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api/tutorial | data/mdn-content/files/en-us/web/api/canvas_api/tutorial/pixel_manipulation_with_canvas/index.md | ---
title: Pixel manipulation with canvas
slug: Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Advanced_animations", "Web/API/Canvas_API/Tutorial/Optimizing_canvas")}}
Until now we haven't looked at the actual pixels of our canvas. With the `ImageData` object you can directly read and write a data array to manipulate pixel data. We will also look into how image smoothing (anti-aliasing) can be controlled and how to save images from your canvas.
## The ImageData object
The {{domxref("ImageData")}} object represents the underlying pixel data of an area of a canvas object. It contains the following read-only attributes:
- `width`
- : The width of the image in pixels.
- `height`
- : The height of the image in pixels.
- `data`
- : A {{jsxref("Uint8ClampedArray")}} representing a one-dimensional array containing the data in the RGBA order, with integer values between `0` and `255` (included).
The `data` property returns a {{jsxref("Uint8ClampedArray")}} which can be accessed to look at the raw pixel data; each pixel is represented by four one-byte values (red, green, blue, and alpha, in that order; that is, "RGBA" format). Each color component is represented by an integer between 0 and 255. Each component is assigned a consecutive index within the array, with the top left pixel's red component being at index 0 within the array. Pixels then proceed from left to right, then downward, throughout the array.
The {{jsxref("Uint8ClampedArray")}} contains `height` × `width` × 4 bytes of data, with index values ranging from 0 to (`height`×`width`×4)-1.
For example, to read the blue component's value from the pixel at column 200, row 50 in the image, you would do the following:
```js
const blueComponent = imageData.data[50 * (imageData.width * 4) + 200 * 4 + 2];
```
If given a set of coordinates (X and Y), you may end up doing something like this:
```js
const xCoord = 50;
const yCoord = 100;
const canvasWidth = 1024;
const getColorIndicesForCoord = (x, y, width) => {
const red = y * (width * 4) + x * 4;
return [red, red + 1, red + 2, red + 3];
};
const colorIndices = getColorIndicesForCoord(xCoord, yCoord, canvasWidth);
const [redIndex, greenIndex, blueIndex, alphaIndex] = colorIndices;
```
You may also access the size of the pixel array in bytes by reading the `Uint8ClampedArray.length` attribute:
```js
const numBytes = imageData.data.length;
```
## Creating an ImageData object
To create a new, blank `ImageData` object, you should use the {{domxref("CanvasRenderingContext2D.createImageData", "createImageData()")}} method. There are two versions of the `createImageData()` method:
```js
const myImageData = ctx.createImageData(width, height);
```
This creates a new `ImageData` object with the specified dimensions. All pixels are preset to transparent black (all zeroes, i.e., rgb(0 0 0 / 0%)).
You can also create a new `ImageData` object with the same dimensions as the object specified by `anotherImageData`. The new object's pixels are all preset to transparent black. **This does not copy the image data!**
```js
const myImageData = ctx.createImageData(anotherImageData);
```
## Getting the pixel data for a context
To obtain an `ImageData` object containing a copy of the pixel data for a canvas context, you can use the `getImageData()` method:
```js
const myImageData = ctx.getImageData(left, top, width, height);
```
This method returns an `ImageData` object representing the pixel data for the area of the canvas whose corners are represented by the points (`left`, `top`), (`left+width`, `top`), (`left`, `top+height`), and (`left+width`, `top+height`). The coordinates are specified in canvas coordinate space units.
> **Note:** Any pixels outside the canvas are returned as transparent black in the resulting `ImageData` object.
This method is also demonstrated in the article [Manipulating video using canvas](/en-US/docs/Web/API/Canvas_API/Manipulating_video_using_canvas).
### A color picker
In this example we are using the [`getImageData()`](/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData) method to display the color under the mouse cursor. For this, we need the current position of the mouse, then we look up the pixel data on that position in the pixel array that [`getImageData()`](/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData) provides us. Finally, we use the array data to set a background color and a text in the `<div>` to display the color. Clicking on the image will do the same operation but remember what the selected color was.
```js
const img = new Image();
img.crossOrigin = "anonymous";
img.src = "./assets/rhino.jpg";
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
img.addEventListener("load", () => {
ctx.drawImage(img, 0, 0);
img.style.display = "none";
});
const hoveredColor = document.getElementById("hovered-color");
const selectedColor = document.getElementById("selected-color");
function pick(event, destination) {
const bounding = canvas.getBoundingClientRect();
const x = event.clientX - bounding.left;
const y = event.clientY - bounding.top;
const pixel = ctx.getImageData(x, y, 1, 1);
const data = pixel.data;
const rgbColor = `rgb(${data[0]} ${data[1]} ${data[2]} / ${data[3] / 255})`;
destination.style.background = rgbColor;
destination.textContent = rgbColor;
return rgbColor;
}
canvas.addEventListener("mousemove", (event) => pick(event, hoveredColor));
canvas.addEventListener("click", (event) => pick(event, selectedColor));
```
The code's usage is demonstrated in the following live example:
{{EmbedGHLiveSample("dom-examples/canvas/pixel-manipulation/color-picker.html", '100%', 300)}}
Also see the source code — [HTML](https://github.com/mdn/dom-examples/blob/main/canvas/pixel-manipulation/color-picker.html), [JavaScript](https://github.com/mdn/dom-examples/blob/main/canvas/pixel-manipulation/color-picker.js).
## Painting pixel data into a context
You can use the [putImageData()](/en-US/docs/Web/API/CanvasRenderingContext2D/putImageData) method to paint pixel data into a context:
```js
ctx.putImageData(myImageData, dx, dy);
```
The `dx` and `dy` parameters indicate the device coordinates within the context at which to paint the top left corner of the pixel data you wish to draw.
For example, to paint the entire image represented by `myImageData` to the top left corner of the context, you can do the following:
```js
ctx.putImageData(myImageData, 0, 0);
```
### Grayscaling and inverting colors
In this example we iterate over all pixels to change their values, then we put the modified pixel array back to the canvas using [putImageData()](/en-US/docs/Web/API/CanvasRenderingContext2D/putImageData). The invert function subtracts each color from the max value 255. The grayscale function uses the average of red, green and blue. You can also use a weighted average, given by the formula `x = 0.299r + 0.587g + 0.114b`, for example. See [Grayscale](https://en.wikipedia.org/wiki/Grayscale) on Wikipedia for more information.
```js
const img = new Image();
img.crossOrigin = "anonymous";
img.src = "./assets/rhino.jpg";
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
img.onload = () => {
ctx.drawImage(img, 0, 0);
};
const original = () => {
ctx.drawImage(img, 0, 0);
};
const invert = () => {
ctx.drawImage(img, 0, 0);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data;
for (let i = 0; i < data.length; i += 4) {
data[i] = 255 - data[i]; // red
data[i + 1] = 255 - data[i + 1]; // green
data[i + 2] = 255 - data[i + 2]; // blue
}
ctx.putImageData(imageData, 0, 0);
};
const grayscale = () => {
ctx.drawImage(img, 0, 0);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data;
for (let i = 0; i < data.length; i += 4) {
const avg = (data[i] + data[i + 1] + data[i + 2]) / 3;
data[i] = avg; // red
data[i + 1] = avg; // green
data[i + 2] = avg; // blue
}
ctx.putImageData(imageData, 0, 0);
};
const inputs = document.querySelectorAll("[name=color]");
for (const input of inputs) {
input.addEventListener("change", (evt) => {
switch (evt.target.value) {
case "inverted":
return invert();
case "grayscale":
return grayscale();
default:
return original();
}
});
}
```
The code's usage is demonstrated in the following live example:
{{EmbedGHLiveSample("dom-examples/canvas/pixel-manipulation/color-manipulation.html", '100%', 300)}}
Also see the source code — [HTML](https://github.com/mdn/dom-examples/blob/main/canvas/pixel-manipulation/color-manipulation.html), [JavaScript](https://github.com/mdn/dom-examples/blob/main/canvas/pixel-manipulation/color-manipulation.js).
## Zooming and anti-aliasing
With the help of the {{domxref("CanvasRenderingContext2D.drawImage", "drawImage()")}} method, a second canvas and the {{domxref("CanvasRenderingContext2D.imageSmoothingEnabled", "imageSmoothingEnabled")}} property, we are able to zoom into our picture and see the details. A third canvas without {{domxref("CanvasRenderingContext2D.imageSmoothingEnabled", "imageSmoothingEnabled")}} is also drawn onto to be able to have a side by side comparison
We get the position of the mouse and crop an image of 5 pixels left and above to 5 pixels right and below. Then we copy that one over to another canvas and resize the image to the size we want it to. In the zoom canvas we resize a 10×10 pixel crop of the original canvas to 200×200.
```js
zoomctx.drawImage(
canvas,
Math.min(Math.max(0, x - 5), img.width - 10),
Math.min(Math.max(0, y - 5), img.height - 10),
10,
10,
0,
0,
200,
200,
);
```
Zoom example:
```js
const img = new Image();
img.crossOrigin = "anonymous";
img.src = "./assets/rhino.jpg";
img.onload = () => {
draw(this);
};
function draw(img) {
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
const smoothedZoomCtx = document
.getElementById("smoothed-zoom")
.getContext("2d");
smoothedZoomCtx.imageSmoothingEnabled = true;
const pixelatedZoomCtx = document
.getElementById("pixelated-zoom")
.getContext("2d");
pixelatedZoomCtx.imageSmoothingEnabled = false;
const zoom = (ctx, x, y) => {
ctx.drawImage(
canvas,
Math.min(Math.max(0, x - 5), img.width - 10),
Math.min(Math.max(0, y - 5), img.height - 10),
10,
10,
0,
0,
200,
200,
);
};
canvas.addEventListener("mousemove", (event) => {
const x = event.layerX;
const y = event.layerY;
zoom(smoothedZoomCtx, x, y);
zoom(pixelatedZoomCtx, x, y);
});
}
```
The code's usage is demonstrated in the following live example:
{{EmbedGHLiveSample("dom-examples/canvas/pixel-manipulation/image-smoothing.html", '100%', 300)}}
Also see the source code — [HTML](https://github.com/mdn/dom-examples/blob/main/canvas/pixel-manipulation/image-smoothing.html), [JavaScript](https://github.com/mdn/dom-examples/blob/main/canvas/pixel-manipulation/image-smoothing.js).
## Saving images
The {{domxref("HTMLCanvasElement")}} provides a `toDataURL()` method, which is useful when saving images. It returns a [data URL](/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs) containing a representation of the image in the format specified by the `type` parameter (defaults to [PNG](https://en.wikipedia.org/wiki/Portable_Network_Graphics)). The returned image is in a resolution of 96 dpi.
> **Note:** Be aware that if the canvas contains any pixels that were obtained from another {{Glossary("origin")}} without using CORS, the canvas is **tainted** and its contents can no longer be read and saved.
> See [Security and tainted canvases](/en-US/docs/Web/HTML/CORS_enabled_image#security_and_tainted_canvases).
- {{domxref("HTMLCanvasElement.toDataURL", "canvas.toDataURL('image/png')")}}
- : Default setting. Creates a PNG image.
- {{domxref("HTMLCanvasElement.toDataURL", "canvas.toDataURL('image/jpeg', quality)")}}
- : Creates a JPG image. Optionally, you can provide a quality in the range from 0 to 1, with one being the best quality and with 0 almost not recognizable but small in file size.
Once you have generated a data URL from your canvas, you are able to use it as the source of any {{HTMLElement("image")}} or put it into a hyperlink with a [download attribute](/en-US/docs/Web/HTML/Element/a#download) to save it to disc, for example.
You can also create a {{domxref("Blob")}} from the canvas.
- {{domxref("HTMLCanvasElement.toBlob", "canvas.toBlob(_callback_, _type_, _encoderOptions_)")}}
- : Creates a `Blob` object representing the image contained in the canvas.
## See also
- {{domxref("ImageData")}}
- [Manipulating video using canvas](/en-US/docs/Web/API/Canvas_API/Manipulating_video_using_canvas)
- [Download Canvas API-Generated Images Using toBlob](https://www.digitalocean.com/community/tutorials/js-canvas-toblob)
- [HTML5 Canvas Tutorials](https://www.html5canvastutorials.com/)
{{PreviousNext("Web/API/Canvas_API/Tutorial/Advanced_animations", "Web/API/Canvas_API/Tutorial/Optimizing_canvas")}}
| 0 |
data/mdn-content/files/en-us/web/api/canvas_api | data/mdn-content/files/en-us/web/api/canvas_api/manipulating_video_using_canvas/index.md | ---
title: Manipulating video using canvas
slug: Web/API/Canvas_API/Manipulating_video_using_canvas
page-type: guide
---
{{DefaultAPISidebar("Canvas API")}}
By combining the capabilities of the [`video`](/en-US/docs/Web/HTML/Element/video) element with a [`canvas`](/en-US/docs/Web/HTML/Element/canvas), you can manipulate video data in real time to incorporate a variety of visual effects to the video being displayed. This tutorial demonstrates how to perform chroma-keying (also known as the "green screen effect") using JavaScript code.
{{EmbedGHLiveSample('dom-examples/canvas/chroma-keying/index.html', 700, 400) }}
## The document content
The HTML document used to render this content is shown below.
```html
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Video test page</title>
<style>
body {
background: black;
color: #cccccc;
}
#c2 {
background-image: url(media/foo.png);
background-repeat: no-repeat;
}
div {
float: left;
border: 1px solid #444444;
padding: 10px;
margin: 10px;
background: #3b3b3b;
}
</style>
</head>
<body>
<div>
<video
id="video"
src="media/video.mp4"
controls
crossorigin="anonymous" />
</div>
<div>
<canvas id="c1" width="160" height="96"></canvas>
<canvas id="c2" width="160" height="96"></canvas>
</div>
<script src="processor.js"></script>
</body>
</html>
```
The key bits to take away from this are:
1. This document establishes two [`canvas`](/en-US/docs/Web/HTML/Element/canvas) elements, with the IDs `c1` and `c2`. Canvas `c1` is used to display the current frame of the original video, while `c2` is used to display the video after performing the chroma-keying effect; `c2` is preloaded with the still image that will be used to replace the green background in the video.
2. The JavaScript code is imported from a script named `processor.js`.
## The JavaScript code
The JavaScript code in `processor.js` consists of three methods.
### Initializing the chroma-key player
The `doLoad()` method is called when the HTML document initially loads. This method's job is to prepare the variables needed by the chroma-key processing code, and to set up an event listener so we can detect when the user starts playing the video.
```js
const processor = {};
processor.doLoad = function doLoad() {
const video = document.getElementById("video");
this.video = video;
this.c1 = document.getElementById("c1");
this.ctx1 = this.c1.getContext("2d");
this.c2 = document.getElementById("c2");
this.ctx2 = this.c2.getContext("2d");
video.addEventListener(
"play",
() => {
this.width = video.videoWidth / 2;
this.height = video.videoHeight / 2;
this.timerCallback();
},
false,
);
};
```
This code grabs references to the elements in the HTML document that are of particular interest, namely the `video` element and the two `canvas` elements. It also fetches references to the graphics contexts for each of the two canvases. These will be used when we're actually doing the chroma-keying effect.
Then `addEventListener()` is called to begin watching the `video` element so that we obtain notification when the user presses the play button on the video. In response to the user beginning playback, this code fetches the width and height of the video, halving each (we will be halving the size of the video when we perform the chroma-keying effect), then calls the `timerCallback()` method to start watching the video and computing the visual effect.
### The timer callback
The timer callback is called initially when the video starts playing (when the "play" event occurs), then takes responsibility for establishing itself to be called periodically in order to launch the keying effect for each frame.
```js
processor.timerCallback = function timerCallback() {
if (this.video.paused || this.video.ended) {
return;
}
this.computeFrame();
setTimeout(() => {
this.timerCallback();
}, 0);
};
```
The first thing the callback does is check to see if the video is even playing; if it's not, the callback returns immediately without doing anything.
Then it calls the `computeFrame()` method, which performs the chroma-keying effect on the current video frame.
The last thing the callback does is call `setTimeout()` to schedule itself to be called again as soon as possible. In the real world, you would probably schedule this to be done based on knowledge of the video's frame rate.
### Manipulating the video frame data
The `computeFrame()` method, shown below, is responsible for actually fetching a frame of data and performing the chroma-keying effect.
```js
processor.computeFrame = function () {
this.ctx1.drawImage(this.video, 0, 0, this.width, this.height);
const frame = this.ctx1.getImageData(0, 0, this.width, this.height);
const data = frame.data;
for (let i = 0; i < data.length; i += 4) {
const red = data[i + 0];
const green = data[i + 1];
const blue = data[i + 2];
if (green > 100 && red > 100 && blue < 43) {
data[i + 3] = 0;
}
}
this.ctx2.putImageData(frame, 0, 0);
};
```
When this routine is called, the video element is displaying the most recent frame of video data, which looks like this:

In line 2, that frame of video is copied into the graphics context `ctx1` of the first canvas, specifying as the height and width the values we previously saved to draw the frame at half size. Note that you can pass the video element into the context's `drawImage()` method to draw the current video frame into the context. The result is:

Line 3 fetches a copy of the raw graphics data for the current frame of video by calling the `getImageData()` method on the first context. This provides raw 32-bit pixel image data we can then manipulate. Line 4 computes the number of pixels in the image by dividing the total size of the frame's image data by four.
The `for` loop that begins on line 6 scans through the frame's pixels, pulling out the red, green, and blue values for each pixel, and compares the values against predetermined numbers that are used to detect the green screen that will be replaced with the still background image imported from `foo.png`.
Every pixel in the frame's image data that is found that is within the parameters that are considered to be part of the green screen has its alpha value replaced with a zero, indicating that the pixel is entirely transparent. As a result, the final image has the entire green screen area 100% transparent, so that when it's drawn into the destination context in line 13, the result is an overlay onto the static backdrop.
The resulting image looks like this:

This is done repeatedly as the video plays, so that frame after frame is processed and displayed with the chroma-key effect.
[View the full source for this example](https://github.com/mdn/dom-examples/tree/main/canvas/chroma-keying).
## See also
- [Web media technologies](/en-US/docs/Web/Media)
- [Guide to media types and formats on the web](/en-US/docs/Web/Media/Formats)
- [Learning area: Video and audio content](/en-US/docs/Learn/HTML/Multimedia_and_embedding/Video_and_audio_content)
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/webglrenderingcontext/index.md | ---
title: WebGLRenderingContext
slug: Web/API/WebGLRenderingContext
page-type: web-api-interface
browser-compat: api.WebGLRenderingContext
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext`** interface provides an interface to the OpenGL ES 2.0 graphics rendering context for the drawing surface of an HTML {{HTMLElement("canvas")}} element.
To get an access to a WebGL context for 2D and/or 3D graphics rendering, call {{domxref("HTMLCanvasElement.getContext()", "getContext()")}} on a `<canvas>` element, supplying "webgl" as the argument:
```js
const canvas = document.getElementById("myCanvas");
const gl = canvas.getContext("webgl");
```
Once you have the WebGL rendering context for a canvas, you can render within it. The [WebGL tutorial](/en-US/docs/Web/API/WebGL_API/Tutorial) has more information, examples, and resources on how to get started with WebGL.
If you require a WebGL 2.0 context, see {{domxref("WebGL2RenderingContext")}}; this supplies access to an implementation of OpenGL ES 3.0 graphics.
## Constants
See the [WebGL constants](/en-US/docs/Web/API/WebGL_API/Constants) page.
## The WebGL context
The following properties and methods provide general information and functionality to deal with the WebGL context:
- {{domxref("WebGLRenderingContext.canvas")}}
- : A read-only back-reference to the {{domxref("HTMLCanvasElement")}}. Might be [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null) if it is not associated with a {{HTMLElement("canvas")}} element.
- {{domxref("WebGLRenderingContext.drawingBufferWidth")}}
- : The read-only width of the current drawing buffer. Should match the width of the canvas element associated with this context.
- {{domxref("WebGLRenderingContext.drawingBufferHeight")}}
- : The read-only height of the current drawing buffer. Should match the height of the canvas element associated with this context.
- {{domxref("WebGLRenderingContext.getContextAttributes()")}}
- : Returns a `WebGLContextAttributes` object that contains the actual context parameters. Might return [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null), if the context is lost.
- {{domxref("WebGLRenderingContext.isContextLost()")}}
- : Returns `true` if the context is lost, otherwise returns `false`.
- {{domxref("WebGLRenderingContext.makeXRCompatible()")}}
- : Ensures the context is compatible with the user's XR hardware, re-creating the context if necessary with a new configuration to do so. This can be used to start an application using standard 2D presentation, then transition to using a VR or AR mode later.
## Viewing and clipping
- {{domxref("WebGLRenderingContext.scissor()")}}
- : Defines the scissor box.
- {{domxref("WebGLRenderingContext.viewport()")}}
- : Sets the viewport.
## State information
- {{domxref("WebGLRenderingContext.activeTexture()")}}
- : Selects the active texture unit.
- {{domxref("WebGLRenderingContext.blendColor()")}}
- : Sets the source and destination blending factors.
- {{domxref("WebGLRenderingContext.blendEquation()")}}
- : Sets both the RGB blend equation and alpha blend equation to a single equation.
- {{domxref("WebGLRenderingContext.blendEquationSeparate()")}}
- : Sets the RGB blend equation and alpha blend equation separately.
- {{domxref("WebGLRenderingContext.blendFunc()")}}
- : Defines which function is used for blending pixel arithmetic.
- {{domxref("WebGLRenderingContext.blendFuncSeparate()")}}
- : Defines which function is used for blending pixel arithmetic for RGB and alpha components separately.
- {{domxref("WebGLRenderingContext.clearColor()")}}
- : Specifies the color values used when clearing color buffers.
- {{domxref("WebGLRenderingContext.clearDepth()")}}
- : Specifies the depth value used when clearing the depth buffer.
- {{domxref("WebGLRenderingContext.clearStencil()")}}
- : Specifies the stencil value used when clearing the stencil buffer.
- {{domxref("WebGLRenderingContext.colorMask()")}}
- : Sets which color components to enable or to disable when drawing or rendering to a {{domxref("WebGLFramebuffer")}}.
- {{domxref("WebGLRenderingContext.cullFace()")}}
- : Specifies whether or not front- and/or back-facing polygons can be culled.
- {{domxref("WebGLRenderingContext.depthFunc()")}}
- : Specifies a function that compares incoming pixel depth to the current depth buffer value.
- {{domxref("WebGLRenderingContext.depthMask()")}}
- : Sets whether writing into the depth buffer is enabled or disabled.
- {{domxref("WebGLRenderingContext.depthRange()")}}
- : Specifies the depth range mapping from normalized device coordinates to window or viewport coordinates.
- {{domxref("WebGLRenderingContext.disable()")}}
- : Disables specific WebGL capabilities for this context.
- {{domxref("WebGLRenderingContext.enable()")}}
- : Enables specific WebGL capabilities for this context.
- {{domxref("WebGLRenderingContext.frontFace()")}}
- : Specifies whether polygons are front- or back-facing by setting a winding orientation.
- {{domxref("WebGLRenderingContext.getParameter()")}}
- : Returns a value for the passed parameter name.
- {{domxref("WebGLRenderingContext.getError()")}}
- : Returns error information.
- {{domxref("WebGLRenderingContext.hint()")}}
- : Specifies hints for certain behaviors. The interpretation of these hints depend on the implementation.
- {{domxref("WebGLRenderingContext.isEnabled()")}}
- : Tests whether a specific WebGL capability is enabled or not for this context.
- {{domxref("WebGLRenderingContext.lineWidth()")}}
- : Sets the line width of rasterized lines.
- {{domxref("WebGLRenderingContext.pixelStorei()")}}
- : Specifies the pixel storage modes
- {{domxref("WebGLRenderingContext.polygonOffset()")}}
- : Specifies the scale factors and units to calculate depth values.
- {{domxref("WebGLRenderingContext.sampleCoverage()")}}
- : Specifies multi-sample coverage parameters for anti-aliasing effects.
- {{domxref("WebGLRenderingContext.stencilFunc()")}}
- : Sets the both front and back function and reference value for stencil testing.
- {{domxref("WebGLRenderingContext.stencilFuncSeparate()")}}
- : Sets the front and/or back function and reference value for stencil testing.
- {{domxref("WebGLRenderingContext.stencilMask()")}}
- : Controls enabling and disabling of both the front and back writing of individual bits in the stencil planes.
- {{domxref("WebGLRenderingContext.stencilMaskSeparate()")}}
- : Controls enabling and disabling of front and/or back writing of individual bits in the stencil planes.
- {{domxref("WebGLRenderingContext.stencilOp()")}}
- : Sets both the front and back-facing stencil test actions.
- {{domxref("WebGLRenderingContext.stencilOpSeparate()")}}
- : Sets the front and/or back-facing stencil test actions.
## Buffers
- {{domxref("WebGLRenderingContext.bindBuffer()")}}
- : Binds a `WebGLBuffer` object to a given target.
- {{domxref("WebGLRenderingContext.bufferData()")}}
- : Updates buffer data.
- {{domxref("WebGLRenderingContext.bufferSubData()")}}
- : Updates buffer data starting at a passed offset.
- {{domxref("WebGLRenderingContext.createBuffer()")}}
- : Creates a `WebGLBuffer` object.
- {{domxref("WebGLRenderingContext.deleteBuffer()")}}
- : Deletes a `WebGLBuffer` object.
- {{domxref("WebGLRenderingContext.getBufferParameter()")}}
- : Returns information about the buffer.
- {{domxref("WebGLRenderingContext.isBuffer()")}}
- : Returns a Boolean indicating if the passed buffer is valid.
## Framebuffers
- {{domxref("WebGLRenderingContext.bindFramebuffer()")}}
- : Binds a `WebGLFrameBuffer` object to a given target.
- {{domxref("WebGLRenderingContext.checkFramebufferStatus()")}}
- : Returns the status of the framebuffer.
- {{domxref("WebGLRenderingContext.createFramebuffer()")}}
- : Creates a `WebGLFrameBuffer` object.
- {{domxref("WebGLRenderingContext.deleteFramebuffer()")}}
- : Deletes a `WebGLFrameBuffer` object.
- {{domxref("WebGLRenderingContext.framebufferRenderbuffer()")}}
- : Attaches a `WebGLRenderingBuffer` object to a `WebGLFrameBuffer` object.
- {{domxref("WebGLRenderingContext.framebufferTexture2D()")}}
- : Attaches a textures image to a `WebGLFrameBuffer` object.
- {{domxref("WebGLRenderingContext.getFramebufferAttachmentParameter()")}}
- : Returns information about the framebuffer.
- {{domxref("WebGLRenderingContext.isFramebuffer()")}}
- : Returns a Boolean indicating if the passed `WebGLFrameBuffer` object is valid.
- {{domxref("WebGLRenderingContext.readPixels()")}}
- : Reads a block of pixels from the `WebGLFrameBuffer`.
## Renderbuffers
- {{domxref("WebGLRenderingContext.bindRenderbuffer()")}}
- : Binds a `WebGLRenderBuffer` object to a given target.
- {{domxref("WebGLRenderingContext.createRenderbuffer()")}}
- : Creates a `WebGLRenderBuffer` object.
- {{domxref("WebGLRenderingContext.deleteRenderbuffer()")}}
- : Deletes a `WebGLRenderBuffer` object.
- {{domxref("WebGLRenderingContext.getRenderbufferParameter()")}}
- : Returns information about the renderbuffer.
- {{domxref("WebGLRenderingContext.isRenderbuffer()")}}
- : Returns a Boolean indicating if the passed `WebGLRenderingBuffer` is valid.
- {{domxref("WebGLRenderingContext.renderbufferStorage()")}}
- : Creates a renderbuffer data store.
## Textures
- {{domxref("WebGLRenderingContext.bindTexture()")}}
- : Binds a `WebGLTexture` object to a given target.
- {{domxref("WebGLRenderingContext.compressedTexImage2D()")}}
- : Specifies a 2D texture image in a compressed format.
- {{domxref("WebGLRenderingContext.compressedTexSubImage2D()")}}
- : Specifies a 2D texture sub-image in a compressed format.
- {{domxref("WebGLRenderingContext.copyTexImage2D()")}}
- : Copies a 2D texture image.
- {{domxref("WebGLRenderingContext.copyTexSubImage2D()")}}
- : Copies a 2D texture sub-image.
- {{domxref("WebGLRenderingContext.createTexture()")}}
- : Creates a `WebGLTexture` object.
- {{domxref("WebGLRenderingContext.deleteTexture()")}}
- : Deletes a `WebGLTexture` object.
- {{domxref("WebGLRenderingContext.generateMipmap()")}}
- : Generates a set of mipmaps for a `WebGLTexture` object.
- {{domxref("WebGLRenderingContext.getTexParameter()")}}
- : Returns information about the texture.
- {{domxref("WebGLRenderingContext.isTexture()")}}
- : Returns a Boolean indicating if the passed `WebGLTexture` is valid.
- {{domxref("WebGLRenderingContext.texImage2D()")}}
- : Specifies a 2D texture image.
- {{domxref("WebGLRenderingContext.texSubImage2D()")}}
- : Updates a sub-rectangle of the current `WebGLTexture`.
- {{domxref("WebGLRenderingContext.texParameter", "WebGLRenderingContext.texParameterf()")}}
- : Sets texture parameters.
- {{domxref("WebGLRenderingContext.texParameter", "WebGLRenderingContext.texParameteri()")}}
- : Sets texture parameters.
## Programs and shaders
- {{domxref("WebGLRenderingContext.attachShader()")}}
- : Attaches a `WebGLShader` to a `WebGLProgram`.
- {{domxref("WebGLRenderingContext.bindAttribLocation()")}}
- : Binds a generic vertex index to a named attribute variable.
- {{domxref("WebGLRenderingContext.compileShader()")}}
- : Compiles a `WebGLShader`.
- {{domxref("WebGLRenderingContext.createProgram()")}}
- : Creates a `WebGLProgram`.
- {{domxref("WebGLRenderingContext.createShader()")}}
- : Creates a `WebGLShader`.
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- : Deletes a `WebGLProgram`.
- {{domxref("WebGLRenderingContext.deleteShader()")}}
- : Deletes a `WebGLShader`.
- {{domxref("WebGLRenderingContext.detachShader()")}}
- : Detaches a `WebGLShader`.
- {{domxref("WebGLRenderingContext.getAttachedShaders()")}}
- : Returns a list of `WebGLShader` objects attached to a `WebGLProgram`.
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- : Returns information about the program.
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
- : Returns the information log for a `WebGLProgram` object.
- {{domxref("WebGLRenderingContext.getShaderParameter()")}}
- : Returns information about the shader.
- {{domxref("WebGLRenderingContext.getShaderPrecisionFormat()")}}
- : Returns a `WebGLShaderPrecisionFormat` object describing the precision for the numeric format of the shader.
- {{domxref("WebGLRenderingContext.getShaderInfoLog()")}}
- : Returns the information log for a `WebGLShader` object.
- {{domxref("WebGLRenderingContext.getShaderSource()")}}
- : Returns the source code of a `WebGLShader` as a string.
- {{domxref("WebGLRenderingContext.isProgram()")}}
- : Returns a Boolean indicating if the passed `WebGLProgram` is valid.
- {{domxref("WebGLRenderingContext.isShader()")}}
- : Returns a Boolean indicating if the passed `WebGLShader` is valid.
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- : Links the passed `WebGLProgram` object.
- {{domxref("WebGLRenderingContext.shaderSource()")}}
- : Sets the source code in a `WebGLShader`.
- {{domxref("WebGLRenderingContext.useProgram()")}}
- : Uses the specified `WebGLProgram` as part the current rendering state.
- {{domxref("WebGLRenderingContext.validateProgram()")}}
- : Validates a `WebGLProgram`.
## Uniforms and attributes
- {{domxref("WebGLRenderingContext.disableVertexAttribArray()")}}
- : Disables a vertex attribute array at a given position.
- {{domxref("WebGLRenderingContext.enableVertexAttribArray()")}}
- : Enables a vertex attribute array at a given position.
- {{domxref("WebGLRenderingContext.getActiveAttrib()")}}
- : Returns information about an active attribute variable.
- {{domxref("WebGLRenderingContext.getActiveUniform()")}}
- : Returns information about an active uniform variable.
- {{domxref("WebGLRenderingContext.getAttribLocation()")}}
- : Returns the location of an attribute variable.
- {{domxref("WebGLRenderingContext.getUniform()")}}
- : Returns the value of a uniform variable at a given location.
- {{domxref("WebGLRenderingContext.getUniformLocation()")}}
- : Returns the location of a uniform variable.
- {{domxref("WebGLRenderingContext.getVertexAttrib()")}}
- : Returns information about a vertex attribute at a given position.
- {{domxref("WebGLRenderingContext.getVertexAttribOffset()")}}
- : Returns the address of a given vertex attribute.
<!-- markdownlint-disable MD052 -- text in code block is misidentified as image -->
- [`WebGLRenderingContext.uniform[1234][fi][v]()`](/en-US/docs/Web/API/WebGLRenderingContext/uniform)
- : Specifies a value for a uniform variable.
- {{domxref("WebGLRenderingContext.uniformMatrix()", "WebGLRenderingContext.uniformMatrix[234]fv()")}}
- : Specifies a matrix value for a uniform variable.
- {{domxref("WebGLRenderingContext.vertexAttrib()", "WebGLRenderingContext.vertexAttrib[1234]f[v]()")}}
- : Specifies a value for a generic vertex attribute.
- {{domxref("WebGLRenderingContext.vertexAttribPointer()")}}
- : Specifies the data formats and locations of vertex attributes in a vertex attributes array.
## Drawing buffers
- {{domxref("WebGLRenderingContext.clear()")}}
- : Clears specified buffers to preset values.
- {{domxref("WebGLRenderingContext.drawArrays()")}}
- : Renders primitives from array data.
- {{domxref("WebGLRenderingContext.drawElements()")}}
- : Renders primitives from element array data.
- {{domxref("WebGLRenderingContext.finish()")}}
- : Blocks execution until all previously called commands are finished.
- {{domxref("WebGLRenderingContext.flush()")}}
- : Empties different buffer commands, causing all commands to be executed as quickly as possible.
## Color spaces
- {{domxref("WebGLRenderingContext.drawingBufferColorSpace")}}
- : Specifies the color space of the WebGL drawing buffer.
- {{domxref("WebGLRenderingContext.unpackColorSpace")}} {{Experimental_Inline}}
- : Specifies the color space to convert to when importing textures.
## Working with extensions
These methods manage WebGL extensions:
- {{domxref("WebGLRenderingContext.getSupportedExtensions()")}}
- : Returns an {{jsxref("Array")}} of strings containing all the supported WebGL extensions.
- {{domxref("WebGLRenderingContext.getExtension()")}}
- : Returns an extension object.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("HTMLCanvasElement")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/activetexture/index.md | ---
title: "WebGLRenderingContext: activeTexture() method"
short-title: activeTexture()
slug: Web/API/WebGLRenderingContext/activeTexture
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.activeTexture
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.activeTexture()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) specifies which texture unit to
make active.
## Syntax
```js-nolint
activeTexture(texture)
```
### Parameters
- `texture`
- : The texture unit to make active. The value is a `gl.TEXTUREI`
where _I_ is within the range from 0 to
`gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1`.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
If _texture_ is not one of `gl.TEXTUREI`, where _I_
is within the range from 0 to `gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1`, a
`gl.INVALID_ENUM` error is thrown.
## Examples
The following call selects `gl.TEXTURE1` as the current texture. Subsequent
calls that modify the texture state will affect this texture.
```js
gl.activeTexture(gl.TEXTURE1);
```
The number of texture units is implementation dependent, you can get this number with
the help of the `MAX_COMBINED_TEXTURE_IMAGE_UNITS` constant. It is, per
specification, at least 8.
```js
gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
```
To get the active texture, query the `ACTIVE_TEXTURE` constant.
```js
gl.activeTexture(gl.TEXTURE0);
gl.getParameter(gl.ACTIVE_TEXTURE);
// returns "33984" (0x84C0, gl.TEXTURE0 enum value)
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getParameter()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/compressedtexsubimage2d/index.md | ---
title: "WebGLRenderingContext: compressedTexSubImage2D() method"
short-title: compressedTexSubImage2D()
slug: Web/API/WebGLRenderingContext/compressedTexSubImage2D
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.compressedTexSubImage2D
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.compressedTexSubImage2D()`**
method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies a
two-dimensional sub-rectangle for a texture image in a compressed format.
Compressed image formats must be enabled by [WebGL extensions](/en-US/docs/Web/API/WebGL_API/Using_Extensions) before
using this method or a {{domxref("WebGL2RenderingContext")}} must be used.
## Syntax
```js-nolint
// WebGL 1:
compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, srcData)
// Additionally available in WebGL 2:
compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, offset)
compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, srcData)
compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, srcData, srcOffset)
compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, srcData, srcOffset, srcLengthOverride)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target) of the active
compressed texture. Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_X`: Positive X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_X`: Negative X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Y`: Positive Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Y`: Negative Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Z`: Positive Z face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Z`: Negative Z face for a cube-mapped
texture.
- `level`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the level of detail. Level 0 is the base image
level and level _n_ is the n-th mipmap reduction level.
- `xoffset`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the horizontal offset within the compressed
texture image.
- `yoffset`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the vertical offset within the compressed texture
image.
- `width`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the compressed texture.
- `height`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the compressed texture.
- `format`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the compressed image format. Compressed image
formats must be enabled by [WebGL extensions](/en-US/docs/Web/API/WebGL_API/Using_Extensions) before
using this method. Possible values:
- When using the {{domxref("WEBGL_compressed_texture_s3tc")}} extension:
- `ext.COMPRESSED_RGB_S3TC_DXT1_EXT`
- `ext.COMPRESSED_RGBA_S3TC_DXT1_EXT`
- `ext.COMPRESSED_RGBA_S3TC_DXT3_EXT`
- `ext.COMPRESSED_RGBA_S3TC_DXT5_EXT`
- When using the {{domxref("WEBGL_compressed_texture_s3tc_srgb")}} extension:
- `ext.COMPRESSED_SRGB_S3TC_DXT1_EXT`
- `ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT`
- `ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT`
- `ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT`
- When using the {{domxref("WEBGL_compressed_texture_etc")}} extension:
- `ext.COMPRESSED_R11_EAC`
- `ext.COMPRESSED_SIGNED_R11_EAC`
- `ext.COMPRESSED_RG11_EAC`
- `ext.COMPRESSED_SIGNED_RG11_EAC`
- `ext.COMPRESSED_RGB8_ETC2`
- `ext.COMPRESSED_RGBA8_ETC2_EAC`
- `ext.COMPRESSED_SRGB8_ETC2`
- `ext.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC`
- `ext.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2`
- `ext.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2`
- When using the {{domxref("WEBGL_compressed_texture_pvrtc")}} extension:
- `ext.COMPRESSED_RGB_PVRTC_4BPPV1_IMG`
- `ext.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG`
- `ext.COMPRESSED_RGB_PVRTC_2BPPV1_IMG`
- `ext.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG`
- When using the {{domxref("WEBGL_compressed_texture_astc")}} extension:
- `ext.COMPRESSED_RGBA_ASTC_4x4_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR`
- `ext.COMPRESSED_RGBA_ASTC_5x4_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR`
- `ext.COMPRESSED_RGBA_ASTC_5x5_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR`
- `ext.COMPRESSED_RGBA_ASTC_6x5_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR`
- `ext.COMPRESSED_RGBA_ASTC_6x6_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR`
- `ext.COMPRESSED_RGBA_ASTC_8x5_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR`
- `ext.COMPRESSED_RGBA_ASTC_8x6_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR`
- `ext.COMPRESSED_RGBA_ASTC_8x8_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR`
- `ext.COMPRESSED_RGBA_ASTC_10x5_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR`
- `ext.COMPRESSED_RGBA_ASTC_10x6_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR`
- `ext.COMPRESSED_RGBA_ASTC_10x6_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR`
- `ext.COMPRESSED_RGBA_ASTC_10x10_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR`
- `ext.COMPRESSED_RGBA_ASTC_12x10_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR`
- `ext.COMPRESSED_RGBA_ASTC_12x12_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR`
- When using the {{domxref("EXT_texture_compression_bptc")}} extension:
- `ext.COMPRESSED_RGBA_BPTC_UNORM_EXT`
- `ext.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT`
- `ext.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT`
- `ext.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT`
- When using the {{domxref("EXT_texture_compression_rgtc")}} extension:
- `ext.COMPRESSED_RED_RGTC1_EXT`
- `ext.COMPRESSED_SIGNED_RED_RGTC1_EXT`
- `ext.COMPRESSED_RED_GREEN_RGTC2_EXT`
- `ext.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT`
- `imageSize`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the number of bytes to read from the buffer
bound to `gl.PIXEL_UNPACK_BUFFER`.
- `offset`
- : A {{domxref("WebGL_API/Types", "GLintptr")}} specifying the offset in bytes from which to read from the
buffer bound to `gl.PIXEL_UNPACK_BUFFER`.
- `srcData`
- : A {{jsxref("TypedArray")}} or a {{jsxref("DataView")}} that will be used as a data store for the compressed
image data in memory.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
const ext =
gl.getExtension("WEBGL_compressed_texture_s3tc") ||
gl.getExtension("MOZ_WEBGL_compressed_texture_s3tc") ||
gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
gl.compressedTexSubImage2D(
gl.TEXTURE_2D,
0,
256,
256,
512,
512,
ext.COMPRESSED_RGBA_S3TC_DXT5_EXT,
textureData,
);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Using WebGL extensions](/en-US/docs/Web/API/WebGL_API/Using_Extensions)
- {{domxref("WebGLRenderingContext.getExtension()")}}
- {{domxref("WebGLRenderingContext.compressedTexImage2D()")}}
- {{domxref("WEBGL_compressed_texture_s3tc")}}
- {{domxref("WEBGL_compressed_texture_s3tc_srgb")}}
- {{domxref("WEBGL_compressed_texture_etc")}}
- {{domxref("WEBGL_compressed_texture_pvrtc")}}
- {{domxref("WEBGL_compressed_texture_astc")}}
- {{domxref("EXT_texture_compression_bptc")}}
- {{domxref("EXT_texture_compression_rgtc")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/drawingbuffercolorspace/index.md | ---
title: "WebGLRenderingContext: drawingBufferColorSpace property"
short-title: drawingBufferColorSpace
slug: Web/API/WebGLRenderingContext/drawingBufferColorSpace
page-type: web-api-instance-property
browser-compat: api.WebGLRenderingContext.drawingBufferColorSpace
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.drawingBufferColorSpace`** property specifies the color space of the WebGL drawing buffer. Along with the default (`srgb`), the `display-p3` color space can be used.
See [`WebGLRenderingContext.unpackColorSpace`](/en-US/docs/Web/API/WebGLRenderingContext/unpackColorSpace) for specifying the color space for textures.
## Value
This property can have the following values:
- `"srgb"` selects the [sRGB color space](https://en.wikipedia.org/wiki/SRGB). This is the default value.
- `"display-p3"` selects the [display-p3 color space](https://en.wikipedia.org/wiki/DCI-P3).
If an invalid value is specified, then the value of `drawingBufferColorSpace` will remain unchanged.
## Examples
### Setting the drawing buffer color space to draw a Display P3 red
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.drawingBufferColorSpace = "display-p3";
gl.clearColor(1, 0, 0, 1);
gl.clear(glP3.COLOR_BUFFER_BIT);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [`WebGLRenderingContext.unpackColorSpace`](/en-US/docs/Web/API/WebGLRenderingContext/unpackColorSpace)
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/generatemipmap/index.md | ---
title: "WebGLRenderingContext: generateMipmap() method"
short-title: generateMipmap()
slug: Web/API/WebGLRenderingContext/generateMipmap
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.generateMipmap
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.generateMipmap()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) generates a set of mipmaps for a
{{domxref("WebGLTexture")}} object.
Mipmaps are used to create distance with objects. A higher-resolution mipmap is used
for objects that are closer, and a lower-resolution mipmap is used for objects that are
farther away. It starts with the resolution of the texture image and halves the
resolution until a 1x1 dimension texture image is created.
## Syntax
```js-nolint
generateMipmap(target)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target) of the active texture
whose mipmaps will be generated. Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP`: A cube-mapped texture.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.TEXTURE_3D`: A three-dimensional texture.
- `gl.TEXTURE_2D_ARRAY`: A two-dimensional array texture.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.generateMipmap(gl.TEXTURE_2D);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createTexture()")}}
- {{domxref("WebGLRenderingContext.bindTexture()")}}
- {{domxref("WebGLRenderingContext.getTexParameter()")}}
- {{domxref("WebGLRenderingContext.texParameter",
"WebGLRenderingContext.texParameterf()")}}
- {{domxref("WebGLRenderingContext.texParameter",
"WebGLRenderingContext.texParameteri()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/stencilfuncseparate/index.md | ---
title: "WebGLRenderingContext: stencilFuncSeparate() method"
short-title: stencilFuncSeparate()
slug: Web/API/WebGLRenderingContext/stencilFuncSeparate
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.stencilFuncSeparate
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.stencilFuncSeparate()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets the front and/or back
function and reference value for stencil testing.
Stencilling enables and disables drawing on a per-pixel basis. It is typically used in
multipass rendering to achieve special effects.
## Syntax
```js-nolint
stencilFuncSeparate(face, func, ref, mask)
```
### Parameters
- `face`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying whether the front and/or back stencil state is
updated. The possible values are:
- `gl.FRONT`
- `gl.BACK`
- `gl.FRONT_AND_BACK`
- `func`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the test function. The default function is
`gl.ALWAYS`. The possible values are:
- `gl.NEVER`: Never pass.
- `gl.LESS`: Pass if `(ref & mask) < (stencil & mask)`.
- `gl.EQUAL`: Pass if `(ref & mask) = (stencil & mask)`.
- `gl.LEQUAL`: Pass if `(ref & mask) <= (stencil & mask)`.
- `gl.GREATER`: Pass if `(ref & mask) > (stencil & mask)`.
- `gl.NOTEQUAL`: Pass if `(ref & mask) !== (stencil & mask)`.
- `gl.GEQUAL`: Pass if `(ref & mask) >= (stencil & mask)`.
- `gl.ALWAYS`: Always pass.
- `ref`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the reference value for the stencil test. This
value is clamped to the range 0 to 2^n - 1 where n is the number of bitplanes
in the stencil buffer. The default value is 0.
- `mask`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying a bit-wise mask that is used to AND the reference
value and the stored stencil value when the test is done. The default value is all 1.
### Return value
None ({{jsxref("undefined")}}).
## Examples
The stencil testing is disabled by default. To enable or disable stencil testing, use
the {{domxref("WebGLRenderingContext.enable", "enable()")}} and
{{domxref("WebGLRenderingContext.disable", "disable()")}} methods with the argument
`gl.STENCIL_TEST`.
```js
gl.enable(gl.STENCIL_TEST);
gl.stencilFuncSeparate(gl.FRONT, gl.LESS, 0.2, 1110011);
```
To get the current stencil function, reference value, or other stencil information,
query the following constants with {{domxref("WebGLRenderingContext.getParameter",
"getParameter()")}}.
```js
gl.getParameter(gl.STENCIL_FUNC);
gl.getParameter(gl.STENCIL_VALUE_MASK);
gl.getParameter(gl.STENCIL_REF);
gl.getParameter(gl.STENCIL_BACK_FUNC);
gl.getParameter(gl.STENCIL_BACK_VALUE_MASK);
gl.getParameter(gl.STENCIL_BACK_REF);
gl.getParameter(gl.STENCIL_BITS);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.stencilFunc()")}}
- {{domxref("WebGLRenderingContext.stencilMask()")}}
- {{domxref("WebGLRenderingContext.stencilMaskSeparate()")}}
- {{domxref("WebGLRenderingContext.stencilOp()")}}
- {{domxref("WebGLRenderingContext.stencilOpSeparate()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getprograminfolog/index.md | ---
title: "WebGLRenderingContext: getProgramInfoLog() method"
short-title: getProgramInfoLog()
slug: Web/API/WebGLRenderingContext/getProgramInfoLog
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getProgramInfoLog
---
{{APIRef("WebGL")}}
The **WebGLRenderingContext.getProgramInfoLog** returns the information
log for the specified {{domxref("WebGLProgram")}} object. It contains errors that
occurred during failed linking or validation of `WebGLProgram` objects.
## Syntax
```js-nolint
getProgramInfoLog(program)
```
### Parameters
- `program`
- : The {{domxref("WebGLProgram")}} to query.
### Return value
A string that contains diagnostic messages, warning messages, and
other information about the last linking or validation operation. When a
{{domxref("WebGLProgram")}} object is initially created, its information log will be a
string of length 0.
## Examples
### Checking program errors
```js
const program = gl.createProgram();
// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
gl.getProgramInfoLog(program);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getShaderInfoLog()")}}
- {{domxref("WebGLRenderingContext.getError()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/renderbufferstorage/index.md | ---
title: "WebGLRenderingContext: renderbufferStorage() method"
short-title: renderbufferStorage()
slug: Web/API/WebGLRenderingContext/renderbufferStorage
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.renderbufferStorage
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.renderbufferStorage()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) creates and initializes a
renderbuffer object's data store.
## Syntax
```js-nolint
renderbufferStorage(target, internalFormat, width, height)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the target renderbuffer object. Possible values:
- `gl.RENDERBUFFER`
- : Buffer data storage for single images in a renderable internal format.
- `internalFormat`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the internal format of the renderbuffer. Possible
values:
- `gl.RGBA4`: 4 red bits, 4 green bits, 4 blue bits 4 alpha bits.
- `gl.RGB565`: 5 red bits, 6 green bits, 5 blue bits.
- `gl.RGB5_A1`: 5 red bits, 5 green bits, 5 blue bits, 1 alpha bit.
- `gl.DEPTH_COMPONENT16`: 16 depth bits.
- `gl.STENCIL_INDEX8`: 8 stencil bits.
- `gl.DEPTH_STENCIL`
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.R8`
- `gl.R8UI`
- `gl.R8I`
- `gl.R16UI`
- `gl.R16I`
- `gl.R32UI`
- `gl.R32I`
- `gl.RG8`
- `gl.RG8UI`
- `gl.RG8I`
- `gl.RG16UI`
- `gl.RG16I`
- `gl.RG32UI`
- `gl.RG32I`
- `gl.RGB8`
- `gl.RGBA8`
- `gl.SRGB8_ALPHA8` (also available as an extension for WebGL 1, see below)
- `gl.RGB10_A2`
- `gl.RGBA8UI`
- `gl.RGBA8I`
- `gl.RGB10_A2UI`
- `gl.RGBA16UI`
- `gl.RGBA16I`
- `gl.RGBA32I`
- `gl.RGBA32UI`
- `gl.DEPTH_COMPONENT24`
- `gl.DEPTH_COMPONENT32F`
- `gl.DEPTH24_STENCIL8`
- `gl.DEPTH32F_STENCIL8`
When using the {{domxref("WEBGL_color_buffer_float")}} extension:
- `ext.RGBA32F_EXT`: RGBA 32-bit floating-point type.
- `ext.RGB32F_EXT`: RGB 32-bit floating-point type.
When using the {{domxref("EXT_sRGB")}} extension:
- `ext.SRGB8_ALPHA8_EXT`: 8-bit sRGB and alpha.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}} and
the {{domxref("EXT_color_buffer_float")}} extension:
- `gl.R16F`
- `gl.RG16F`
- `gl.RGBA16F`
- `gl.R32F`
- `gl.RG32F`
- `gl.RGBA32F`
- `gl.R11F_G11F_B10F`
- `width`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the renderbuffer in pixels.
- `height`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the renderbuffer in pixels.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.createRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.deleteRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.getRenderbufferParameter()")}}
- {{domxref("WEBGL_color_buffer_float")}}
- {{domxref("EXT_sRGB")}}
- {{domxref("EXT_color_buffer_float")}}
- {{domxref("EXT_texture_norm16")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/framebuffertexture2d/index.md | ---
title: "WebGLRenderingContext: framebufferTexture2D() method"
short-title: framebufferTexture2D()
slug: Web/API/WebGLRenderingContext/framebufferTexture2D
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.framebufferTexture2D
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.framebufferTexture2D()`** method
of the [WebGL API](/en-US/docs/Web/API/WebGL_API) attaches a texture to a
{{domxref("WebGLFramebuffer")}}.
## Syntax
```js-nolint
framebufferTexture2D(target, attachment, textarget, texture, level)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.FRAMEBUFFER`
- : Collection buffer data storage of color, alpha,
depth and stencil buffers used to render an image.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.DRAW_FRAMEBUFFER`
- : Used as a destination for drawing,
rendering, clearing, and writing operations.
- `gl.READ_FRAMEBUFFER`
- : Used as a source for reading operations.
When binding, `gl.FRAMEBUFFER` sets both the
`gl.DRAW_FRAMEBUFFER` and `gl.READ_FRAMEBUFFER` binding
points. When referencing, `gl.FRAMEBUFFER` refers to the
`gl.DRAW_FRAMEBUFFER` binding
- `attachment`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the attachment point for the
`texture`. Possible values:
- `gl.COLOR_ATTACHMENT0`: Attaches the texture to the framebuffer's
color buffer.
- `gl.DEPTH_ATTACHMENT`: Attaches the texture to the framebuffer's
depth buffer.
- `gl.STENCIL_ATTACHMENT`: Attaches the texture to the framebuffer's
stencil buffer.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.DEPTH_STENCIL_ATTACHMENT`: depth and stencil buffer.
- `gl.COLOR_ATTACHMENT1 gl.COLOR_ATTACHMENT2 gl.COLOR_ATTACHMENT3 gl.COLOR_ATTACHMENT4 gl.COLOR_ATTACHMENT5 gl.COLOR_ATTACHMENT6 gl.COLOR_ATTACHMENT7 gl.COLOR_ATTACHMENT8 gl.COLOR_ATTACHMENT9 gl.COLOR_ATTACHMENT10 gl.COLOR_ATTACHMENT11 gl.COLOR_ATTACHMENT12 gl.COLOR_ATTACHMENT13 gl.COLOR_ATTACHMENT14 gl.COLOR_ATTACHMENT15`
When using the {{domxref("WEBGL_draw_buffers")}} extension:
- `ext.COLOR_ATTACHMENT0_WEBGL` (same as
`gl.COLOR_ATTACHMENT0`)
- `ext.COLOR_ATTACHMENT1_WEBGL ext.COLOR_ATTACHMENT2_WEBGL ext.COLOR_ATTACHMENT3_WEBGL ext.COLOR_ATTACHMENT4_WEBGL ext.COLOR_ATTACHMENT5_WEBGL ext.COLOR_ATTACHMENT6_WEBGL ext.COLOR_ATTACHMENT7_WEBGL ext.COLOR_ATTACHMENT8_WEBGL ext.COLOR_ATTACHMENT9_WEBGL ext.COLOR_ATTACHMENT10_WEBGL ext.COLOR_ATTACHMENT11_WEBGL ext.COLOR_ATTACHMENT12_WEBGL ext.COLOR_ATTACHMENT13_WEBGL ext.COLOR_ATTACHMENT14_WEBGL ext.COLOR_ATTACHMENT15_WEBGL`
When using the {{domxref("WEBGL_depth_texture")}} extension:
- `gl.DEPTH_STENCIL_ATTACHMENT`: Depth and stencil buffer data storage.
- `textarget`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the texture target. Possible values:
- `gl.TEXTURE_2D`: A 2D image.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_X`: Image for the positive X face of
the cube.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_X`: Image for the negative X face of
the cube.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Y`: Image for the positive Y face of
the cube.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Y`: Image for the negative Y face of
the cube.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Z`: Image for the positive Z face of
the cube.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Z`: Image for the negative Z face of
the cube.
- `texture`
- : A {{domxref("WebGLTexture")}} object whose image to attach.
- `level`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the mipmap level of the texture image to be
attached. Must be 0.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- A `gl.INVALID_ENUM` error is thrown if
- `target` is not `gl.FRAMEBUFFER`.
- `attachment` is not one of the accepted attachment points.
- `textarget` is not one of the accepted texture targets.
- A `gl.INVALID_VALUE` error is thrown if `level` is not 0.
- A `gl.INVALID_OPERATION` error is thrown if `texture` isn't 0
or the name of an existing texture object.
## Examples
```js
gl.framebufferTexture2D(
gl.FRAMEBUFFER,
gl.COLOR_ATTACHMENT0,
gl.TEXTURE_2D,
texture,
0,
);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createFramebuffer()")}}
- {{domxref("WebGLRenderingContext.deleteFramebuffer()")}}
- {{domxref("WebGLRenderingContext.isFramebuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLRenderbuffer")}}
- {{domxref("WEBGL_depth_texture")}}
- {{domxref("WEBGL_draw_buffers")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/enable/index.md | ---
title: "WebGLRenderingContext: enable() method"
short-title: enable()
slug: Web/API/WebGLRenderingContext/enable
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.enable
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.enable()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) enables specific WebGL capabilities
for this context.
## Syntax
```js-nolint
enable(cap)
```
### Parameters
- `cap`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying which WebGL capability to enable. Possible
values:
| Constant | Description |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gl.BLEND` | Activates blending of the computed fragment color values. See {{domxref("WebGLRenderingContext.blendFunc()")}}. |
| `gl.CULL_FACE` | Activates culling of polygons. See {{domxref("WebGLRenderingContext.cullFace()")}}. |
| `gl.DEPTH_TEST` | Activates depth comparisons and updates to the depth buffer. See {{domxref("WebGLRenderingContext.depthFunc()")}}. |
| `gl.DITHER` | Activates dithering of color components before they get written to the color buffer. |
| `gl.POLYGON_OFFSET_FILL` | Activates adding an offset to depth values of polygon's fragments. See {{domxref("WebGLRenderingContext.polygonOffset()")}}. |
| `gl.SAMPLE_ALPHA_TO_COVERAGE` | Activates the computation of a temporary coverage value determined by the alpha value. |
| `gl.SAMPLE_COVERAGE` | Activates ANDing the fragment's coverage with the temporary coverage value. See {{domxref("WebGLRenderingContext.sampleCoverage()")}}. |
| `gl.SCISSOR_TEST` | Activates the scissor test that discards fragments that are outside of the scissor rectangle. See {{domxref("WebGLRenderingContext.scissor()")}}. |
| `gl.STENCIL_TEST` | Activates stencil testing and updates to the stencil buffer. See {{domxref("WebGLRenderingContext.stencilFunc()")}}. |
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the
following values are available additionally:
| Constant | Description |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gl.RASTERIZER_DISCARD` | Primitives are discarded immediately before the rasterization stage, but after the optional transform feedback stage. `gl.clear()` commands are ignored. |
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.enable(gl.DITHER);
```
To check if a capability is enabled, use the
{{domxref("WebGLRenderingContext.isEnabled()")}} method:
```js
gl.isEnabled(gl.DITHER);
// true
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.disable()")}}
- {{domxref("WebGLRenderingContext.isEnabled()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getuniformlocation/index.md | ---
title: "WebGLRenderingContext: getUniformLocation() method"
short-title: getUniformLocation()
slug: Web/API/WebGLRenderingContext/getUniformLocation
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getUniformLocation
---
{{APIRef("WebGL")}}
Part of the [WebGL API](/en-US/docs/Web/API/WebGL_API), the {{domxref("WebGLRenderingContext")}} method
**`getUniformLocation()`** returns the location of a
specific **uniform** variable which is part of a given
{{domxref("WebGLProgram")}}.
The uniform variable is returned as a
{{domxref("WebGLUniformLocation")}} object, which is an opaque identifier used to
specify where in the GPU's memory that uniform variable is located.
Once you have the uniform's location, you can access the uniform itself using one of
the other uniform access methods, passing in the uniform location as one of the
inputs:
- {{domxref("WebGLRenderingContext.getUniform", "getUniform()")}}
- : Returns the value of the uniform at the given location.
<!-- markdownlint-disable MD052 -- text in code block is misidentified as image -->
- [`WebGLRenderingContext.uniform[1234][fi][v]()`](/en-US/docs/Web/API/WebGLRenderingContext/uniform)
- : Sets the uniform's value to the specified value, which may be a single floating
point or integer number, or a 2-4 component vector specified either as a list of
values or as a {{jsxref("Float32Array")}} or {{jsxref("Int32Array")}}.
<!-- markdownlint-disable MD052 — text in code block is misidentified as image -->
- [`WebGLRenderingContext.uniformMatrix[234][fv]()`](/en-US/docs/Web/API/WebGLRenderingContext/uniformMatrix)
- : Sets the uniform's value to the specified matrix, possibly with transposition. The
value is represented as a sequence of `GLfloat` values or as a
`Float32Array`.
The uniform itself is declared in the shader program using GLSL.
## Syntax
```js-nolint
getUniformLocation(program, name)
```
### Parameters
- `program`
- : The {{domxref("WebGLProgram")}} in which to locate the specified uniform variable.
- `name`
- : A string specifying the name of the uniform variable whose
location is to be returned. The name can't have any whitespace in it, and you
can't use this function to get the location of any uniforms starting with the
reserved string `"gl_"`, since those are internal to the WebGL
layer.
The possible values correspond to the uniform names returned by
{{domxref("WebGLRenderingContext.getActiveUniform()", "getActiveUniform")}}; see
that function for specifics on how declared uniforms map to uniform location
names.
Additionally, for uniforms declared as arrays, the following names are also
valid:
- The uniform name without the `[0]` suffix. E.g. the location
returned for `arrayUniform` is equivalent to the one for
`arrayUniform[0]`.
- The uniform name indexed with an integer. E.g. the location returned for
`arrayUniform[2]` would point directly to the third entry of
the `arrayUniform` uniform.
### Return value
A {{domxref("WebGLUniformLocation")}} value indicating the location of the named
variable, if it exists. If the specified variable doesn't exist, [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null) is
returned instead.
The `WebGLUniformLocation` is an opaque value used to uniquely identify the
location in the GPU's memory at which the uniform variable is located. With this value
in hand, you can call other WebGL methods to access the value of the uniform variable.
> **Note:** The `WebGLUniformLocation` type is compatible with the
> `GLint` type when specifying the index or location of a uniform
> attribute.
### Errors
The following errors may occur; to check for errors after
`getUniformLocation()` returns, call
{{domxref("WebGLRenderingContext.getError", "getError()")}}.
- `GL_INVALID_VALUE`
- : The `program` parameter is not a value or object generated by WebGL.
- `GL_INVALID_OPERATION`
- : The `program` parameter doesn't correspond to a GLSL program generated
by WebGL, or the specified program hasn't been linked successfully.
## Examples
In this example, taken from the `animateScene()` method in the article [A basic 2D WebGL animation example](/en-US/docs/Web/API/WebGL_API/Basic_2D_animation_example#drawing_and_animating_the_scene), obtains the locations of three uniforms from
the shading program, then sets the value of each of the three uniforms.
```js
gl.useProgram(shaderProgram);
uScalingFactor = gl.getUniformLocation(shaderProgram, "uScalingFactor");
uGlobalColor = gl.getUniformLocation(shaderProgram, "uGlobalColor");
uRotationVector = gl.getUniformLocation(shaderProgram, "uRotationVector");
gl.uniform2fv(uScalingFactor, currentScale);
gl.uniform2fv(uRotationVector, currentRotation);
gl.uniform4fv(uGlobalColor, [0.1, 0.7, 0.2, 1.0]);
```
> **Note:** This code snippet is taken from [the function `animateScene()`](/en-US/docs/Web/API/WebGL_API/Basic_2D_animation_example#drawing_and_animating_the_scene) in "A basic 2D WebGL animation example."
> See that article for the full sample and to see the resulting animation in action.
After setting the current shading program to `shaderProgram`, this code
fetches the three uniforms `"uScalingFactor"`, `"uGlobalColor"`,
and `"uRotationVector"`, calling `getUniformLocation()` once for
each uniform.
Then the three uniforms' values are set:
- The `uScalingFactor` uniform — a 2-component vertex — receives the
horizontal and vertical scaling factors from the variable
`currentScale`.
- The uniform `uRotationVector` is set to the contents of the variable
`currentRotation`. This, too, is a 2-component vertex.
- Finally, the uniform `uGlobalColor` is set to the color
`[0.1, 0.7, 0.2, 1.0]`, the components in this 4-component vector
represent the values of red, green, blue, and alpha, respectively.
Having done this, the next time the shading functions are called, their own variables
named `uScalingFactor`, `uGlobalColor`, and
`uRotationVector` will all have the values provided by the JavaScript code.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getAttribLocation()")}}
- {{domxref("WebGLRenderingContext.getActiveUniform()")}}
- {{domxref("WebGLUniformLocation")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/hint/index.md | ---
title: "WebGLRenderingContext: hint() method"
short-title: hint()
slug: Web/API/WebGLRenderingContext/hint
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.hint
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.hint()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies hints for certain
behaviors. The interpretation of these hints depend on the implementation.
## Syntax
```js-nolint
hint(target, mode)
```
### Parameters
- `target`
- : Sets which behavior to be controlled. Possible values:
- `gl.GENERATE_MIPMAP_HINT`
- : Quality of filtering when generating
mipmap images with {{domxref("WebGLRenderingContext.generateMipmap()")}}.
When using the {{domxref("OES_standard_derivatives")}} extension:
- `ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES`
- : Accuracy of the
derivative calculation for the GLSL built-in functions: `dFdx`,
`dFdy`, and `fwidth`.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.FRAGMENT_SHADER_DERIVATIVE_HINT`
- : Same as `ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES`
- `mode`
- : Sets the behavior. The default value is `gl.DONT_CARE`. The possible
values are:
- `gl.FASTEST`: The most efficient behavior should be used.
- `gl.NICEST`: The most correct or the highest quality option should be
used.
- `gl.DONT_CARE`: There is no preference for this behavior.
### Return value
None ({{jsxref("undefined")}}).
## Examples
The following example hints that the quality of filtering when generating mipmap images
should be most efficient instead of the best quality.
```js
gl.hint(gl.GENERATE_MIPMAP_HINT, gl.FASTEST);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.generateMipmap()")}}
- {{domxref("OES_standard_derivatives")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/createbuffer/index.md | ---
title: "WebGLRenderingContext: createBuffer() method"
short-title: createBuffer()
slug: Web/API/WebGLRenderingContext/createBuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.createBuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.createBuffer()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) creates and initializes a
{{domxref("WebGLBuffer")}} storing data such as vertices or colors.
## Syntax
```js-nolint
createBuffer()
```
### Parameters
None.
### Return value
A {{domxref("WebGLBuffer")}} storing data such as vertices or colors.
## Examples
### Creating a buffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const buffer = gl.createBuffer();
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindBuffer()")}}
- {{domxref("WebGLRenderingContext.deleteBuffer()")}}
- {{domxref("WebGLRenderingContext.isBuffer()")}}
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/deletebuffer/index.md | ---
title: "WebGLRenderingContext: deleteBuffer() method"
short-title: deleteBuffer()
slug: Web/API/WebGLRenderingContext/deleteBuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.deleteBuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.deleteBuffer()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) deletes a given
{{domxref("WebGLBuffer")}}. This method has no effect if the buffer has already been
deleted. Normally you don't need to call this method yourself, when the buffer object is dereferenced it will be marked as free.
## Syntax
```js-nolint
deleteBuffer(buffer)
```
### Parameters
- `buffer`
- : A {{domxref("WebGLBuffer")}} object to delete.
### Return value
None ({{jsxref("undefined")}}).
## Examples
### Deleting a buffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const buffer = gl.createBuffer();
// …
gl.deleteBuffer(buffer);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindBuffer()")}}
- {{domxref("WebGLRenderingContext.createBuffer()")}}
- {{domxref("WebGLRenderingContext.isBuffer()")}}
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/readpixels/index.md | ---
title: "WebGLRenderingContext: readPixels() method"
short-title: readPixels()
slug: Web/API/WebGLRenderingContext/readPixels
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.readPixels
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.readPixels()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) reads a block of pixels from a
specified rectangle of the current color framebuffer into a {{jsxref("TypedArray")}} or a {{jsxref("DataView")}} object.
## Syntax
```js-nolint
// WebGL1:
readPixels(x, y, width, height, format, type, pixels)
// WebGL2:
readPixels(x, y, width, height, format, type, offset)
readPixels(x, y, width, height, format, type, pixels)
readPixels(x, y, width, height, format, type, pixels, dstOffset)
```
### Parameters
- `x`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the first horizontal pixel that is read from the
lower left corner of a rectangular block of pixels.
- `y`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the first vertical pixel that is read from the
lower left corner of a rectangular block of pixels.
- `width`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the rectangle.
- `height`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the rectangle.
- `format`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the format of the pixel data. Possible values:
- `gl.ALPHA`
- : Discards the red, green and blue components and reads the
alpha component.
- `gl.RGB`
- : Discards the alpha components and reads the red, green and
blue components.
- `gl.RGBA`
- : Red, green, blue and alpha components are read from the
color buffer.
WebGL2 adds
- `gl.RED`
- `gl.RG`
- `gl.RED_INTEGER`
- `gl.RG_INTEGER`
- `gl.RGB_INTEGER`
- `gl.RGBA_INTEGER`
- `type`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the data type of the pixel data. Possible values:
- `gl.UNSIGNED_BYTE`
- `gl.UNSIGNED_SHORT_5_6_5`
- `gl.UNSIGNED_SHORT_4_4_4_4`
- `gl.UNSIGNED_SHORT_5_5_5_1`
- `gl.FLOAT`
WebGL2 adds
- `gl.BYTE`
- `gl.UNSIGNED_INT_2_10_10_10_REV`
- `gl.HALF_FLOAT`
- `gl.SHORT`
- `gl.UNSIGNED_SHORT`
- `gl.INT`
- `gl.UNSIGNED_INT`
- `gl.UNSIGNED_INT_10F_11F_11F_REV`
- `gl.UNSIGNED_INT_5_9_9_9_REV`
- `pixels`
- : An object to read data into. The array type must
match the type of the `type` parameter:
- {{jsxref("Uint8Array")}} for `gl.UNSIGNED_BYTE`.
- {{jsxref("Uint16Array")}} for `gl.UNSIGNED_SHORT_5_6_5`,
`gl.UNSIGNED_SHORT_4_4_4_4`, or `gl.UNSIGNED_SHORT_5_5_5_1`.
- {{jsxref("Float32Array")}} for `gl.FLOAT`.
- `dstOffset` {{optional_inline}}
- : Offset. Defaults to 0.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- A `gl.INVALID_ENUM` error is thrown if `format` or
`type` is not an accepted value.
- A `gl.INVALID_OPERATION` error is thrown if
- `type` is `gl.UNSIGNED_SHORT_5_6_5` and
`format` is not `gl.RGB`.
- `type` is `gl.UNSIGNED_SHORT_4_4_4_4` and
`format` is not `gl.RGBA`.
- `type` does not match the typed array type of `pixels`.
- A `gl.INVALID_FRAMEBUFFER_OPERATION` error is thrown if the currently
bound framebuffer is not framebuffer complete.
## Examples
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const pixels = new Uint8Array(
gl.drawingBufferWidth * gl.drawingBufferHeight * 4,
);
gl.readPixels(
0,
0,
gl.drawingBufferWidth,
gl.drawingBufferHeight,
gl.RGBA,
gl.UNSIGNED_BYTE,
pixels,
);
console.log(pixels); // Uint8Array
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Typed Arrays](/en-US/docs/Web/JavaScript/Guide/Typed_arrays)
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/copytexsubimage2d/index.md | ---
title: "WebGLRenderingContext: copyTexSubImage2D() method"
short-title: copyTexSubImage2D()
slug: Web/API/WebGLRenderingContext/copyTexSubImage2D
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.copyTexSubImage2D
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.copyTexSubImage2D()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) copies pixels from the current
{{domxref("WebGLFramebuffer")}} into an existing 2D texture sub-image.
## Syntax
```js-nolint
copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target) of the active texture.
Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_X`: Positive X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_X`: Negative X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Y`: Positive Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Y`: Negative Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Z`: Positive Z face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Z`: Negative Z face for a cube-mapped
texture.
- `level`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the level of detail. Level 0 is the base image
level and level _n_ is the n-th mipmap reduction level.
- `xoffset`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the horizontal offset within the texture image.
- `yoffset`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the vertical offset within the texture image.
- `x`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the x coordinate of the lower left corner where to
start copying.
- `y`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the y coordinate of the lower left corner where to
start copying.
- `width`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the texture.
- `height`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the texture.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 16, 16);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.copyTexImage2D()")}}
- {{domxref("WebGLRenderingContext.texImage2D()")}}
- {{domxref("WebGLRenderingContext.texSubImage2D()")}}
- {{domxref("WebGLRenderingContext.compressedTexImage2D()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/bufferdata/index.md | ---
title: "WebGLRenderingContext: bufferData() method"
short-title: bufferData()
slug: Web/API/WebGLRenderingContext/bufferData
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.bufferData
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.bufferData()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) initializes and creates the
buffer object's data store.
## Syntax
```js-nolint
// WebGL1
bufferData(target, usage)
bufferData(target, size, usage)
bufferData(target, srcData, usage)
// WebGL2
bufferData(target, usage, srcOffset)
bufferData(target, srcData, usage, srcOffset)
bufferData(target, srcData, usage, srcOffset, length)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.ARRAY_BUFFER`
- : Buffer containing vertex attributes, such as
vertex coordinates, texture coordinate data, or vertex color data.
- `gl.ELEMENT_ARRAY_BUFFER`
- : Buffer used for element indices.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:
- `gl.COPY_READ_BUFFER`
- : Buffer for copying from one buffer object to another.
- `gl.COPY_WRITE_BUFFER`
- : Buffer for copying from one buffer object to another.
- `gl.TRANSFORM_FEEDBACK_BUFFER`
- : Buffer for transform feedback operations.
- `gl.UNIFORM_BUFFER`
- : Buffer used for storing uniform blocks.
- `gl.PIXEL_PACK_BUFFER`
- : Buffer used for pixel transfer operations.
- `gl.PIXEL_UNPACK_BUFFER`
- : Buffer used for pixel transfer operations.
- `size`
- : A {{domxref("WebGL_API/Types", "GLsizeiptr")}} setting the size in bytes of the buffer object's data
store.
- `srcData` {{optional_inline}}
- : An {{jsxref("ArrayBuffer")}}, {{jsxref("SharedArrayBuffer")}}, a {{jsxref("TypedArray")}} or a {{jsxref("DataView")}}
that will be copied into the data store.
If `null`, a data store is still created, but the content is uninitialized and undefined.
- `usage`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the intended usage pattern of the data store
for optimization purposes. Possible values:
- `gl.STATIC_DRAW`
- : The contents are intended to be specified
once by the application, and used many times as the source for WebGL
drawing and image specification commands.
- `gl.DYNAMIC_DRAW`
- : The contents are intended to be respecified
repeatedly by the application, and used many times as the source for WebGL
drawing and image specification commands.
- `gl.STREAM_DRAW`
- : The contents are intended to be specified
once by the application, and used at most a few times as the source for
WebGL drawing and image specification commands.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:
- `gl.STATIC_READ`
- : The contents are intended to be
specified once by reading data from WebGL, and queried many times
by the application.
- `gl.DYNAMIC_READ`
- : The contents are intended to be
respecified repeatedly by reading data from WebGL, and queried
many times by the application.
- `gl.STREAM_READ`
- : The contents are intended to be
specified once by reading data from WebGL, and queried at most a
few times by the application
- `gl.STATIC_COPY`
- : The contents are intended to be
specified once by reading data from WebGL, and used many times as
the source for WebGL drawing and image specification commands.
- `gl.DYNAMIC_COPY`
- : The contents are intended to be
respecified repeatedly by reading data from WebGL, and used many
times as the source for WebGL drawing and image specification
commands.
- `gl.STREAM_COPY`
- : The contents are intended to be
specified once by reading data from WebGL, and used at most a few
times as the source for WebGL drawing and image specification
commands.
- `srcOffset`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the element index offset where to start reading
the buffer.
- `length` {{optional_inline}}
- : A {{domxref("WebGL_API/Types", "GLuint")}} defaulting to 0.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- A `gl.OUT_OF_MEMORY` error is thrown if the context is unable to create
a data store with the given `size`.
- A `gl.INVALID_VALUE` error is thrown if `size` is negative.
- A `gl.INVALID_ENUM` error is thrown if `target` or
`usage` are not one of the allowed enums.
## Examples
### Using bufferData
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
```
### Getting buffer information
To check the current buffer usage and buffer size, use the
{{domxref("WebGLRenderingContext.getBufferParameter()")}} method.
```js
gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE);
gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE);
```
### Getting size of a typed array
To calculate size parameter for a typed array.
```js
const dataArray = new Float32Array([1, 2, 3, 4]);
const sizeInBytes = dataArray.length * dataArray.BYTES_PER_ELEMENT;
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createBuffer()")}}
- {{domxref("WebGLRenderingContext.bufferSubData()")}}
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getsupportedextensions/index.md | ---
title: "WebGLRenderingContext: getSupportedExtensions() method"
short-title: getSupportedExtensions()
slug: Web/API/WebGLRenderingContext/getSupportedExtensions
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getSupportedExtensions
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getSupportedExtensions()`** method
returns a list of all the supported [WebGL](/en-US/docs/Web/API/WebGL_API)
extensions.
## Syntax
```js-nolint
getSupportedExtensions()
```
### Parameters
None.
### Return value
An {{jsxref("Array")}} of strings with all the supported WebGL extensions.
## Examples
```js
const canvas = document.getElementById("canvas");
gl = canvas.getContext("webgl");
const extensions = gl.getSupportedExtensions();
// Array [ 'ANGLE_instanced_arrays', 'EXT_blend_minmax', … ]
```
See also the {{domxref("WebGLRenderingContext.getExtension()")}} method to get a
specific extension object.
## WebGL extensions
Extensions for the WebGL API are registered in the [WebGL Extension Registry](https://www.khronos.org/registry/webgl/extensions/). They are also listed [here](/en-US/docs/Web/API/WebGL_API#extensions).
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getExtension()")}}
- [webglreport.com](https://webglreport.com)
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/isprogram/index.md | ---
title: "WebGLRenderingContext: isProgram() method"
short-title: isProgram()
slug: Web/API/WebGLRenderingContext/isProgram
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.isProgram
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.isProgram()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns `true` if the
passed {{domxref("WebGLProgram")}} is valid, `false` otherwise.
## Syntax
```js-nolint
isProgram(program)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} to check.
### Return value
A {{domxref("WebGL_API/Types", "GLboolean")}} indicating whether or not the program is valid.
## Examples
### Checking a program
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const program = gl.createProgram();
// …
gl.isProgram(program);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createProgram()")}}
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- {{domxref("WebGLRenderingContext.useProgram()")}}
- {{domxref("WebGLRenderingContext.validateProgram()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getattachedshaders/index.md | ---
title: "WebGLRenderingContext: getAttachedShaders() method"
short-title: getAttachedShaders()
slug: Web/API/WebGLRenderingContext/getAttachedShaders
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getAttachedShaders
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getAttachedShaders()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns a list of
{{domxref("WebGLShader")}} objects attached to a {{domxref("WebGLProgram")}}.
## Syntax
```js-nolint
getAttachedShaders(program)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} object to get attached shaders for.
### Return value
An {{jsxref("Array")}} of {{domxref("WebGLShader")}} objects that are attached to the
given `WebGLProgram`.
## Examples
```js
const program = gl.createProgram();
// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
gl.getAttachedShaders(program);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createShader()")}}
- {{domxref("WebGLRenderingContext.isShader()")}}
- {{domxref("WebGLRenderingContext.deleteShader()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/teximage2d/index.md | ---
title: "WebGLRenderingContext: texImage2D() method"
short-title: texImage2D()
slug: Web/API/WebGLRenderingContext/texImage2D
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.texImage2D
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.texImage2D()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies a two-dimensional texture
image.
## Syntax
```js-nolint
// WebGL1
texImage2D(target, level, internalformat, width, height, border, format, type, pixels)
texImage2D(target, level, internalformat, format, type, pixels)
// WebGL2
texImage2D(target, level, internalformat, width, height, border, format, type, offset)
texImage2D(target, level, internalformat, width, height, border, format, type, source)
texImage2D(target, level, internalformat, width, height, border, format, type, srcData, srcOffset)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target) of the active texture.
Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_X`: Positive X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_X`: Negative X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Y`: Positive Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Y`: Negative Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Z`: Positive Z face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Z`: Negative Z face for a cube-mapped
texture.
- `level`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the level of detail. Level 0 is the base image
level and level _n_ is the n-th mipmap reduction level.
- `internalformat`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the color components in the texture.
Possible values in both WebGL1 and WebGL2
<table>
<thead>
<tr>
<td>Format</td>
<td>Type</td>
<td>Channels</td>
<td>Bytes per pixel</td>
</tr>
</thead>
<tbody>
<tr>
<td>RGBA</td>
<td>UNSIGNED_BYTE</td>
<td>4</td>
<td>4</td>
</tr>
<tr>
<td>RGB</td>
<td>UNSIGNED_BYTE</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td>RGBA</td>
<td>UNSIGNED_SHORT_4_4_4_4</td>
<td>4</td>
<td>2</td>
</tr>
<tr>
<td>RGBA</td>
<td>UNSIGNED_SHORT_5_5_5_1</td>
<td>4</td>
<td>2</td>
</tr>
<tr>
<td>RGB</td>
<td>UNSIGNED_SHORT_5_6_5</td>
<td>3</td>
<td>2</td>
</tr>
<tr>
<td>LUMINANCE_ALPHA</td>
<td>UNSIGNED_BYTE</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>LUMINANCE</td>
<td>UNSIGNED_BYTE</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>ALPHA</td>
<td>UNSIGNED_BYTE</td>
<td>1</td>
<td>1</td>
</tr>
</tbody>
</table>
Other possible values in WebGL2 for the versions of `texImage2D` that
take a {{jsxref("TypedArray")}} or a {{jsxref("DataView")}}, or a `GLintptr offset`
<table>
<thead>
<tr>
<td>
<strong>Sized<br />Format</strong>
</td>
<td>
<strong>Base<br />Format</strong>
</td>
<td>
<strong>R<br />bits</strong>
</td>
<td>
<strong>G<br />bits</strong>
</td>
<td>
<strong>B<br />bits</strong>
</td>
<td>
<strong>A<br />bits</strong>
</td>
<td>
<strong>Shared<br />bits</strong>
</td>
<td>
<strong>Color<br />renderable</strong>
</td>
<td>
<strong>Texture<br />filterable</strong>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>R8</td>
<td>RED</td>
<td>8</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<td>R8_SNORM</td>
<td>RED</td>
<td>s8</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>RG8</td>
<td>RG</td>
<td>8</td>
<td>8</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<td>RG8_SNORM</td>
<td>RG</td>
<td>s8</td>
<td>s8</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>RGB8</td>
<td>RGB</td>
<td>8</td>
<td>8</td>
<td>8</td>
<td></td>
<td></td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<td>RGB8_SNORM</td>
<td>RGB</td>
<td>s8</td>
<td>s8</td>
<td>s8</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>RGB565</td>
<td>RGB</td>
<td>5</td>
<td>6</td>
<td>5</td>
<td></td>
<td></td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<td>RGBA4</td>
<td>RGBA</td>
<td>4</td>
<td>4</td>
<td>4</td>
<td>4</td>
<td></td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<td>RGB5_A1</td>
<td>RGBA</td>
<td>5</td>
<td>5</td>
<td>5</td>
<td>1</td>
<td></td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<td>RGBA8</td>
<td>RGBA</td>
<td>8</td>
<td>8</td>
<td>8</td>
<td>8</td>
<td></td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<td>RGBA8_SNORM</td>
<td>RGBA</td>
<td>s8</td>
<td>s8</td>
<td>s8</td>
<td>s8</td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>RGB10_A2</td>
<td>RGBA</td>
<td>10</td>
<td>10</td>
<td>10</td>
<td>2</td>
<td></td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<td>RGB10_A2UI</td>
<td>RGBA</td>
<td>ui10</td>
<td>ui10</td>
<td>ui10</td>
<td>ui2</td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>SRGB8</td>
<td>RGB</td>
<td>8</td>
<td>8</td>
<td>8</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>SRGB8_ALPHA8</td>
<td>RGBA</td>
<td>8</td>
<td>8</td>
<td>8</td>
<td>8</td>
<td></td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<td>R16F</td>
<td>RED</td>
<td>f16</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>RG16F</td>
<td>RG</td>
<td>f16</td>
<td>f16</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>RGB16F</td>
<td>RGB</td>
<td>f16</td>
<td>f16</td>
<td>f16</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>RGBA16F</td>
<td>RGBA</td>
<td>f16</td>
<td>f16</td>
<td>f16</td>
<td>f16</td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>R32F</td>
<td>RED</td>
<td>f32</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>RG32F</td>
<td>RG</td>
<td>f32</td>
<td>f32</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>RGB32F</td>
<td>RGB</td>
<td>f32</td>
<td>f32</td>
<td>f32</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>RGBA32F</td>
<td>RGBA</td>
<td>f32</td>
<td>f32</td>
<td>f32</td>
<td>f32</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>R11F_G11F_B10F</td>
<td>RGB</td>
<td>f11</td>
<td>f11</td>
<td>f10</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>RGB9_E5</td>
<td>RGB</td>
<td>9</td>
<td>9</td>
<td>9</td>
<td></td>
<td>5</td>
<td></td>
<td>●</td>
</tr>
<tr>
<td>R8I</td>
<td>RED</td>
<td>i8</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>R8UI</td>
<td>RED</td>
<td>ui8</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>R16I</td>
<td>RED</td>
<td>i16</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>R16UI</td>
<td>RED</td>
<td>ui16</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>R32I</td>
<td>RED</td>
<td>i32</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>R32UI</td>
<td>RED</td>
<td>ui32</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RG8I</td>
<td>RG</td>
<td>i8</td>
<td>i8</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RG8UI</td>
<td>RG</td>
<td>ui8</td>
<td>ui8</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RG16I</td>
<td>RG</td>
<td>i16</td>
<td>i16</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RG16UI</td>
<td>RG</td>
<td>ui16</td>
<td>ui16</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RG32I</td>
<td>RG</td>
<td>i32</td>
<td>i32</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RG32UI</td>
<td>RG</td>
<td>ui32</td>
<td>ui32</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RGB8I</td>
<td>RGB</td>
<td>i8</td>
<td>i8</td>
<td>i8</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>RGB8UI</td>
<td>RGB</td>
<td>ui8</td>
<td>ui8</td>
<td>ui8</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>RGB16I</td>
<td>RGB</td>
<td>i16</td>
<td>i16</td>
<td>i16</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>RGB16UI</td>
<td>RGB</td>
<td>ui16</td>
<td>ui16</td>
<td>ui16</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>RGB32I</td>
<td>RGB</td>
<td>i32</td>
<td>i32</td>
<td>i32</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>RGB32UI</td>
<td>RGB</td>
<td>ui32</td>
<td>ui32</td>
<td>ui32</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>RGBA8I</td>
<td>RGBA</td>
<td>i8</td>
<td>i8</td>
<td>i8</td>
<td>i8</td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RGBA8UI</td>
<td>RGBA</td>
<td>ui8</td>
<td>ui8</td>
<td>ui8</td>
<td>ui8</td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RGBA16I</td>
<td>RGBA</td>
<td>i16</td>
<td>i16</td>
<td>i16</td>
<td>i16</td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RGBA16UI</td>
<td>RGBA</td>
<td>ui16</td>
<td>ui16</td>
<td>ui16</td>
<td>ui16</td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RGBA32I</td>
<td>RGBA</td>
<td>i32</td>
<td>i32</td>
<td>i32</td>
<td>i32</td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<td>RGBA32UI</td>
<td>RGBA</td>
<td>ui32</td>
<td>ui32</td>
<td>ui32</td>
<td>ui32</td>
<td></td>
<td>●</td>
<td></td>
</tr>
</tbody>
</table>
Possible values in WebGL2 for the versions of `texImage2D` that take a
texture an `HTMLImageElement`, `HTMLCanvasElement`,
`HTMLVideoElement`, `ImageBitmap`, or `ImageData`
- `gl.ALPHA`: Discards the red, green and blue components and reads the
alpha component.
- `gl.RGB`: Discards the alpha components and reads the red, green and blue
components.
- `gl.RGBA`: Red, green, blue and alpha components are read from the color
buffer.
- `gl.LUMINANCE`: Each color component is a luminance component, alpha is
1.0.
- `gl.LUMINANCE_ALPHA`: Each component is a luminance/alpha component.
When using the {{domxref("WEBGL_depth_texture")}} extension:
- `gl.DEPTH_COMPONENT`
- `gl.DEPTH_STENCIL`
When using the {{domxref("EXT_sRGB")}} extension:
- `ext.SRGB_EXT`
- `ext.SRGB_ALPHA_EXT`
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the
following values are available additionally:
- `gl.R8`
- `gl.R16F`
- `gl.R32F`
- `gl.R8UI`
- `gl.RG8`
- `gl.RG16F`
- `gl.RG32F`
- `gl.RG8UI`
- `gl.RG16UI`
- `gl.RG32UI`
- `gl.RGB8`
- `gl.SRGB8`
- `gl.RGB565`
- `gl.R11F_G11F_B10F`
- `gl.RGB9_E5`
- `gl.RGB16F`
- `gl.RGB32F`
- `gl.RGB8UI`
- `gl.RGBA8`
- `gl.SRGB8_ALPHA8`
- `gl.RGB5_A1`
- `gl.RGB10_A2`
- `gl.RGBA4`
- `gl.RGBA16F`
- `gl.RGBA32F`
- `gl.RGBA8UI`
- `width`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the texture.
- `height`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the texture.
- `border`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the width of the border. Must be 0.
- `format`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the format of the texel data. In WebGL 1, this
must be the same as `internalformat` (see above). in WebGL 2, the
combinations are listed in [this table](https://www.khronos.org/registry/webgl/specs/latest/2.0/#TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE).
- `type`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the data type of the texel data. Possible values:
- `gl.UNSIGNED_BYTE`: 8 bits per channel for `gl.RGBA`
- `gl.UNSIGNED_SHORT_5_6_5`: 5 red bits, 6 green bits, 5 blue bits.
- `gl.UNSIGNED_SHORT_4_4_4_4`: 4 red bits, 4 green bits, 4 blue bits, 4
alpha bits.
- `gl.UNSIGNED_SHORT_5_5_5_1`: 5 red bits, 5 green bits, 5 blue bits, 1
alpha bit.
When using the {{domxref("WEBGL_depth_texture")}} extension:
- `gl.UNSIGNED_SHORT`
- `gl.UNSIGNED_INT`
- `ext.UNSIGNED_INT_24_8_WEBGL` (constant provided by the extension)
- When using the {{domxref("OES_texture_float")}} extension:
- `gl.FLOAT`
When using the {{domxref("OES_texture_half_float")}} extension:
- `ext.HALF_FLOAT_OES` (constant provided by the extension)
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.BYTE`
- `gl.UNSIGNED_SHORT`
- `gl.SHORT`
- `gl.UNSIGNED_INT`
- `gl.INT`
- `gl.HALF_FLOAT`
- `gl.FLOAT`
- `gl.UNSIGNED_INT_2_10_10_10_REV`
- `gl.UNSIGNED_INT_10F_11F_11F_REV`
- `gl.UNSIGNED_INT_5_9_9_9_REV`
- `gl.UNSIGNED_INT_24_8`
- `gl.FLOAT_32_UNSIGNED_INT_24_8_REV` (pixels must be
[`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null))
- `pixels`
- : The following types can always be used as a pixel source for the texture:
- {{domxref("ImageData")}},
- {{domxref("HTMLImageElement")}},
- {{domxref("HTMLCanvasElement")}},
- {{domxref("HTMLVideoElement")}},
- {{domxref("ImageBitmap")}}.
The following types can only be used as a pixel source when `width`, `height`, and `border` are specified:
- {{jsxref("Uint8Array")}} (must be used if `type` is `gl.UNSIGNED_BYTE`)
- {{jsxref("Uint16Array")}} (must be used if `type` is either
`gl.UNSIGNED_SHORT_5_6_5`, `gl.UNSIGNED_SHORT_4_4_4_4`,
`gl.UNSIGNED_SHORT_5_5_5_1`, `gl.UNSIGNED_SHORT` or
`ext.HALF_FLOAT_OES`)
- {{jsxref("Uint32Array")}} (must be used if `type` is `gl.UNSIGNED_INT` or `ext.UNSIGNED_INT_24_8_WEBGL`)
- {{jsxref("Float32Array")}} (must be used if `type` is `gl.FLOAT`)
- `offset`
- : (WebGL 2 only) A {{domxref("WebGL_API/Types", "GLintptr")}} byte offset into the
{{domxref("WebGLBuffer")}}'s data store. Used to upload data to the currently bound
{{domxref("WebGLTexture")}} from the `WebGLBuffer` bound to the
`PIXEL_UNPACK_BUFFER` target.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createTexture()")}}
- {{domxref("WebGLRenderingContext.bindTexture()")}}
- {{domxref("WebGLRenderingContext.texSubImage2D()")}}
- {{domxref("WebGLRenderingContext.compressedTexImage2D()")}}
- {{domxref("WebGLRenderingContext.copyTexImage2D()")}}
- {{domxref("WebGLRenderingContext.getTexParameter()")}}
- {{domxref("WEBGL_depth_texture")}}
- {{domxref("OES_texture_float")}}
- {{domxref("OES_texture_half_float")}}
- {{domxref("EXT_texture_norm16")}}
- {{domxref("EXT_sRGB")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/uniform/index.md | ---
title: "WebGLRenderingContext: uniform[1234][fi][v]() method"
short-title: uniform[1234][fi][v]()
slug: Web/API/WebGLRenderingContext/uniform
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.uniform1f
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.uniform[1234][fi][v]()`** methods
of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specify values of uniform
variables. All active uniform variables defined in a program object are initialized to 0
when the program object is linked successfully. They retain the values assigned to them
by a call to this method until the next successful link operation occurs on the program
object, when they are once again initialized to 0.
> **Note:** Many of the functions described here have expanded WebGL 2 interfaces, which can be
> found under
> [`WebGL2RenderingContext.uniform[1234][uif][v]()`](/en-US/docs/Web/API/WebGL2RenderingContext/uniform).
## Syntax
```js-nolint
uniform1f(location, v0)
uniform1fv(location, value)
uniform1i(location, v0)
uniform1iv(location, value)
uniform2f(location, v0, v1)
uniform2fv(location, value)
uniform2i(location, v0, v1)
uniform2iv(location, value)
uniform3f(location, v0, v1, v2)
uniform3fv(location, value)
uniform3i(location, v0, v1, v2)
uniform3iv(location, value)
uniform4f(location, v0, v1, v2, v3)
uniform4fv(location, value)
uniform4i(location, v0, v1, v2, v3)
uniform4iv(location, value)
```
### Parameters
- `location`
- : A {{domxref("WebGLUniformLocation")}} object containing the location of the uniform
attribute to modify.
- `value, v0, v1, v2, v3`
- : A new value to be used for the uniform variable. Possible types:
- A floating point {{jsxref("Number")}} for floating point values (methods with
"f").
- A sequence of floating point numbers (for example a {{jsxref("Float32Array")}}
or an {{jsxref("Array")}} of numbers) for floating point vector methods (methods
with "fv").
- An integer {{jsxref("Number")}} for integer values (methods with "i").
- An {{jsxref("Int32Array")}} for integer vector methods (methods with "iv").
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.uniform1f(u_alpha, 0.8);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.uniformMatrix()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/deleteframebuffer/index.md | ---
title: "WebGLRenderingContext: deleteFramebuffer() method"
short-title: deleteFramebuffer()
slug: Web/API/WebGLRenderingContext/deleteFramebuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.deleteFramebuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.deleteFramebuffer()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) deletes a given
{{domxref("WebGLFramebuffer")}} object. This method has no effect if the frame buffer
has already been deleted.
## Syntax
```js-nolint
deleteFramebuffer(framebuffer)
```
### Parameters
- `framebuffer`
- : A {{domxref("WebGLFramebuffer")}} object to delete.
### Return value
None ({{jsxref("undefined")}}).
## Examples
### Deleting a frame buffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const framebuffer = gl.createFramebuffer();
// …
gl.deleteFramebuffer(framebuffer);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindFramebuffer()")}}
- {{domxref("WebGLRenderingContext.createFramebuffer()")}}
- {{domxref("WebGLRenderingContext.isFramebuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/cleardepth/index.md | ---
title: "WebGLRenderingContext: clearDepth() method"
short-title: clearDepth()
slug: Web/API/WebGLRenderingContext/clearDepth
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.clearDepth
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.clearDepth()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies the clear value for the
depth buffer.
This specifies what depth value to use when calling the
{{domxref("WebGLRenderingContext.clear", "clear()")}} method. The value is clamped
between 0 and 1.
## Syntax
```js-nolint
clearDepth(depth)
```
### Parameters
- `depth`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} specifying the depth value used when the depth buffer is
cleared. Default value: 1.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.clearDepth(0.5);
```
To get the current depth clear value, query the `DEPTH_CLEAR_VALUE`
constant.
```js
gl.getParameter(gl.DEPTH_CLEAR_VALUE);
// 0.5
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.clear()")}}
- {{domxref("WebGLRenderingContext.clearColor()")}}
- {{domxref("WebGLRenderingContext.clearStencil()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/stencilmask/index.md | ---
title: "WebGLRenderingContext: stencilMask() method"
short-title: stencilMask()
slug: Web/API/WebGLRenderingContext/stencilMask
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.stencilMask
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.stencilMask()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) controls enabling and disabling of
both the front and back writing of individual bits in the stencil planes.
The {{domxref("WebGLRenderingContext.stencilMaskSeparate()")}} method can set front and
back stencil writemasks to different values.
## Syntax
```js-nolint
stencilMask(mask)
```
### Parameters
- `mask`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying a bit mask to enable or disable writing of
individual bits in the stencil planes. By default, the mask is all 1.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.stencilMask(110101);
```
To get the current stencil masks, query the `STENCIL_WRITEMASK`,
`STENCIL_BACK_WRITEMASK`, or `STENCIL_BITS` constants.
```js
gl.getParameter(gl.STENCIL_WRITEMASK);
// 110101
gl.getParameter(gl.STENCIL_BACK_WRITEMASK);
// 110101
gl.getParameter(gl.STENCIL_BITS);
// 0
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.colorMask()")}}
- {{domxref("WebGLRenderingContext.depthMask()")}}
- {{domxref("WebGLRenderingContext.stencilMaskSeparate()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/deleteprogram/index.md | ---
title: "WebGLRenderingContext: deleteProgram() method"
short-title: deleteProgram()
slug: Web/API/WebGLRenderingContext/deleteProgram
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.deleteProgram
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.deleteProgram()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) deletes a given
{{domxref("WebGLProgram")}} object. This method has no effect if the program has already
been deleted.
## Syntax
```js-nolint
deleteProgram(program)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} object to delete.
### Return value
None ({{jsxref("undefined")}}).
## Examples
### Deleting a program
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const program = gl.createProgram();
// …
gl.deleteProgram(program);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createProgram()")}}
- {{domxref("WebGLRenderingContext.isProgram()")}}
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- {{domxref("WebGLRenderingContext.useProgram()")}}
- {{domxref("WebGLRenderingContext.validateProgram()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/vertexattrib/index.md | ---
title: "WebGLRenderingContext: vertexAttrib[1234]f[v]() method"
short-title: vertexAttrib[1234]f[v]()
slug: Web/API/WebGLRenderingContext/vertexAttrib
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.vertexAttrib1f
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.vertexAttrib[1234]f[v]()`**
methods of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specify constant
values for generic vertex attributes.
## Syntax
```js-nolint
vertexAttrib1f(index, v0)
vertexAttrib2f(index, v0, v1)
vertexAttrib3f(index, v0, v1, v2)
vertexAttrib4f(index, v0, v1, v2, v3)
vertexAttrib1fv(index, value)
vertexAttrib2fv(index, value)
vertexAttrib3fv(index, value)
vertexAttrib4fv(index, value)
```
### Parameters
- `index`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the position of the vertex attribute to be
modified.
- `v0, v1, v2, v3`
- : A floating point {{jsxref("Number")}} for the vertex attribute value.
- `value`
- : A {{jsxref("Float32Array")}} for floating point vector vertex attribute values.
### Return value
None ({{jsxref("undefined")}}).
## Description
While vertex attributes are usually used to specify values which are different for each
vertex (using {{domxref("WebGLRenderingContext.vertexAttribPointer()",
"vertexAttribPointer")}}), it can be useful to specify a constant value. For example, if
you have a shader which has a `color` vertex attribute, but you want to draw
everything in a single color, you can use `vertexAttrib` to achieve that
without creating a buffer filled with only one value or having to create a separate
shader which uses a uniform for the color.
This value will be used if a bound array buffer has not been enabled with
{{domxref("WebGLRenderingContext.enableVertexAttribArray()",
"enableVertexAttribArray")}}.
Attributes may be matrices, in which case columns of the matrix must be loaded into
successive vertex attribute slots.
The values set with `vertexAttrib` are context-global; that is, they aren't part of the shader state
(like generic vertex attribute indexes to shader variable bindings) and aren't part of
the vertex array object state (like enabled vertex attribute arrays). The only way to
change the values is by calling this function again.
## Examples
```js
const a_foobar = gl.getAttribLocation(shaderProgram, "foobar");
//either set each component individually:
gl.vertexAttrib3f(a_foobar, 10.0, 5.0, 2.0);
//or provide a Float32Array:
const floatArray = new Float32Array([10.0, 5.0, 2.0]);
gl.vertexAttrib3fv(a_foobar, floatArray);
```
```js
// we want to load the following 3x3 matrix into attribute named "matrix3x3"
// 0 1 2
// 3 4 5
// 6 7 8
const matrix3x3Location = gl.getAttribLocation(shaderProgram, "matrix3x3");
gl.vertexAttrib3f(matrix3x3Location, 0, 3, 6);
gl.vertexAttrib3f(matrix3x3Location + 1, 1, 4, 7);
gl.vertexAttrib3f(matrix3x3Location + 2, 2, 5, 8);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getVertexAttrib()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/validateprogram/index.md | ---
title: "WebGLRenderingContext: validateProgram() method"
short-title: validateProgram()
slug: Web/API/WebGLRenderingContext/validateProgram
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.validateProgram
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.validateProgram()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) validates a
{{domxref("WebGLProgram")}}. It checks if it is successfully linked and if it can be
used in the current WebGL state.
## Syntax
```js-nolint
validateProgram(program)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} to validate.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
const program = gl.createProgram();
// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
gl.validateProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
const info = gl.getProgramInfoLog(program);
throw `Could not compile WebGL program. \n\n${info}`;
}
gl.useProgram(program);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createProgram()")}}
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- {{domxref("WebGLRenderingContext.isProgram()")}}
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- {{domxref("WebGLRenderingContext.useProgram()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getprogramparameter/index.md | ---
title: "WebGLRenderingContext: getProgramParameter() method"
short-title: getProgramParameter()
slug: Web/API/WebGLRenderingContext/getProgramParameter
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getProgramParameter
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getProgramParameter()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns information about the
given program.
## Syntax
```js-nolint
getProgramParameter(program, pname)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} to get parameter information from.
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the information to query. Possible values:
- `gl.DELETE_STATUS`
- : Returns a {{domxref("WebGL_API/Types", "GLboolean")}} indicating
whether or not the program is flagged for deletion.
- `gl.LINK_STATUS`
- : Returns a {{domxref("WebGL_API/Types", "GLboolean")}} indicating
whether or not the last link operation was successful.
- `gl.VALIDATE_STATUS`
- : Returns a {{domxref("WebGL_API/Types", "GLboolean")}} indicating
whether or not the last validation operation was successful.
- `gl.ATTACHED_SHADERS`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of attached shaders to a program.
- `gl.ACTIVE_ATTRIBUTES`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of active attribute variables to a program.
- `gl.ACTIVE_UNIFORMS`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of active uniform variables to a program.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.TRANSFORM_FEEDBACK_BUFFER_MODE`
- : Returns a
{{domxref("WebGL_API/Types", "GLenum")}} indicating the buffer mode when transform feedback is
active. May be `gl.SEPARATE_ATTRIBS` or
`gl.INTERLEAVED_ATTRIBS`.
- `gl.TRANSFORM_FEEDBACK_VARYINGS`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}}
indicating the number of varying variables to capture in transform feedback
mode.
- `gl.ACTIVE_UNIFORM_BLOCKS`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}}
indicating the number of uniform blocks containing active uniforms.
### Return value
Returns the requested program information (as specified with `pname`).
## Examples
```js
gl.getProgramParameter(program, gl.DELETE_STATUS);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getShaderParameter()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getrenderbufferparameter/index.md | ---
title: "WebGLRenderingContext: getRenderbufferParameter() method"
short-title: getRenderbufferParameter()
slug: Web/API/WebGLRenderingContext/getRenderbufferParameter
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getRenderbufferParameter
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getRenderbufferParameter()`**
method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns information
about the renderbuffer.
## Syntax
```js-nolint
getRenderbufferParameter(target, pname)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the target renderbuffer object. Possible values:
- `gl.RENDERBUFFER`
- : Buffer data storage for single images in a
renderable internal format.
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the information to query. Possible values:
- `gl.RENDERBUFFER_WIDTH`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} indicating
the width of the image of the currently bound renderbuffer.
- `gl.RENDERBUFFER_HEIGHT`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} indicating
the height of the image of the currently bound renderbuffer.
- `gl.RENDERBUFFER_INTERNAL_FORMAT`
- : Returns a {{domxref("WebGL_API/Types", "GLenum")}}
indicating the internal format of the currently bound renderbuffer. The default is
`gl.RGBA4`. Possible return values:
- `gl.RGBA4`: 4 red bits, 4 green bits, 4 blue bits 4 alpha bits.
- `gl.RGB565`: 5 red bits, 6 green bits, 5 blue bits.
- `gl.RGB5_A1`: 5 red bits, 5 green bits, 5 blue bits, 1 alpha bit.
- `gl.DEPTH_COMPONENT16`: 16 depth bits.
- `gl.STENCIL_INDEX8`: 8 stencil bits.
- `gl.RENDERBUFFER_GREEN_SIZE`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} that is
the resolution size (in bits) for the green color.
- `gl.RENDERBUFFER_BLUE_SIZE`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} that is
the resolution size (in bits) for the blue color.
- `gl.RENDERBUFFER_RED_SIZE`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} that is
the resolution size (in bits) for the red color.
- `gl.RENDERBUFFER_ALPHA_SIZE`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} that is
the resolution size (in bits) for the alpha component.
- `gl.RENDERBUFFER_DEPTH_SIZE`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} that is
the resolution size (in bits) for the depth component.
- `gl.RENDERBUFFER_STENCIL_SIZE`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} that
is the resolution size (in bits) for the stencil component.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following value is available additionally:
- `gl.RENDERBUFFER_SAMPLES`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}}
indicating the number of samples of the image of the currently bound
renderbuffer.
### Return value
Depends on the requested information (as specified with `pname`). Either a
{{domxref("WebGL_API/Types", "GLint")}} or a {{domxref("WebGL_API/Types", "GLenum")}}.
## Examples
```js
gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.createRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.deleteRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.renderbufferStorage()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLFramebuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/cullface/index.md | ---
title: "WebGLRenderingContext: cullFace() method"
short-title: cullFace()
slug: Web/API/WebGLRenderingContext/cullFace
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.cullFace
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.cullFace()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies whether or not front-
and/or back-facing polygons can be culled.
## Syntax
```js-nolint
cullFace(mode)
```
### Parameters
- `mode`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying whether front- or back-facing polygons are
candidates for culling. The default value is `gl.BACK`. Possible values
are:
- `gl.FRONT`
- `gl.BACK`
- `gl.FRONT_AND_BACK`
### Return value
None ({{jsxref("undefined")}}).
## Examples
Polygon culling is disabled by default. To enable or disable culling, use the
{{domxref("WebGLRenderingContext.enable", "enable()")}} and
{{domxref("WebGLRenderingContext.disable", "disable()")}} methods with the argument
`gl.CULL_FACE`.
```js
gl.enable(gl.CULL_FACE);
gl.cullFace(gl.FRONT_AND_BACK);
```
To check the current cull face mode, query the `CULL_FACE_MODE` constant.
```js
gl.getParameter(gl.CULL_FACE_MODE) === gl.FRONT_AND_BACK;
// true
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.enable()")}}
- {{domxref("WebGLRenderingContext.frontFace()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/blendequation/index.md | ---
title: "WebGLRenderingContext: blendEquation() method"
short-title: blendEquation()
slug: Web/API/WebGLRenderingContext/blendEquation
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.blendEquation
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.blendEquation()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) is used to set both the RGB blend
equation and alpha blend equation to a single equation.
The blend equation determines how a new pixel is combined with a pixel already in the
{{domxref("WebGLFramebuffer")}}.
## Syntax
```js-nolint
blendEquation(mode)
```
### Parameters
- `mode`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying how source and destination colors are combined.
Must be either:
- `gl.FUNC_ADD`: source + destination (default value)
- `gl.FUNC_SUBTRACT`: source - destination
- `gl.FUNC_REVERSE_SUBTRACT`: destination - source
When using the {{domxref("EXT_blend_minmax")}} extension:
- `ext.MIN_EXT`: Minimum of source and destination
- `ext.MAX_EXT`: Maximum of source and destination
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.MIN`: Minimum of source and destination
- `gl.MAX`: Maximum of source and destination
### Exception
If _mode_ is not one of the three possible values, a
`gl.INVALID_ENUM` error is thrown.
### Return value
None ({{jsxref("undefined")}}).
## Examples
To set the blend equation, use:
```js
gl.blendEquation(gl.FUNC_ADD);
gl.blendEquation(gl.FUNC_SUBTRACT);
gl.blendEquation(gl.FUNC_REVERSE_SUBTRACT);
```
To get the blend equations, query the `BLEND_EQUATION`,
`BLEND_EQUATION_RGB` and `BLEND_EQUATION_ALPHA` constants which
return `gl.FUNC_ADD`, `gl.FUNC_SUBTRACT`,
`gl.FUNC_REVERSE_SUBTRACT`, or if the {{domxref("EXT_blend_minmax")}} is
enabled: `ext.MIN_EXT` or `ext.MAX_EXT`.
```js
gl.getParameter(gl.BLEND_EQUATION_RGB) === gl.FUNC_ADD;
// true
gl.getParameter(gl.BLEND_EQUATION_ALPHA) === gl.FUNC_ADD;
// true
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.blendColor()")}}
- {{domxref("WebGLRenderingContext.blendFunc()")}}
- {{domxref("EXT_blend_minmax")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/bindrenderbuffer/index.md | ---
title: "WebGLRenderingContext: bindRenderbuffer() method"
short-title: bindRenderbuffer()
slug: Web/API/WebGLRenderingContext/bindRenderbuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.bindRenderbuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.bindRenderbuffer()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) binds a given
{{domxref("WebGLRenderbuffer")}} to a target, which must be
`gl.RENDERBUFFER`.
## Syntax
```js-nolint
bindRenderbuffer(target, renderbuffer)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.RENDERBUFFER`
- : Buffer data storage for single images in a
renderable internal format.
- `renderbuffer`
- : A {{domxref("WebGLRenderbuffer")}} object to bind.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
A `gl.INVALID_ENUM` error is thrown if `target` is not
`gl.RENDERBUFFER`.
## Examples
### Binding a renderbuffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const renderbuffer = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
```
### Getting current bindings
To check the current renderbuffer binding, query the `RENDERBUFFER_BINDING`
constant.
```js
gl.getParameter(gl.RENDERBUFFER_BINDING);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.deleteRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.isRenderbuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLFramebuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/stencilmaskseparate/index.md | ---
title: "WebGLRenderingContext: stencilMaskSeparate() method"
short-title: stencilMaskSeparate()
slug: Web/API/WebGLRenderingContext/stencilMaskSeparate
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.stencilMaskSeparate
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.stencilMaskSeparate()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) controls enabling and
disabling of front and/or back writing of individual bits in the stencil planes.
The {{domxref("WebGLRenderingContext.stencilMask()")}} method can set both, the front
and back stencil writemasks to one value at the same time.
## Syntax
```js-nolint
stencilMaskSeparate(face, mask)
```
### Parameters
- `face`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying whether the front and/or back stencil writemask
is updated. The possible values are:
- `gl.FRONT`
- `gl.BACK`
- `gl.FRONT_AND_BACK`
- `mask`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying a bit mask to enable or disable writing of
individual bits in the stencil planes. By default, the mask is all 1.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.stencilMaskSeparate(gl.FRONT, 110101);
```
To get the current stencil masks, query the `STENCIL_WRITEMASK`,
`STENCIL_BACK_WRITEMASK`, or `STENCIL_BITS` constants.
```js
gl.getParameter(gl.STENCIL_WRITEMASK);
// 110101
gl.getParameter(gl.STENCIL_BACK_WRITEMASK);
// 110101
gl.getParameter(gl.STENCIL_BITS);
// 0
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.colorMask()")}}
- {{domxref("WebGLRenderingContext.depthMask()")}}
- {{domxref("WebGLRenderingContext.stencilMask()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/copyteximage2d/index.md | ---
title: "WebGLRenderingContext: copyTexImage2D() method"
short-title: copyTexImage2D()
slug: Web/API/WebGLRenderingContext/copyTexImage2D
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.copyTexImage2D
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.copyTexImage2D()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) copies pixels from the current
{{domxref("WebGLFramebuffer")}} into a 2D texture image.
## Syntax
```js-nolint
copyTexImage2D(target, level, internalformat, x, y, width, height, border)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target) of the active texture.
Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_X`: Positive X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_X`: Negative X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Y`: Positive Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Y`: Negative Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Z`: Positive Z face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Z`: Negative Z face for a cube-mapped
texture.
- `level`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the level of detail. Level 0 is the base image
level and level _n_ is the n-th mipmap reduction level.
- `internalformat`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the color components in the texture. Possible
values:
- `gl.ALPHA`: Discards the red, green and blue components and reads the
alpha component.
- `gl.RGB`: Discards the alpha components and reads the red, green and
blue components.
- `gl.RGBA`: Red, green, blue and alpha components are read from the
color buffer.
- `gl.LUMINANCE`: Each color component is a luminance component, alpha
is 1.0.
- `gl.LUMINANCE_ALPHA`: Each component is a luminance/alpha component.
- `x`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the x coordinate of the lower left corner where to
start copying.
- `y`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the y coordinate of the lower left corner where to
start copying.
- `width`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the texture.
- `height`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the texture.
- `border`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the width of the border. Must be 0.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 512, 512, 0);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createTexture()")}}
- {{domxref("WebGLRenderingContext.bindTexture()")}}
- {{domxref("WebGLRenderingContext.texImage2D()")}}
- {{domxref("WebGLRenderingContext.texSubImage2D()")}}
- {{domxref("WebGLRenderingContext.compressedTexImage2D()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/deleterenderbuffer/index.md | ---
title: "WebGLRenderingContext: deleteRenderbuffer() method"
short-title: deleteRenderbuffer()
slug: Web/API/WebGLRenderingContext/deleteRenderbuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.deleteRenderbuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.deleteRenderbuffer()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) deletes a given
{{domxref("WebGLRenderbuffer")}} object. This method has no effect if the render buffer
has already been deleted.
## Syntax
```js-nolint
deleteRenderbuffer(renderbuffer)
```
### Parameters
- `renderbuffer`
- : A {{domxref("WebGLRenderbuffer")}} object to delete.
### Return value
None ({{jsxref("undefined")}}).
## Examples
### Deleting a renderbuffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const renderbuffer = gl.createRenderbuffer();
// …
gl.deleteRenderbuffer(renderbuffer);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.createRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.isRenderbuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLFramebuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/useprogram/index.md | ---
title: "WebGLRenderingContext: useProgram() method"
short-title: useProgram()
slug: Web/API/WebGLRenderingContext/useProgram
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.useProgram
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.useProgram()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets the specified
{{domxref("WebGLProgram")}} as part of the current rendering state.
## Syntax
```js-nolint
useProgram(program)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} to use.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
const program = gl.createProgram();
// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
gl.useProgram(program);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createProgram()")}}
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- {{domxref("WebGLRenderingContext.isProgram()")}}
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- {{domxref("WebGLRenderingContext.validateProgram()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/compressedteximage2d/index.md | ---
title: "WebGLRenderingContext: compressedTexImage[23]D() method"
short-title: compressedTexImage[23]D()
slug: Web/API/WebGLRenderingContext/compressedTexImage2D
page-type: web-api-instance-method
browser-compat:
- api.WebGLRenderingContext.compressedTexImage2D
- api.WebGL2RenderingContext.compressedTexImage3D
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.compressedTexImage2D()`**
and **`WebGL2RenderingContext.compressedTexImage3D()`** methods
of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specify a two- or
three-dimensional texture image in a compressed format.
Compressed image formats must be enabled by [WebGL extensions](/en-US/docs/Web/API/WebGL_API/Using_Extensions) before
using these methods.
## Syntax
```js-nolint
// WebGL 1:
compressedTexImage2D(target, level, internalformat, width, height, border)
compressedTexImage2D(target, level, internalformat, width, height, border, pixels)
// Additionally available in WebGL 2:
// read from buffer bound to gl.PIXEL_UNPACK_BUFFER
compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, offset)
compressedTexImage2D(target, level, internalformat, width, height, border, srcData)
compressedTexImage2D(target, level, internalformat, width, height, border, srcData, srcOffset)
compressedTexImage2D(target, level, internalformat, width, height, border, srcData, srcOffset, srcLengthOverride)
// read from buffer bound to gl.PIXEL_UNPACK_BUFFER
compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, offset)
compressedTexImage3D(target, level, internalformat, width, height, depth, border, srcData)
compressedTexImage3D(target, level, internalformat, width, height, depth, border, srcData, srcOffset)
compressedTexImage3D(target, level, internalformat, width, height, depth, border, srcData, srcOffset, srcLengthOverride)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target) of the active texture.
Possible values for `compressedTexImage2D`:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_X`: Positive X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_X`: Negative X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Y`: Positive Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Y`: Negative Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Z`: Positive Z face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Z`: Negative Z face for a cube-mapped
texture.
Possible values for `compressedTexImage3D`:
- `gl.TEXTURE_2D_ARRAY`
- `gl.TEXTURE_3D`
- `level`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the level of detail. Level 0 is the base image
level and level _n_ is the n-th mipmap reduction level.
- `internalformat`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the compressed image format. Compressed image
formats must be enabled by [WebGL extensions](/en-US/docs/Web/API/WebGL_API/Using_Extensions) before
using this method. All values are possible for `compressedTexImage2D`. See
[compressed texture formats](/en-US/docs/Web/API/WebGL_API/Compressed_texture_formats) for which are valid for `compressedTexImage3D`. Possible
values:
- When using the {{domxref("WEBGL_compressed_texture_s3tc")}} extension:
- `ext.COMPRESSED_RGB_S3TC_DXT1_EXT`
- `ext.COMPRESSED_RGBA_S3TC_DXT1_EXT`
- `ext.COMPRESSED_RGBA_S3TC_DXT3_EXT`
- `ext.COMPRESSED_RGBA_S3TC_DXT5_EXT`
- When using the {{domxref("WEBGL_compressed_texture_s3tc_srgb")}} extension:
- `ext.COMPRESSED_SRGB_S3TC_DXT1_EXT`
- `ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT`
- `ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT`
- `ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT`
- When using the {{domxref("WEBGL_compressed_texture_etc")}} extension:
- `ext.COMPRESSED_R11_EAC`
- `ext.COMPRESSED_SIGNED_R11_EAC`
- `ext.COMPRESSED_RG11_EAC`
- `ext.COMPRESSED_SIGNED_RG11_EAC`
- `ext.COMPRESSED_RGB8_ETC2`
- `ext.COMPRESSED_RGBA8_ETC2_EAC`
- `ext.COMPRESSED_SRGB8_ETC2`
- `ext.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC`
- `ext.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2`
- `ext.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2`
- When using the {{domxref("WEBGL_compressed_texture_pvrtc")}} extension:
- `ext.COMPRESSED_RGB_PVRTC_4BPPV1_IMG`
- `ext.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG`
- `ext.COMPRESSED_RGB_PVRTC_2BPPV1_IMG`
- `ext.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG`
- When using the {{domxref("WEBGL_compressed_texture_etc1")}} extension:
- `ext.COMPRESSED_RGB_ETC1_WEBGL`
- When using the {{domxref("WEBGL_compressed_texture_astc")}} extension:
- `ext.COMPRESSED_RGBA_ASTC_4x4_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR`
- `ext.COMPRESSED_RGBA_ASTC_5x4_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR`
- `ext.COMPRESSED_RGBA_ASTC_5x5_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR`
- `ext.COMPRESSED_RGBA_ASTC_6x5_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR`
- `ext.COMPRESSED_RGBA_ASTC_6x6_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR`
- `ext.COMPRESSED_RGBA_ASTC_8x5_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR`
- `ext.COMPRESSED_RGBA_ASTC_8x6_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR`
- `ext.COMPRESSED_RGBA_ASTC_8x8_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR`
- `ext.COMPRESSED_RGBA_ASTC_10x5_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR`
- `ext.COMPRESSED_RGBA_ASTC_10x6_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR`
- `ext.COMPRESSED_RGBA_ASTC_10x10_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR`
- `ext.COMPRESSED_RGBA_ASTC_12x10_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR`
- `ext.COMPRESSED_RGBA_ASTC_12x12_KHR ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR`
- When using the {{domxref("EXT_texture_compression_bptc")}} extension:
- `ext.COMPRESSED_RGBA_BPTC_UNORM_EXT`
- `ext.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT`
- `ext.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT`
- `ext.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT`
- When using the {{domxref("EXT_texture_compression_rgtc")}} extension:
- `ext.COMPRESSED_RED_RGTC1_EXT`
- `ext.COMPRESSED_SIGNED_RED_RGTC1_EXT`
- `ext.COMPRESSED_RED_GREEN_RGTC2_EXT`
- `ext.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT`
- `width`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the texture.
- `height`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the texture.
- `depth`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the depth of the texture/the number of textures
in a `TEXTURE_2D_ARRAY`.
- `border`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the width of the border. Must be 0.
- `imageSize`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the number of bytes to read from the buffer
bound to `gl.PIXEL_UNPACK_BUFFER`.
- `offset`
- : A {{domxref("WebGL_API/Types", "GLintptr")}} specifying the offset in bytes from which to read from the
buffer bound to `gl.PIXEL_UNPACK_BUFFER`.
- `pixels`
- : A {{jsxref("TypedArray")}} or a {{jsxref("DataView")}} that will be used as a data store for the
compressed image data in memory.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
const ext =
gl.getExtension("WEBGL_compressed_texture_s3tc") ||
gl.getExtension("MOZ_WEBGL_compressed_texture_s3tc") ||
gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
const texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.compressedTexImage2D(
gl.TEXTURE_2D,
0,
ext.COMPRESSED_RGBA_S3TC_DXT5_EXT,
512,
512,
0,
textureData,
);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Using WebGL extensions](/en-US/docs/Web/API/WebGL_API/Using_Extensions)
- {{domxref("WebGLRenderingContext.compressedTexSubImage2D()")}}
- {{domxref("WEBGL_compressed_texture_s3tc")}}
- {{domxref("WEBGL_compressed_texture_s3tc_srgb")}}
- {{domxref("WEBGL_compressed_texture_etc")}}
- {{domxref("WEBGL_compressed_texture_pvrtc")}}
- {{domxref("WEBGL_compressed_texture_etc1")}}
- {{domxref("WEBGL_compressed_texture_astc")}}
- {{domxref("EXT_texture_compression_bptc")}}
- {{domxref("EXT_texture_compression_rgtc")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/bindtexture/index.md | ---
title: "WebGLRenderingContext: bindTexture() method"
short-title: bindTexture()
slug: Web/API/WebGLRenderingContext/bindTexture
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.bindTexture
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.bindTexture()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) binds a given
{{domxref("WebGLTexture")}} to a target (binding point).
## Syntax
```js-nolint
bindTexture(target, texture)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP`: A cube-mapped texture.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.TEXTURE_3D`: A three-dimensional texture.
- `gl.TEXTURE_2D_ARRAY`: A two-dimensional array texture.
- `texture`
- : A {{domxref("WebGLTexture")}} object to bind.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
A `gl.INVALID_ENUM` error is thrown if `target` is not
`gl.TEXTURE_2D`, `gl.TEXTURE_CUBE_MAP`,
`gl.TEXTURE_3D`, or `gl.TEXTURE_2D_ARRAY`.
## Examples
### Binding a texture
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
```
### Getting current bindings
To check the current texture binding, query the `gl.TEXTURE_BINDING_2D` or
`gl.TEXTURE_BINDING_CUBE_MAP` constants.
```js
gl.getParameter(gl.TEXTURE_BINDING_2D);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createTexture()")}}
- {{domxref("WebGLRenderingContext.deleteTexture()")}}
- {{domxref("WebGLRenderingContext.isTexture()")}}
- {{domxref("WebGLRenderingContext.texImage2D()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/pixelstorei/index.md | ---
title: "WebGLRenderingContext: pixelStorei() method"
short-title: pixelStorei()
slug: Web/API/WebGLRenderingContext/pixelStorei
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.pixelStorei
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.pixelStorei()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies the pixel storage modes.
## Syntax
```js-nolint
pixelStorei(pname, param)
```
### Parameters
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying which parameter to set. See below for possible
values.
- `param`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying a value to set the `pname`
parameter to. See below for possible values.
### Return value
None ({{jsxref("undefined")}}).
## Pixel storage parameters
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Parameter name (for <code>pname</code>)</th>
<th scope="col">Description</th>
<th scope="col">Type</th>
<th scope="col">Default value</th>
<th scope="col">Allowed values (for <code>param</code>)</th>
<th scope="col">Specified in</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.PACK_ALIGNMENT</code></td>
<td>Packing of pixel data into memory</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>4</td>
<td>1, 2, 4, 8</td>
<td>OpenGL ES 2.0</td>
</tr>
<tr>
<td><code>gl.UNPACK_ALIGNMENT</code></td>
<td>Unpacking of pixel data from memory.</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>4</td>
<td>1, 2, 4, 8</td>
<td>OpenGL ES 2.0</td>
</tr>
<tr>
<td><code>gl.UNPACK_FLIP_Y_WEBGL</code></td>
<td>Flips the source data along its vertical axis if true.</td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td>false</td>
<td>true, false</td>
<td>WebGL</td>
</tr>
<tr>
<td><code>gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL</code></td>
<td>Multiplies the alpha channel into the other color channels</td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td>false</td>
<td>true, false</td>
<td>WebGL</td>
</tr>
<tr>
<td><code>gl.UNPACK_COLORSPACE_CONVERSION_WEBGL</code></td>
<td>Default color space conversion or no color space conversion.</td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td><code>gl.BROWSER_DEFAULT_WEBGL</code></td>
<td><code>gl.BROWSER_DEFAULT_WEBGL</code>, <code>gl.NONE</code></td>
<td>WebGL</td>
</tr>
</tbody>
</table>
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the
following values are available additionally:
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Constant</th>
<th scope="col">Description</th>
<th scope="col">Type</th>
<th scope="col">Default value</th>
<th scope="col">Allowed values (for <code>param</code>)</th>
<th scope="col">Specified in</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.PACK_ROW_LENGTH</code></td>
<td>Number of pixels in a row.</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>0</td>
<td>0 to <code>Infinity</code></td>
<td>OpenGL ES 3.0</td>
</tr>
<tr>
<td><code>gl.PACK_SKIP_PIXELS</code></td>
<td>
Number of pixel locations skipped before the first pixel is written into
memory.
</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>0</td>
<td>0 to <code>Infinity</code></td>
<td>OpenGL ES 3.0</td>
</tr>
<tr>
<td><code>gl.PACK_SKIP_ROWS</code></td>
<td>
Number of rows of pixel locations skipped before the first pixel is
written into memory
</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>0</td>
<td>0 to <code>Infinity</code></td>
<td>OpenGL ES 3.0</td>
</tr>
<tr>
<td><code>gl.UNPACK_ROW_LENGTH</code></td>
<td>Number of pixels in a row.</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>0</td>
<td>0 to <code>Infinity</code></td>
<td>OpenGL ES 3.0</td>
</tr>
<tr>
<td><code>gl.UNPACK_IMAGE_HEIGHT</code></td>
<td>Image height used for reading pixel data from memory</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>0</td>
<td>0 to <code>Infinity</code></td>
<td>OpenGL ES 3.0</td>
</tr>
<tr>
<td><code>gl.UNPACK_SKIP_PIXELS</code></td>
<td>
Number of pixel images skipped before the first pixel is read from
memory
</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>0</td>
<td>0 to <code>Infinity</code></td>
<td>OpenGL ES 3.0</td>
</tr>
<tr>
<td><code>gl.UNPACK_SKIP_ROWS</code></td>
<td>
Number of rows of pixel locations skipped before the first pixel is read
from memory
</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>0</td>
<td>0 to <code>Infinity</code></td>
<td>OpenGL ES 3.0</td>
</tr>
<tr>
<td><code>gl.UNPACK_SKIP_IMAGES</code></td>
<td>
Number of pixel images skipped before the first pixel is read from
memory
</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>0</td>
<td>0 to <code>Infinity</code></td>
<td>OpenGL ES 3.0</td>
</tr>
</tbody>
</table>
## Examples
Setting the pixel storage mode affects the
{{domxref("WebGLRenderingContext.readPixels()")}} operations, as well as unpacking of
textures with the {{domxref("WebGLRenderingContext.texImage2D()")}} and
{{domxref("WebGLRenderingContext.texSubImage2D()")}} methods.
```js
const tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
```
To check the values for packing and unpacking of pixel data, you can query the same
pixel storage parameters with {{domxref("WebGLRenderingContext.getParameter()")}}.
```js
gl.getParameter(gl.PACK_ALIGNMENT);
gl.getParameter(gl.UNPACK_ALIGNMENT);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.readPixels()")}}
- {{domxref("WebGLRenderingContext.texImage2D()")}}
- {{domxref("WebGLRenderingContext.texSubImage2D()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getextension/index.md | ---
title: "WebGLRenderingContext: getExtension() method"
short-title: getExtension()
slug: Web/API/WebGLRenderingContext/getExtension
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getExtension
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getExtension()`** method enables a
[WebGL](/en-US/docs/Web/API/WebGL_API) extension.
## Syntax
```js-nolint
getExtension(name)
```
### Parameters
- `name`
- : A {{jsxref("String")}} for the name of the WebGL extension to enable.
### Return value
A WebGL extension object, or [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null) if name does not match
(case-insensitive) to one of the strings in
{{domxref("WebGLRenderingContext.getSupportedExtensions")}}.
## Examples
Once a WebGL extension is enabled, you are able to use the methods, properties or
constants that this extension object provides.
```js
const canvas = document.getElementById("canvas");
gl = canvas.getContext("webgl");
gl.getExtension("WEBGL_lose_context").loseContext();
```
## WebGL extensions
Extensions for the WebGL API are registered in the [WebGL Extension Registry](https://www.khronos.org/registry/webgl/extensions/). They are also
listed [here](/en-US/docs/Web/API/WebGL_API#extensions).
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getSupportedExtensions()")}}
- [webglreport.com](https://webglreport.com)
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/unpackcolorspace/index.md | ---
title: "WebGLRenderingContext: unpackColorSpace property"
short-title: unpackColorSpace
slug: Web/API/WebGLRenderingContext/unpackColorSpace
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.WebGLRenderingContext.unpackColorSpace
---
{{APIRef("WebGL")}}{{SeeCompatTable}}
The **`WebGLRenderingContext.unpackColorSpace`** property specifies the color space to convert to when importing textures. Along with the default (`srgb`), the `display-p3` color space can be used.
Texture image sources can be the following:
- [`ImageBitmap`](/en-US/docs/Web/API/ImageBitmap)
- [`ImageData`](/en-US/docs/Web/API/ImageData)
- [`HTMLImageElement`](/en-US/docs/Web/API/HTMLImageElement)
- [`HTMLCanvasElement`](/en-US/docs/Web/API/HTMLCanvasElement)
- [`HTMLVideoElement`](/en-US/docs/Web/API/HTMLVideoElement)
- [`OffscreenCanvas`](/en-US/docs/Web/API/OffscreenCanvas)
- [`VideoFrame`](/en-US/docs/Web/API/VideoFrame)
Textures are imported using the [`WebGLRenderingContext.texImage2D()`](/en-US/docs/Web/API/WebGLRenderingContext/texImage2D) and [`WebGLRenderingContext.texSubImage2D()`](/en-US/docs/Web/API/WebGLRenderingContext/texSubImage2D) methods and conversion to the specified `unpackColorSpace` color space happens during import.
Note that this doesn't apply to [`HTMLImageElement`](/en-US/docs/Web/API/HTMLImageElement) when the `UNPACK_COLORSPACE_CONVERSION_WEBGL` pixel storage parameter is set to `NONE`.
## Value
This property can have the following values:
- `"srgb"` selects the [sRGB color space](https://en.wikipedia.org/wiki/SRGB). This is the default value.
- `"display-p3"` selects the [display-p3 color space](https://en.wikipedia.org/wiki/DCI-P3).
If an invalid value is specified, then the value of `unpackColorSpace` will remain unchanged.
## Examples
### Converting sRGB ImageData to display-p3 in a texture
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.drawingBufferColorSpace = "display-p3";
gl.unpackColorSpace = "display-p3";
// Some sRGB ImageData
// Will be converted from sRGB to Display P3
const imageData = new ImageData(data, 32, 32);
const tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(
gl.TEXTURE_2D,
0,
gl.RGBA,
width,
height,
0,
gl.RGBA,
gl.UNSIGNED_BYTE,
imageData,
);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [`WebGLRenderingContext.drawingBufferColorSpace`](/en-US/docs/Web/API/WebGLRenderingContext/drawingBufferColorSpace)
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/texsubimage2d/index.md | ---
title: "WebGLRenderingContext: texSubImage2D() method"
short-title: texSubImage2D()
slug: Web/API/WebGLRenderingContext/texSubImage2D
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.texSubImage2D
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.texSubImage2D()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) specifies a sub-rectangle of the
current texture.
## Syntax
```js-nolint
// WebGL1
texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels) // pixels is a TypedArray or a DataView
texSubImage2D(target, level, xoffset, yoffset, format, type, pixels)
// WebGL2
texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, offset)
texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, source)
texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels, srcOffset)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target) of the active texture.
Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_X`: Positive X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_X`: Negative X face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Y`: Positive Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Y`: Negative Y face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_POSITIVE_Z`: Positive Z face for a cube-mapped
texture.
- `gl.TEXTURE_CUBE_MAP_NEGATIVE_Z`: Negative Z face for a cube-mapped
texture.
- `level`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the level of detail. Level 0 is the base image
level and level _n_ is the n-th mipmap reduction level.
- `xoffset`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the lower left texel x coordinate of a width-wide
by height-wide rectangular subregion of the texture array.
- `yoffset`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the lower left texel y coordinate of a width-wide
by height-wide rectangular subregion of the texture array.
- `width`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the texture in texels.
- `height`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the texture in texels.
- `format`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the format of the texel data. Possible values:
- `gl.ALPHA`: Discards the red, green and blue components and reads the
alpha component.
- `gl.RGB`: Discards the alpha components and reads the red, green and
blue components.
- `gl.RGBA`: Red, green, blue and alpha components are read from the
color buffer.
- `gl.LUMINANCE`: Each color component is a luminance component, alpha
is 1.0.
- `gl.LUMINANCE_ALPHA`: Each component is a luminance/alpha component.
When using the {{domxref("EXT_sRGB")}} extension:
- `ext.SRGB_EXT`
- `ext.SRGB_ALPHA_EXT`
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.RED`
- `gl.RG`
- `gl.RED_INTEGER`
- `gl.RG_INTEGER`
- `gl.RGB_INTEGER`
- `gl.RGBA_INTEGER`
- `type`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the data type of the texel data. Possible values:
- `gl.UNSIGNED_BYTE`: 8 bits per channel for `gl.RGBA`
- `gl.UNSIGNED_SHORT_5_6_5`: 5 red bits, 6 green bits, 5 blue bits.
- `gl.UNSIGNED_SHORT_4_4_4_4`: 4 red bits, 4 green bits, 4 blue bits, 4
alpha bits.
- `gl.UNSIGNED_SHORT_5_5_5_1`: 5 red bits, 5 green bits, 5 blue bits, 1
alpha bit.
When using the {{domxref("OES_texture_float")}} extension:
- `gl.FLOAT`
When using the {{domxref("OES_texture_half_float")}} extension:
- `gl.HALF_FLOAT_OES`
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.BYTE`
- `gl.UNSIGNED_SHORT`
- `gl.SHORT`
- `gl.UNSIGNED_INT`
- `gl.INT`
- `gl.HALF_FLOAT`
- `gl.FLOAT`
- `gl.UNSIGNED_INT_2_10_10_10_REV`
- `gl.UNSIGNED_INT_10F_11F_11F_REV`
- `gl.UNSIGNED_INT_5_9_9_9_REV`
- `gl.UNSIGNED_INT_24_8`
- `gl.FLOAT_32_UNSIGNED_INT_24_8_REV` (pixels must be
[`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null))
- `pixels`
- : One of the following objects can be used as a pixel source for the texture:
- {{jsxref("Uint8Array")}} (Must be used if `type` is `gl.UNSIGNED_BYTE`)
- {{jsxref("Uint16Array")}} (Must be used if `type` is either
`gl.UNSIGNED_SHORT_5_6_5`, `gl.UNSIGNED_SHORT_4_4_4_4`,
`gl.UNSIGNED_SHORT_5_5_5_1`, or `ext.HALF_FLOAT_OES`)
- {{jsxref("Float32Array")}} (Must be used if `type` is `gl.FLOAT`)
- {{domxref("ImageData")}},
- {{domxref("HTMLImageElement")}},
- {{domxref("HTMLCanvasElement")}},
- {{domxref("HTMLVideoElement")}},
- {{domxref("ImageBitmap")}}.
- `offset`
- : (WebGL 2 only) A {{domxref("WebGL_API/Types", "GLintptr")}} byte offset into the
{{domxref("WebGLBuffer")}}'s data store. Used to upload data to the currently bound
{{domxref("WebGLTexture")}} from the `WebGLBuffer` bound to the
`PIXEL_UNPACK_BUFFER` target.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, image);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createTexture()")}}
- {{domxref("WebGLRenderingContext.bindTexture()")}}
- {{domxref("WebGLRenderingContext.texImage2D()")}}
- {{domxref("WebGLRenderingContext.compressedTexImage2D()")}}
- {{domxref("WebGLRenderingContext.copyTexImage2D()")}}
- {{domxref("WebGLRenderingContext.getTexParameter()")}}
- {{domxref("OES_texture_float")}}
- {{domxref("OES_texture_half_float")}}
- {{domxref("EXT_sRGB")}}
- {{domxref("EXT_texture_norm16")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/uniformmatrix/index.md | ---
title: "WebGLRenderingContext: uniformMatrix[234]fv() method"
short-title: uniformMatrix[234]fv()
slug: Web/API/WebGLRenderingContext/uniformMatrix
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.uniformMatrix2fv
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.uniformMatrix[234]fv()`** methods
of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specify matrix values for
uniform variables.
The three versions of this method (`uniformMatrix2fv()`,
`uniformMatrix3fv()`, and `uniformMatrix4fv()`) take as the input
value 2-component, 3-component, and 4-component square matrices, respectively. They are
expected to have 4, 9 or 16 floats.
## Syntax
```js-nolint
uniformMatrix2fv(location, transpose, value)
uniformMatrix3fv(location, transpose, value)
uniformMatrix4fv(location, transpose, value)
```
### Parameters
- `location`
- : A {{domxref("WebGLUniformLocation")}} object containing the location of the uniform
attribute to modify. The location is obtained using
{{domxref("WebGLRenderingContext.getUniformLocation", "getUniformLocation()")}}.
- `transpose`
- : A {{domxref("WebGL_API/Types", "GLboolean")}} specifying whether to transpose the matrix. Must be
`false`.
- `value`
- : A {{jsxref("Float32Array")}} or sequence of `GLfloat` values. The values
are assumed to be supplied in column major order.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.uniformMatrix2fv(loc, false, [2, 1, 2, 2]);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.uniform()")}}
- {{domxref("WebGL2RenderingContext.uniformMatrix()")}} – WebGL 2 versions of these
methods.
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/frontface/index.md | ---
title: "WebGLRenderingContext: frontFace() method"
short-title: frontFace()
slug: Web/API/WebGLRenderingContext/frontFace
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.frontFace
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.frontFace()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies whether polygons are
front- or back-facing by setting a winding orientation.
## Syntax
```js-nolint
frontFace(mode)
```
### Parameters
- `mode`
- : A [GLenum](/en-US/docs/Web/API/WebGL_API/Types) type winding orientation.
The default value is `gl.CCW`. Possible values:
- `gl.CW`: Clock-wise winding.
- `gl.CCW`: Counter-clock-wise winding.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.frontFace(gl.CW);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.cullFace()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/disablevertexattribarray/index.md | ---
title: "WebGLRenderingContext: disableVertexAttribArray() method"
short-title: disableVertexAttribArray()
slug: Web/API/WebGLRenderingContext/disableVertexAttribArray
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.disableVertexAttribArray
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.disableVertexAttribArray()`**
method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) turns the generic
vertex attribute array off at a given index position.
## Syntax
```js-nolint
disableVertexAttribArray(index)
```
### Parameters
- `index`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the index of the vertex attribute to disable.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.disableVertexAttribArray(0);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.enableVertexAttribArray()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/drawingbufferwidth/index.md | ---
title: "WebGLRenderingContext: drawingBufferWidth property"
short-title: drawingBufferWidth
slug: Web/API/WebGLRenderingContext/drawingBufferWidth
page-type: web-api-instance-property
browser-compat: api.WebGLRenderingContext.drawingBufferWidth
---
{{APIRef("WebGL")}}
The read-only **`WebGLRenderingContext.drawingBufferWidth`**
property represents the actual width of the current drawing buffer. It should match the
`width` attribute of the {{HTMLElement("canvas")}} element associated with
this context, but might differ if the implementation is not able to provide the
requested width.
## Value
A number.
## Examples
Given this {{HTMLElement("canvas")}} element:
```html
<canvas id="canvas"></canvas>
```
You can get the width of the drawing buffer with the following lines:
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.drawingBufferWidth; // 300
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.drawingBufferHeight")}}
- {{domxref("WebGLRenderingContext.viewport()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getshaderprecisionformat/index.md | ---
title: "WebGLRenderingContext: getShaderPrecisionFormat() method"
short-title: getShaderPrecisionFormat()
slug: Web/API/WebGLRenderingContext/getShaderPrecisionFormat
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getShaderPrecisionFormat
---
{{APIRef("WebGL")}}
The
**`WebGLRenderingContext.getShaderPrecisionFormat()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns a new
{{domxref("WebGLShaderPrecisionFormat")}} object describing the range and precision for
the specified shader numeric format.
## Syntax
```js-nolint
getShaderPrecisionFormat(shaderType, precisionType)
```
### Parameters
- `shaderType`
- : Either a `gl.FRAGMENT_SHADER` or a `gl.VERTEX_SHADER`.
- `precisionType`
- : A precision type value. Either `gl.LOW_FLOAT`,
`gl.MEDIUM_FLOAT`, `gl.HIGH_FLOAT`, `gl.LOW_INT`,
`gl.MEDIUM_INT`, or `gl.HIGH_INT`.
### Return value
A {{domxref("WebGLShaderPrecisionFormat")}} object or `null`, if an error
occurs.
### Exceptions
- `gl.INVALID_ENUM` if the shader or precision types aren't recognized.
- `gl.INVALID_OPERATION` if the shader compiler isn't supported.
## Examples
The following code gets the precision format of a `gl.VERTEX_SHADER` with a
`gl.MEDIUM_FLOAT` precision type.
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT);
// WebGLShaderPrecisionFormat { rangeMin: 127, rangeMax: 127, precision: 23 }
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLShaderPrecisionFormat")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/drawelements/index.md | ---
title: "WebGLRenderingContext: drawElements() method"
short-title: drawElements()
slug: Web/API/WebGLRenderingContext/drawElements
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.drawElements
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.drawElements()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) renders primitives from array data.
## Syntax
```js-nolint
drawElements(mode, count, type, offset)
```
### Parameters
- `mode`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the type primitive to render. Possible values
are:
- `gl.POINTS`: Draws a single dot.
- `gl.LINE_STRIP`: Draws a straight line to the next vertex.
- `gl.LINE_LOOP`: Draws a straight line to the next vertex, and
connects the last vertex back to the first.
- `gl.LINES`: Draws a line between a pair of vertices.
- [`gl.TRIANGLE_STRIP`](https://en.wikipedia.org/wiki/Triangle_strip)
- [`gl.TRIANGLE_FAN`](https://en.wikipedia.org/wiki/Triangle_fan)
- `gl.TRIANGLES`: Draws a triangle for a group of three vertices.
- `count`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the number of elements of the bound element array
buffer to be rendered. For example, to draw a wireframe triangle with `gl.LINES`
the count should be 2 endpoints per line × 3 lines = 6 elements. However to draw the
same wireframe triangle with `gl.LINE_STRIP` the element array buffer does not
repeat the indices for the end of the first line/start of the second line, and end of the
second line/start of the third line, so `count` will be four. To draw the same
triangle with `gl.LINE_LOOP` the element array buffer does not repeat the
first/last vertex either so `count` will be three.
- `type`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the type of the values in the element array
buffer. Possible values are:
- `gl.UNSIGNED_BYTE`
- `gl.UNSIGNED_SHORT`
When using the {{domxref("OES_element_index_uint")}} extension:
- `gl.UNSIGNED_INT`
- `offset`
- : A {{domxref("WebGL_API/Types", "GLintptr")}} specifying a byte offset in the element array buffer. Must
be a valid multiple of the size of the given `type`.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- If `mode` is not one of the accepted values, a
`gl.INVALID_ENUM` error is thrown.
- If `offset` is not a valid multiple of the size of the given type, a
`gl.INVALID_OPERATION` error is thrown.
- If `count` is negative, a `gl.INVALID_VALUE` error is thrown.
## Examples
```js
gl.drawElements(gl.POINTS, 8, gl.UNSIGNED_BYTE, 0);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.drawArrays()")}}
- {{domxref("OES_element_index_uint")}}
- {{domxref("WEBGL_multi_draw.multiDrawElementsWEBGL()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/isenabled/index.md | ---
title: "WebGLRenderingContext: isEnabled() method"
short-title: isEnabled()
slug: Web/API/WebGLRenderingContext/isEnabled
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.isEnabled
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.isEnabled()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) tests whether a specific WebGL
capability is enabled or not for this context.
By default, all capabilities except `gl.DITHER` are
**disabled**.
## Syntax
```js-nolint
isEnabled(cap)
```
### Parameters
- `cap`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying which WebGL capability to test. Possible values:
| Constant | Description |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `gl.BLEND` | Blending of the computed fragment color values. See {{domxref("WebGLRenderingContext.blendFunc()")}}. |
| `gl.CULL_FACE` | Culling of polygons. See {{domxref("WebGLRenderingContext.cullFace()")}}. |
| `gl.DEPTH_TEST` | Depth comparisons and updates to the depth buffer. See {{domxref("WebGLRenderingContext.depthFunc()")}}. |
| `gl.DITHER` | Dithering of color components before they get written to the color buffer. |
| `gl.POLYGON_OFFSET_FILL` | Adding an offset to depth values of polygon's fragments. See {{domxref("WebGLRenderingContext.polygonOffset()")}}. |
| `gl.SAMPLE_ALPHA_TO_COVERAGE` | Computation of a temporary coverage value determined by the alpha value. |
| `gl.SAMPLE_COVERAGE` | ANDing the fragment's coverage with the temporary coverage value. See {{domxref("WebGLRenderingContext.sampleCoverage()")}}. |
| `gl.SCISSOR_TEST` | Scissor test that discards fragments that are outside of the scissor rectangle. See {{domxref("WebGLRenderingContext.scissor()")}}. |
| `gl.STENCIL_TEST` | Stencil testing and updates to the stencil buffer. See {{domxref("WebGLRenderingContext.stencilFunc()")}}. |
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the
following values are available additionally:
| Constant | Description |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gl.RASTERIZER_DISCARD` | Primitives are discarded immediately before the rasterization stage, but after the optional transform feedback stage. `gl.clear()` commands are ignored. |
### Return value
A {{domxref("WebGL_API/Types", "GLboolean")}} indicating if the capability _cap_ is enabled
(`true`), or not (`false`).
## Examples
```js
gl.isEnabled(gl.STENCIL_TEST);
// false
```
To activate or deactivate a specific capability, use the
{{domxref("WebGLRenderingContext.enable()")}} and
{{domxref("WebGLRenderingContext.disable()")}} methods:
```js
gl.enable(gl.STENCIL_TEST);
gl.disable(gl.STENCIL_TEST);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.enable()")}}
- {{domxref("WebGLRenderingContext.disable()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/isrenderbuffer/index.md | ---
title: "WebGLRenderingContext: isRenderbuffer() method"
short-title: isRenderbuffer()
slug: Web/API/WebGLRenderingContext/isRenderbuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.isRenderbuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.isRenderbuffer()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) returns `true` if the
passed {{domxref("WebGLRenderbuffer")}} is valid and `false` otherwise.
## Syntax
```js-nolint
isRenderbuffer(renderbuffer)
```
### Parameters
- `renderbuffer`
- : A {{domxref("WebGLRenderbuffer")}} to check.
### Return value
A {{domxref("WebGL_API/Types", "GLboolean")}} indicating whether or not the renderbuffer is valid.
## Examples
### Checking a renderbuffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const renderbuffer = gl.createRenderbuffer();
gl.isRenderbuffer(renderbuffer);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.createRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.deleteRenderbuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLFramebuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/stencilopseparate/index.md | ---
title: "WebGLRenderingContext: stencilOpSeparate() method"
short-title: stencilOpSeparate()
slug: Web/API/WebGLRenderingContext/stencilOpSeparate
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.stencilOpSeparate
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.stencilOpSeparate()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets the front and/or
back-facing stencil test actions.
## Syntax
```js-nolint
stencilOpSeparate(face, fail, zfail, zpass)
```
### Parameters
The `fail`, `zfail` and `zpass` parameters accept all
constants listed below.
- `face`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying whether the front and/or back stencil state is
updated. The possible values are:
- `gl.FRONT`
- `gl.BACK`
- `gl.FRONT_AND_BACK`
- `fail`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the function to use when the stencil test fails.
The default value is `gl.KEEP`.
- `zfail`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the function to use when the stencil test passes,
but the depth test fails. The default value is `gl.KEEP`.
- `zpass`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the function to use when both the stencil test
and the depth test pass, or when the stencil test passes and there is no depth buffer
or depth testing is disabled. The default value is `gl.KEEP`.
### Return value
None ({{jsxref("undefined")}}).
## Constants
- `gl.KEEP`
- : Keeps the current value.
- `gl.ZERO`
- : Sets the stencil buffer value to 0.
- `gl.REPLACE`
- : Sets the stencil buffer value to the reference value as specified by
{{domxref("WebGLRenderingContext.stencilFunc()")}}.
- `gl.INCR`
- : Increments the current stencil buffer value. Clamps to the maximum representable
unsigned value.
- `gl.INCR_WRAP`
- : Increments the current stencil buffer value. Wraps stencil buffer value to zero when
incrementing the maximum representable unsigned value.
- `gl.DECR`
- : Decrements the current stencil buffer value. Clamps to 0.
- `gl.DECR_WRAP`
- : Decrements the current stencil buffer value. Wraps stencil buffer value to the
maximum representable unsigned value when decrementing a stencil buffer value of 0.
- `gl.INVERT`
- : Inverts the current stencil buffer value bitwise.
## Examples
The stencil testing is disabled by default. To enable or disable stencil testing, use
the {{domxref("WebGLRenderingContext.enable", "enable()")}} and
{{domxref("WebGLRenderingContext.disable", "disable()")}} methods with the argument
`gl.STENCIL_TEST`.
```js
gl.enable(gl.STENCIL_TEST);
gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl.INVERT);
```
To get the current information about stencil and depth pass or fail, query the
following constants with {{domxref("WebGLRenderingContext.getParameter",
"getParameter()")}}.
```js
gl.getParameter(gl.STENCIL_FAIL);
gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS);
gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL);
gl.getParameter(gl.STENCIL_BACK_FAIL);
gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_PASS);
gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_FAIL);
gl.getParameter(gl.STENCIL_BITS);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.stencilOp()")}}
- {{domxref("WebGLRenderingContext.stencilFunc()")}}
- {{domxref("WebGLRenderingContext.stencilFuncSeparate()")}}
- {{domxref("WebGLRenderingContext.stencilMask()")}}
- {{domxref("WebGLRenderingContext.stencilMaskSeparate()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/deleteshader/index.md | ---
title: "WebGLRenderingContext: deleteShader() method"
short-title: deleteShader()
slug: Web/API/WebGLRenderingContext/deleteShader
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.deleteShader
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.deleteShader()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) marks a given
{{domxref("WebGLShader")}} object for deletion. It will then be deleted whenever the
shader is no longer in use. This method has no effect if the shader has already been
deleted, and the {{domxref("WebGLShader")}} is automatically marked for deletion when it
is destroyed by the garbage collector.
## Syntax
```js-nolint
deleteShader(shader)
```
### Parameters
- `shader`
- : A {{domxref("WebGLShader")}} object to delete.
### Return value
None ({{jsxref("undefined")}}).
## Examples
### Deleting a shader
```js
gl.deleteShader(shader);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createShader()")}}
- {{domxref("WebGLRenderingContext.isShader()")}}
- {{domxref("WebGLRenderingContext.getAttachedShaders()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/blendequationseparate/index.md | ---
title: "WebGLRenderingContext: blendEquationSeparate() method"
short-title: blendEquationSeparate()
slug: Web/API/WebGLRenderingContext/blendEquationSeparate
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.blendEquationSeparate
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.blendEquationSeparate()`** method
of the [WebGL API](/en-US/docs/Web/API/WebGL_API) is used to set the RGB
blend equation and alpha blend equation separately.
The blend equation determines how a new pixel is combined with a pixel already in the
{{domxref("WebGLFramebuffer")}}.
## Syntax
```js-nolint
blendEquationSeparate(modeRGB, modeAlpha)
```
### Parameters
- `modeRGB`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying how the red, green and blue components of source
and destination colors are combined. Must be either:
- `gl.FUNC_ADD`: source + destination (default value),
- `gl.FUNC_SUBTRACT`: source - destination,
- `gl.FUNC_REVERSE_SUBTRACT`: destination - source,
- When using the {{domxref("EXT_blend_minmax")}} extension:
- `ext.MIN_EXT`: Minimum of source and destination,
- `ext.MAX_EXT`: Maximum of source and destination.
- When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.MIN`: Minimum of source and destination,
- `gl.MAX`: Maximum of source and destination.
- `modeAlpha`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying how the alpha component (transparency) of source
and destination colors are combined. Must be either:
- `gl.FUNC_ADD`: source + destination (default value),
- `gl.FUNC_SUBTRACT`: source - destination,
- `gl.FUNC_REVERSE_SUBTRACT`: destination - source,
- When using the {{domxref("EXT_blend_minmax")}} extension:
- `ext.MIN_EXT`: Minimum of source and destination,
- `ext.MAX_EXT`: Maximum of source and destination.
- When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.MIN`: Minimum of source and destination,
- `gl.MAX`: Maximum of source and destination.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
If _mode_ is not one of the three possible values, a
`gl.INVALID_ENUM` error is thrown.
## Examples
To set the blend equations, use:
```js
gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_SUBTRACT);
```
To get the current blend equations, query the `BLEND_EQUATION`,
`BLEND_EQUATION_RGB` and `BLEND_EQUATION_ALPHA` constants which
return `gl.FUNC_ADD`, `gl.FUNC_SUBTRACT`,
`gl.FUNC_REVERSE_SUBTRACT`, or if the {{domxref("EXT_blend_minmax")}} is
enabled: `ext.MIN_EXT` or `ext.MAX_EXT`.
```js
gl.getParameter(gl.BLEND_EQUATION_RGB) === gl.FUNC_ADD;
// true
gl.getParameter(gl.BLEND_EQUATION_ALPHA) === gl.FUNC_ADD;
// true
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.blendEquation()")}}
- {{domxref("WebGLRenderingContext.blendColor()")}}
- {{domxref("WebGLRenderingContext.blendFunc()")}}
- {{domxref("EXT_blend_minmax")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/clear/index.md | ---
title: "WebGLRenderingContext: clear() method"
short-title: clear()
slug: Web/API/WebGLRenderingContext/clear
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.clear
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.clear()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) clears buffers to preset values.
The preset values can be set by {{domxref("WebGLRenderingContext.clearColor",
"clearColor()")}}, {{domxref("WebGLRenderingContext.clearDepth", "clearDepth()")}} or
{{domxref("WebGLRenderingContext.clearStencil", "clearStencil()")}}.
The scissor box, dithering, and buffer writemasks can affect the `clear()`
method.
## Syntax
```js-nolint
clear(mask)
```
### Parameters
- `mask`
- : A {{domxref("WebGL_API/Types", "GLbitfield")}} bitwise OR mask that indicates the buffers to be
cleared. Possible values are:
- `gl.COLOR_BUFFER_BIT`
- `gl.DEPTH_BUFFER_BIT`
- `gl.STENCIL_BUFFER_BIT`
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
If _mask_ is not one of the listed possible values, a
`gl.INVALID_ENUM` error is thrown.
## Examples
The `clear()` method accepts multiple values.
```js
gl.clear(gl.DEPTH_BUFFER_BIT);
gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT);
```
To get the current clear values, query the `COLOR_CLEAR_VALUE`,
`DEPTH_CLEAR_VALUE`, and `STENCIL_CLEAR_VALUE` constants.
```js
gl.getParameter(gl.COLOR_CLEAR_VALUE);
gl.getParameter(gl.DEPTH_CLEAR_VALUE);
gl.getParameter(gl.STENCIL_CLEAR_VALUE);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.clearColor()")}}
- {{domxref("WebGLRenderingContext.clearDepth()")}}
- {{domxref("WebGLRenderingContext.clearStencil()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/framebufferrenderbuffer/index.md | ---
title: "WebGLRenderingContext: framebufferRenderbuffer() method"
short-title: framebufferRenderbuffer()
slug: Web/API/WebGLRenderingContext/framebufferRenderbuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.framebufferRenderbuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.framebufferRenderbuffer()`**
method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) attaches a
{{domxref("WebGLRenderbuffer")}} object to a {{domxref("WebGLFramebuffer")}} object.
## Syntax
```js-nolint
framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target) for the framebuffer.
Possible values:
- `gl.FRAMEBUFFER`
- : Collection buffer data storage of color, alpha,
depth and stencil buffers used to render an image.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.DRAW_FRAMEBUFFER`
- : Equivalent to `gl.FRAMEBUFFER`.
Used as a destination for drawing, rendering, clearing, and writing operations.
- `gl.READ_FRAMEBUFFER`
- : Used as a source for reading operations.
- `attachment`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the attachment point for the render buffer.
Possible values:
- `gl.COLOR_ATTACHMENT0`: color buffer.
- `gl.DEPTH_ATTACHMENT`: depth buffer.
- `gl.DEPTH_STENCIL_ATTACHMENT`: depth and stencil buffer.
- `gl.STENCIL_ATTACHMENT`: stencil buffer.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.COLOR_ATTACHMENT1 gl.COLOR_ATTACHMENT2 gl.COLOR_ATTACHMENT3 gl.COLOR_ATTACHMENT4 gl.COLOR_ATTACHMENT5 gl.COLOR_ATTACHMENT6 gl.COLOR_ATTACHMENT7 gl.COLOR_ATTACHMENT8 gl.COLOR_ATTACHMENT9 gl.COLOR_ATTACHMENT10 gl.COLOR_ATTACHMENT11 gl.COLOR_ATTACHMENT12 gl.COLOR_ATTACHMENT13 gl.COLOR_ATTACHMENT14 gl.COLOR_ATTACHMENT15`
When using the {{domxref("WEBGL_draw_buffers")}} extension:
- `ext.COLOR_ATTACHMENT0_WEBGL` (same as
`gl.COLOR_ATTACHMENT0`)
- `ext.COLOR_ATTACHMENT1_WEBGL ext.COLOR_ATTACHMENT2_WEBGL ext.COLOR_ATTACHMENT3_WEBGL ext.COLOR_ATTACHMENT4_WEBGL ext.COLOR_ATTACHMENT5_WEBGL ext.COLOR_ATTACHMENT6_WEBGL ext.COLOR_ATTACHMENT7_WEBGL ext.COLOR_ATTACHMENT8_WEBGL ext.COLOR_ATTACHMENT9_WEBGL ext.COLOR_ATTACHMENT10_WEBGL ext.COLOR_ATTACHMENT11_WEBGL ext.COLOR_ATTACHMENT12_WEBGL ext.COLOR_ATTACHMENT13_WEBGL ext.COLOR_ATTACHMENT14_WEBGL ext.COLOR_ATTACHMENT15_WEBGL`
- `renderbuffertarget`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target) for the render buffer.
Possible values:
- `gl.RENDERBUFFER`
- : Buffer data storage for single images in a renderable internal format.
- `renderbuffer`
- : A {{domxref("WebGLRenderbuffer")}} object to attach.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- A `gl.INVALID_ENUM` error is thrown if `target` is not
`gl.FRAMEBUFFER`, `gl.DRAW_FRAMEBUFFER`, or
`gl.READ_FRAMEBUFFER`.
- A `gl.INVALID_ENUM` error is thrown if `renderbuffertarget` is
not `gl.RENDERBUFFER`.
- A `gl.INVALID_ENUM` error is thrown if `attachment` is not one
of the allowed enums.
## Examples
```js
gl.framebufferRenderbuffer(
gl.FRAMEBUFFER,
gl.COLOR_ATTACHMENT0,
gl.RENDERBUFFER,
renderbuffer,
);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createFramebuffer()")}}
- {{domxref("WebGLRenderingContext.deleteFramebuffer()")}}
- {{domxref("WebGLRenderingContext.isFramebuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLRenderbuffer")}}
- {{domxref("WEBGL_draw_buffers")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/texparameter/index.md | ---
title: "WebGLRenderingContext: texParameter[fi]() method"
short-title: texParameter[fi]()
slug: Web/API/WebGLRenderingContext/texParameter
page-type: web-api-instance-method
browser-compat:
- api.WebGLRenderingContext.texParameterf
- api.WebGLRenderingContext.texParameteri
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.texParameter[fi]()`** methods of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) set texture parameters.
## Syntax
```js-nolint
texParameterf(target, pname, param)
texParameteri(target, pname, param)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP`: A cube-mapped texture.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:
- `gl.TEXTURE_3D`: A three-dimensional texture.
- `gl.TEXTURE_2D_ARRAY`: A two-dimensional array texture.
- `param`
- : The `param` parameter is a {{domxref("WebGL_API/Types", "GLfloat")}} or
{{domxref("WebGL_API/Types", "GLint")}} specifying the value for the specified parameter
- `pname`
- : The `pname` parameter is a {{domxref("WebGL_API/Types", "GLenum")}} specifying the texture
parameter to set.
<table class="standard-table">
<thead>
<tr>
<th scope="col"><code>pname</code></th>
<th scope="col">Description</th>
<th scope="col"><code>param</code></th>
</tr>
</thead>
<tbody>
<tr>
<th colspan="3">Available in WebGL 1</th>
</tr>
<tr>
<td><code>gl.TEXTURE_MAG_FILTER</code></td>
<td>Texture magnification filter</td>
<td><code>gl.LINEAR</code> (default value), <code>gl.NEAREST</code>.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MIN_FILTER</code></td>
<td>Texture minification filter</td>
<td>
<code>gl.LINEAR</code>, <code>gl.NEAREST</code>,
<code>gl.NEAREST_MIPMAP_NEAREST</code>,
<code>gl.LINEAR_MIPMAP_NEAREST</code>,
<code>gl.NEAREST_MIPMAP_LINEAR</code> (default value),
<code>gl.LINEAR_MIPMAP_LINEAR</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_WRAP_S</code></td>
<td>Wrapping function for texture coordinate <code>s</code></td>
<td>
<code>gl.REPEAT</code> (default value),<code>gl.CLAMP_TO_EDGE</code>,
<code>gl.MIRRORED_REPEAT</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_WRAP_T</code></td>
<td>Wrapping function for texture coordinate <code>t</code></td>
<td>
<code>gl.REPEAT</code> (default value),<code>gl.CLAMP_TO_EDGE</code>,
<code>gl.MIRRORED_REPEAT</code>.
</td>
</tr>
<tr>
<th colspan="3">
Additionally available when using the
{{domxref("EXT_texture_filter_anisotropic")}} extension
</th>
</tr>
<tr>
<td><code>ext.TEXTURE_MAX_ANISOTROPY_EXT</code></td>
<td>Maximum anisotropy for a texture</td>
<td>A {{domxref("WebGL_API/Types", "GLfloat")}} value.</td>
</tr>
<tr>
<th colspan="3">Additionally available when using a WebGL 2 context</th>
</tr>
<tr>
<td><code>gl.TEXTURE_BASE_LEVEL</code></td>
<td>Texture mipmap level</td>
<td>Any int values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_COMPARE_FUNC</code></td>
<td>Texture Comparison function</td>
<td>
<code>gl.LEQUAL</code> (default value), <code>gl.GEQUAL</code>,
<code>gl.LESS</code>, <code>gl.GREATER</code>, <code>gl.EQUAL</code>,
<code>gl.NOTEQUAL</code>, <code>gl.ALWAYS</code>, <code>gl.NEVER</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_COMPARE_MODE</code></td>
<td>Texture comparison mode</td>
<td>
<code>gl.NONE</code> (default value),
<code>gl.COMPARE_REF_TO_TEXTURE</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MAX_LEVEL</code></td>
<td>Maximum texture mipmap array level</td>
<td>Any int values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MAX_LOD</code></td>
<td>Texture maximum level-of-detail value</td>
<td>Any float values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MIN_LOD</code></td>
<td>Texture minimum level-of-detail value</td>
<td>Any float values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_WRAP_R</code></td>
<td>Wrapping function for texture coordinate <code>r</code></td>
<td>
<code>gl.REPEAT</code> (default value), <code>gl.CLAMP_TO_EDGE</code>,
<code>gl.MIRRORED_REPEAT</code>.
</td>
</tr>
</tbody>
</table>
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(
gl.TEXTURE_2D,
gl.TEXTURE_MIN_FILTER,
gl.LINEAR_MIPMAP_NEAREST,
);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getTexParameter()")}}
- {{domxref("EXT_texture_filter_anisotropic")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getshaderparameter/index.md | ---
title: "WebGLRenderingContext: getShaderParameter() method"
short-title: getShaderParameter()
slug: Web/API/WebGLRenderingContext/getShaderParameter
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getShaderParameter
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getShaderParameter()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns information about the
given shader.
## Syntax
```js-nolint
getShaderParameter(shader, pname)
```
### Parameters
- `shader`
- : A {{domxref("WebGLShader")}} to get parameter information from.
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the information to query. Possible values:
- `gl.DELETE_STATUS`
- : Returns a {{domxref("WebGL_API/Types", "GLboolean")}} indicating
whether or not the shader is flagged for deletion.
- `gl.COMPILE_STATUS`
- : Returns a {{domxref("WebGL_API/Types", "GLboolean")}} indicating
whether or not the last shader compilation was successful.
- `gl.SHADER_TYPE`
- : Returns a {{domxref("WebGL_API/Types", "GLenum")}} indicating whether
the shader is a vertex shader (`gl.VERTEX_SHADER`) or fragment shader
(`gl.FRAGMENT_SHADER`) object.
### Return value
Returns the requested shader information (as specified with `pname`).
## Examples
```js
gl.getShaderParameter(shader, gl.SHADER_TYPE);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/geterror/index.md | ---
title: "WebGLRenderingContext: getError() method"
short-title: getError()
slug: Web/API/WebGLRenderingContext/getError
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getError
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getError()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns error information.
## Syntax
```js-nolint
getError()
```
### Parameters
None.
### Return value
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Constant</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.NO_ERROR</code></td>
<td>No error has been recorded. The value of this constant is 0.</td>
</tr>
<tr>
<td><code>gl.INVALID_ENUM</code></td>
<td>
An unacceptable value has been specified for an enumerated argument. The
command is ignored and the error flag is set.
</td>
</tr>
<tr>
<td><code>gl.INVALID_VALUE</code></td>
<td>
A numeric argument is out of range. The command is ignored and the error
flag is set.
</td>
</tr>
<tr>
<td><code>gl.INVALID_OPERATION</code></td>
<td>
The specified command is not allowed for the current state. The command
is ignored and the error flag is set.
</td>
</tr>
<tr>
<td><code>gl.INVALID_FRAMEBUFFER_OPERATION</code></td>
<td>
The currently bound framebuffer is not framebuffer complete when trying
to render to or to read from it.
</td>
</tr>
<tr>
<td><code>gl.OUT_OF_MEMORY</code></td>
<td>Not enough memory is left to execute the command.</td>
</tr>
<tr>
<td><code>gl.CONTEXT_LOST_WEBGL</code></td>
<td>
If the WebGL context is lost, this error is returned on the first call
to <code>getError</code>. Afterwards and until the context has been
restored, it returns <code>gl.NO_ERROR</code>.
</td>
</tr>
</tbody>
</table>
## Examples
```js
gl.getError(); // gl.NO_ERROR (0)
gl.enable(gl.FOOBAR);
gl.getError(); // gl.INVALID_ENUM;
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext")}}
- {{domxref("WebGLContextEvent")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/isshader/index.md | ---
title: "WebGLRenderingContext: isShader() method"
short-title: isShader()
slug: Web/API/WebGLRenderingContext/isShader
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.isShader
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.isShader()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns `true` if the
passed {{domxref("WebGLShader")}} is valid, `false` otherwise.
## Syntax
```js-nolint
isShader(shader)
```
### Parameters
- `shader`
- : A {{domxref("WebGLShader")}} to check.
### Return value
A {{domxref("WebGL_API/Types", "GLboolean")}} indicating whether or not the shader is valid.
## Examples
### Checking a shader
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const shader = gl.createShader(gl.VERTEX_SHADER);
// …
gl.isShader(shader);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createShader()")}}
- {{domxref("WebGLRenderingContext.deleteShader()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/stencilfunc/index.md | ---
title: "WebGLRenderingContext: stencilFunc() method"
short-title: stencilFunc()
slug: Web/API/WebGLRenderingContext/stencilFunc
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.stencilFunc
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.stencilFunc()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets the front and back function
and reference value for stencil testing.
Stenciling enables and disables drawing on a per-pixel basis. It is typically used in
multipass rendering to achieve special effects.
## Syntax
```js-nolint
stencilFunc(func, ref, mask)
```
### Parameters
- `func`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the test function. The default function is
`gl.ALWAYS`. The possible values are:
- `gl.NEVER`: Never pass.
- `gl.LESS`: Pass if
`(ref & mask) < (stencil & mask)`.
- `gl.EQUAL`: Pass if
`(ref & mask) = (stencil & mask)`.
- `gl.LEQUAL`: Pass if
`(ref & mask) <= (stencil & mask)`.
- `gl.GREATER`: Pass if
`(ref & mask) > (stencil & mask)`.
- `gl.NOTEQUAL`: Pass if
`(ref & mask) !== (stencil & mask)`.
- `gl.GEQUAL`: Pass if
`(ref & mask) >= (stencil & mask)`.
- `gl.ALWAYS`: Always pass.
- `ref`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the reference value for the stencil test. This
value is clamped to the range 0 to 2^n - 1 where n is the number of bitplanes
in the stencil buffer. The default value is 0.
- `mask`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying a bit-wise mask that is used to AND the reference
value and the stored stencil value when the test is done. The default value is all 1.
### Return value
None ({{jsxref("undefined")}}).
## Examples
The stencil testing is disabled by default. To enable or disable stencil testing, use
the {{domxref("WebGLRenderingContext.enable", "enable()")}} and
{{domxref("WebGLRenderingContext.disable", "disable()")}} methods with the argument
`gl.STENCIL_TEST`.
```js
gl.enable(gl.STENCIL_TEST);
gl.stencilFunc(gl.LESS, 0, 0b1110011);
```
To get the current stencil function, reference value, or other stencil information,
query the following constants with {{domxref("WebGLRenderingContext.getParameter",
"getParameter()")}}.
```js
gl.getParameter(gl.STENCIL_FUNC);
gl.getParameter(gl.STENCIL_VALUE_MASK);
gl.getParameter(gl.STENCIL_REF);
gl.getParameter(gl.STENCIL_BACK_FUNC);
gl.getParameter(gl.STENCIL_BACK_VALUE_MASK);
gl.getParameter(gl.STENCIL_BACK_REF);
gl.getParameter(gl.STENCIL_BITS);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.stencilFuncSeparate()")}}
- {{domxref("WebGLRenderingContext.stencilMask()")}}
- {{domxref("WebGLRenderingContext.stencilMaskSeparate()")}}
- {{domxref("WebGLRenderingContext.stencilOp()")}}
- {{domxref("WebGLRenderingContext.stencilOpSeparate()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getcontextattributes/index.md | ---
title: "WebGLRenderingContext: getContextAttributes() method"
short-title: getContextAttributes()
slug: Web/API/WebGLRenderingContext/getContextAttributes
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getContextAttributes
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getContextAttributes()`** method
returns a `WebGLContextAttributes` object that contains the actual context
parameters. Might return [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null), if the context is lost.
## Syntax
```js-nolint
getContextAttributes()
```
### Parameters
None.
### Return value
A `WebGLContextAttributes` object that contains the actual context
parameters, or [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null) if the context is lost.
## Examples
Given this {{HTMLElement("canvas")}} element
```html
<canvas id="canvas"></canvas>
```
and given this WebGL context
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.getContextAttributes();
```
the `getContextAttributes` method returns an object that describes the
attributes set on this context, for example:
```js
{
alpha: true,
antialias: true,
depth: true,
failIfMajorPerformanceCaveat: false,
powerPreference: "default",
premultipliedAlpha: true,
preserveDrawingBuffer: false,
stencil: false,
desynchronized: false
}
```
The context attributes can be set when creating the context using the
{{domxref("HTMLCanvasElement.getContext()")}} method:
```js
canvas.getContext("webgl", { antialias: false, depth: false });
```
See {{domxref("HTMLCanvasElement.getContext()", "getContext()")}} for more information
about the individual attributes.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("HTMLCanvasElement.getContext()")}}
- {{domxref("CanvasRenderingContext2D.getContextAttributes()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/viewport/index.md | ---
title: "WebGLRenderingContext: viewport() method"
short-title: viewport()
slug: Web/API/WebGLRenderingContext/viewport
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.viewport
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.viewport()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets the viewport, which specifies
the affine transformation of x and y from normalized device coordinates to window
coordinates.
## Syntax
```js-nolint
viewport(x, y, width, height)
```
### Parameters
- `x`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the horizontal coordinate for the lower left
corner of the viewport origin. Default value: 0.
- `y`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the vertical coordinate for the lower left corner
of the viewport origin. Default value: 0.
- `width`
- : A non-negative {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the viewport. Default
value: width of the canvas.
- `height`
- : A non-negative {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the viewport. Default
value: height of the canvas.
### Return value
None ({{jsxref("undefined")}}).
### Errors thrown
If either _width_ or _height_ is a negative value, a
`gl.INVALID_VALUE` error is thrown.
## Examples
When you first create a WebGL context, the size of the viewport will match the size of
the canvas. However, if you resize the canvas, you will need to tell the WebGL context a
new viewport setting. In this situation, you can use `gl.viewport`.
```js
gl.viewport(0, 0, canvas.width, canvas.height);
```
The viewport width and height are clamped to a range that is implementation dependent.
To get this range, you can use the `MAX_VIEWPORT_DIMS` constant, which
returns an {{jsxref("Int32Array")}}.
```js
gl.getParameter(gl.MAX_VIEWPORT_DIMS);
// e.g. Int32Array[16384, 16384]
```
To get the current viewport, query the `VIEWPORT` constant.
```js
gl.getParameter(gl.VIEWPORT);
// e.g. Int32Array[0, 0, 640, 480]
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.scissor()")}}
- {{domxref("WebGLRenderingContext.getParameter()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/gettexparameter/index.md | ---
title: "WebGLRenderingContext: getTexParameter() method"
short-title: getTexParameter()
slug: Web/API/WebGLRenderingContext/getTexParameter
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getTexParameter
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getTexParameter()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) returns information about the
given texture.
## Syntax
```js-nolint
getTexParameter(target, pname)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.TEXTURE_2D`: A two-dimensional texture.
- `gl.TEXTURE_CUBE_MAP`: A cube-mapped texture.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.TEXTURE_3D`: A three-dimensional texture.
- `gl.TEXTURE_2D_ARRAY`: A two-dimensional array texture.
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the information to query. Possible values:
<table class="standard-table">
<thead>
<tr>
<th scope="col">pname</th>
<th scope="col">Return type</th>
<th scope="col">Description</th>
<th scope="col">Possible return values</th>
</tr>
</thead>
<tbody>
<tr>
<th colspan="4">Available in a WebGL 1 context</th>
</tr>
<tr>
<td><code>gl.TEXTURE_MAG_FILTER</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>Texture magnification filter</td>
<td><code>gl.LINEAR</code> (default value), <code>gl.NEAREST</code>.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MIN_FILTER</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>Texture minification filter</td>
<td>
<code>gl.LINEAR</code>, <code>gl.NEAREST</code>,
<code>gl.NEAREST_MIPMAP_NEAREST</code>,
<code>gl.LINEAR_MIPMAP_NEAREST</code>,
<code>gl.NEAREST</code>_MIPMAP_LINEAR (default value),
<code>gl.LINEAR_MIPMAP_LINEAR</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_WRAP_S</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>Wrapping function for texture coordinate <code>s</code></td>
<td>
<code>gl.REPEAT</code> (default value), <code>gl.CLAMP_TO_EDGE</code>,
<code>gl.MIRRORED_REPEAT</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_WRAP_T</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>Wrapping function for texture coordinate <code>t</code></td>
<td>
<code>gl.REPEAT</code> (default value), <code>gl.CLAMP_TO_EDGE</code>,
<code>gl.MIRRORED_REPEAT</code>.
</td>
</tr>
<tr>
<th colspan="4">
Additionally available when using the
{{domxref("EXT_texture_filter_anisotropic")}} extension
</th>
</tr>
<tr>
<td><code>ext.TEXTURE_MAX_ANISOTROPY_EXT</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td>Maximum anisotropy for a texture</td>
<td>Any float values.</td>
</tr>
<tr>
<th colspan="4">Additionally available when using a WebGL 2 context</th>
</tr>
<tr>
<td><code>gl.TEXTURE_BASE_LEVEL</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>Texture mipmap level</td>
<td>Any int values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_COMPARE_FUNC</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>Comparison function</td>
<td>
<code>gl.LEQUAL</code> (default value), <code>gl.GEQUAL</code>,
<code>gl.LESS</code>, <code>gl.GREATER</code>, <code>gl.EQUAL</code>,
<code>gl.NOTEQUAL</code>, <code>gl.ALWAYS</code>, <code>gl.NEVER</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_COMPARE_MODE</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>Texture comparison mode</td>
<td>
<code>gl.NONE</code> (default value),
<code>gl.COMPARE_REF_TO_TEXTURE</code>.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_IMMUTABLE_FORMAT</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td>Immutability of the texture format and size</td>
<td>true or false.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_IMMUTABLE_LEVELS</code></td>
<td>{{domxref("WebGL_API/Types", "GLuint")}}</td>
<td>?</td>
<td>Any uint values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MAX_LEVEL</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>Maximum texture mipmap array level</td>
<td>Any int values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MAX_LOD</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td>Texture maximum level-of-detail value</td>
<td>Any float values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_MIN_LOD</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td>Texture minimum level-of-detail value</td>
<td>Any float values.</td>
</tr>
<tr>
<td><code>gl.TEXTURE_WRAP_R</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>Wrapping function for texture coordinate <code>r</code></td>
<td>
<code>gl.REPEAT</code> (default value), <code>gl.CLAMP_TO_EDGE</code>,
<code>gl.MIRRORED_REPEAT</code>.
</td>
</tr>
</tbody>
</table>
### Return value
Returns the requested texture information (as specified with `pname`). If an
error occurs, [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null) is returned.
## Examples
```js
gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.texParameter",
"WebGLRenderingContext.texParameterf()")}}
- {{domxref("WebGLRenderingContext.texParameter",
"WebGLRenderingContext.texParameteri()")}}
- {{domxref("EXT_texture_filter_anisotropic")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/createframebuffer/index.md | ---
title: "WebGLRenderingContext: createFramebuffer() method"
short-title: createFramebuffer()
slug: Web/API/WebGLRenderingContext/createFramebuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.createFramebuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.createFramebuffer()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) creates and initializes a
{{domxref("WebGLFramebuffer")}} object.
## Syntax
```js-nolint
createFramebuffer()
```
### Parameters
None.
### Return value
A {{domxref("WebGLFramebuffer")}} object.
## Examples
### Creating a frame buffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const framebuffer = gl.createFramebuffer();
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindFramebuffer()")}}
- {{domxref("WebGLRenderingContext.deleteFramebuffer()")}}
- {{domxref("WebGLRenderingContext.isFramebuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/checkframebufferstatus/index.md | ---
title: "WebGLRenderingContext: checkFramebufferStatus() method"
short-title: checkFramebufferStatus()
slug: Web/API/WebGLRenderingContext/checkFramebufferStatus
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.checkFramebufferStatus
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.checkFramebufferStatus()`** method
of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns the completeness
status of the {{domxref("WebGLFramebuffer")}} object.
## Syntax
```js-nolint
checkFramebufferStatus(target)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.FRAMEBUFFER`
- : Collection buffer data storage of color, alpha,
depth and stencil buffers used to render an image.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.DRAW_FRAMEBUFFER`
- : Equivalent to `gl.FRAMEBUFFER`.
Used as a destination for drawing, rendering, clearing, and writing operations.
- `gl.READ_FRAMEBUFFER`
- : Used as a source for reading operations.
### Return value
A {{domxref("WebGL_API/Types", "GLenum")}} indicating the completeness status of the framebuffer or
`0` if an error occurs. Possible enum return values:
- `gl.FRAMEBUFFER_COMPLETE`: The framebuffer is ready to display.
- `gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT`: The attachment types are
mismatched or not all framebuffer attachment points are framebuffer attachment
complete.
- `gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT`: There is no attachment.
- `gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS`: Height and width of the
attachment are not the same.
- `gl.FRAMEBUFFER_UNSUPPORTED`: The format of the attachment is not
supported or if depth and stencil attachments are not the same renderbuffer.
- When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the
following values can be returned additionally:
- `gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE`: The values of
`gl.RENDERBUFFER_SAMPLES` are different among attached renderbuffers,
or are non-zero if the attached images are a mix of renderbuffers and textures.
- When using the {{domxref("OVR_multiview2")}} extension, the following value can be
returned additionally:
- `ext.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR`: If
`baseViewIndex` is not the same for all framebuffer attachment points
where the value of `FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE` is not
`NONE`, the framebuffer is considered incomplete.
## Examples
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const framebuffer = gl.createFramebuffer();
// …
gl.checkFramebufferStatus(gl.FRAMEBUFFER);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createFramebuffer()")}}
- {{domxref("WebGLRenderingContext.deleteFramebuffer()")}}
- {{domxref("WebGLRenderingContext.isFramebuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/flush/index.md | ---
title: "WebGLRenderingContext: flush() method"
short-title: flush()
slug: Web/API/WebGLRenderingContext/flush
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.flush
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.flush()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) empties different buffer commands,
causing all commands to be executed as quickly as possible.
## Syntax
```js-nolint
flush()
```
### Parameters
None.
### Return value
None ({{jsxref("undefined")}}).
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.finish()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/createtexture/index.md | ---
title: "WebGLRenderingContext: createTexture() method"
short-title: createTexture()
slug: Web/API/WebGLRenderingContext/createTexture
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.createTexture
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.createTexture()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) creates and initializes a
{{domxref("WebGLTexture")}} object.
## Syntax
```js-nolint
createTexture()
```
### Parameters
None.
### Return value
A {{domxref("WebGLTexture")}} object to which images can be bound to.
## Examples
See also the [WebGL tutorial](/en-US/docs/Web/API/WebGL_API/Tutorial) on [Using textures in WebGL](/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL).
### Creating a texture
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const texture = gl.createTexture();
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindTexture()")}}
- {{domxref("WebGLRenderingContext.deleteTexture()")}}
- {{domxref("WebGLRenderingContext.isTexture()")}}
- {{domxref("WebGLRenderingContext.texImage2D()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/deletetexture/index.md | ---
title: "WebGLRenderingContext: deleteTexture() method"
short-title: deleteTexture()
slug: Web/API/WebGLRenderingContext/deleteTexture
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.deleteTexture
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.deleteTexture()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) deletes a given
{{domxref("WebGLTexture")}} object. This method has no effect if the texture has already
been deleted.
## Syntax
```js-nolint
deleteTexture(texture)
```
### Parameters
- `texture`
- : A {{domxref("WebGLTexture")}} object to delete.
### Return value
None ({{jsxref("undefined")}}).
## Examples
### Deleting a texture
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const texture = gl.createTexture();
// …
gl.deleteTexture(texture);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindTexture()")}}
- {{domxref("WebGLRenderingContext.createTexture()")}}
- {{domxref("WebGLRenderingContext.isTexture()")}}
- {{domxref("WebGLRenderingContext.texImage2D()")}}
| 0 |
Subsets and Splits