From eea98b941c99d850fb98fb54e2789d34218a707b Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Thu, 9 Jan 2025 12:47:43 -0800 Subject: [PATCH] add options --- .../dpr-zoom-test-with-visualviewport.html | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/test/devicepixelcontentbox-with-visualviewport-scale/dpr-zoom-test-with-visualviewport.html b/test/devicepixelcontentbox-with-visualviewport-scale/dpr-zoom-test-with-visualviewport.html index 9dd74f6..db22e99 100644 --- a/test/devicepixelcontentbox-with-visualviewport-scale/dpr-zoom-test-with-visualviewport.html +++ b/test/devicepixelcontentbox-with-visualviewport-scale/dpr-zoom-test-with-visualviewport.html @@ -8,6 +8,7 @@ html, body { margin: 0; /* remove the default margin */ height: 100%; /* make the html,body fill the page */ + font-family: monospace; } canvas { display: block; /* make the canvas act like a block */ @@ -22,6 +23,18 @@ margin: 0; background-color: rgba(0, 0, 0, 0.7); color: white; +} +label { + display: inline-flex; + align-items: center; + gap: 0.25em; +} +input { + margin: 0; +} +.pixelated { + image-rendering: pixelated; + image-rendering: crisp-edges; } @@ -33,6 +46,9 @@ +
+ +

 
   
@@ -59,8 +75,10 @@
 out vec4 fragColor;
 void main() {
   vec2 hv = vec2(floor(mod(gl_FragCoord.xy, 2.0)));
-  fragColor = vec4(1, 0, 1, 1) * hv.x +
-              vec4(0, 1, 0, 1) * hv.y;
+  float s = mod(floor(gl_FragCoord.x / 256.0), 2.0);
+  vec4 hStripe = mix(vec4(1,0,0,1), vec4(1, 1, 0, 1), hv.x);
+  vec4 vStripe = mix(vec4(0,1,0,1), vec4(0, 0, 1, 1), hv.y);
+  fragColor = mix(hStripe, vStripe, s);
 }
 `;
 
@@ -69,6 +87,11 @@
 const radioElems = [...document.querySelectorAll('[name="mode"]')];
 radioElems.forEach(e => e.addEventListener('change', _ => render()));
 
+const pixelatedElem = document.querySelector('#pixelated');
+pixelatedElem.addEventListener('change', e => {
+  canvas.classList.toggle('pixelated', pixelatedElem.checked);
+});
+
 let renderCount = 0;
 const elemSizes = new WeakMap();
 function render() {