Skip to content

Instantly share code, notes, and snippets.

@herrernst
Last active July 5, 2023 20:49
Show Gist options
  • Save herrernst/c48309acd83c6b56b3dbef69b76ed291 to your computer and use it in GitHub Desktop.
Save herrernst/c48309acd83c6b56b3dbef69b76ed291 to your computer and use it in GitHub Desktop.
examples to test macOS scaling artifacts
<!doctype html>
<style>
:root {
background-color: white;
background-image:
linear-gradient(45deg, #000 25%, transparent 25%),
linear-gradient(-45deg, #000 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, #000 75%),
linear-gradient(-45deg, transparent 75%, #000 75%);
background-size:2px 2px;
background-position: 0 0, 0 1px, 1px -1px, -1px 0px;
}
</style>
<!doctype html>
<h1>45 degrees</h1>
<svg width="100" height="100">
<line x1="0" y1="0" x2="100" y2="100" stroke="black" />
</svg>
<h1>45 degrees parallel</h1>
<svg width="102" height="100">
<line x1="0" y1="0" x2="100" y2="100" stroke="black" />
<line x1="2" y1="0" x2="102" y2="100" stroke="black" />
</svg>
<h1>1px shift 500 wide</h1>
<svg width="500" height="100">
<line x1="0" y1="0" x2="500" y2="10" stroke="black" shape-rendering="geometricPrecision" />
</svg>
<h1>1px shift 100 wide</h1>
<svg width="100" height="100">
<line x1="0" y1="0" x2="100" y2="10" stroke="black"/>
</svg>
<!doctype html>
<style>
#line {
width: 100%;
border-bottom: 1px solid black;
position: absolute;
}
body {
margin: 0;
}
</style>
<div id="line"></div>
<script>
const line = document.getElementById("line");
(function moveDown() {
const newVal = (parseInt(getComputedStyle(line).top) + 1) % window.innerHeight + "px"
line.style.top = newVal
requestAnimationFrame(moveDown)
})()
</script>
<!doctype html>
<style>
body {
display: flex;
}
body > div {
flex-grow: 1;
margin: 8px;
border: 1px solid red;
color: blue;
}
div div {
height: 400px;
}
.div1 {
background: repeating-linear-gradient(
to bottom,
#fff,
#fff 1px,
#333 1px,
#333 2px
);
}
.div2 {
background: repeating-linear-gradient(
to bottom,
#fff,
#fff 1px,
#333 1px,
#333 3px
);
}
.div3 {
background: repeating-linear-gradient(
to bottom,
#fff,
#fff 2px,
#333 2px,
#333 3px
);
}
.div4 {
background: repeating-linear-gradient(
45deg,
#fff,
#fff 1.414px,
#333 1.414px,
#333 2.828px
);
}
</style>
<div>
<h1>1:1</h1>
<div class="div1"></div>
</div>
<div>
<h1>1:2</h1>
<div class="div2"></div>
</div>
<div>
<h1>2:1</h1>
<div class="div3"></div>
</div>
<div>
<h1>sqrt(2)</h1>
<div class="div4"></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment