我遇到的情况是,着色器在我的 Apple (M1) iMac(以及 iPhone)上产生的输出与我的 Intel(i5-4300U / Haswell-ULT 集成图形控制器)Thinkpad 440 上产生的输出完全不同(更多信息见评论)。然而,Chrome 和 Safari 等浏览器之间似乎没有区别。Chrome 和 GNOME Web 在 iMac 上分别生成相同的图像。笔记本电脑。我的 Intel Thinkpad 13 Chromebook 也显示 Intel 版本(显然无法测试除 Chrome 之外的其他浏览器)。这可能是什么原因?
[编辑] 大多数人(朋友和下面评论的人)似乎都获得了苹果版本,所以只有我和我的两台笔记本电脑显然获得了英特尔版本?
这是着色器:
const gl = document.querySelector("canvas").getContext("webgl");
gl.canvas.width = gl.canvas.height = 512
gl.viewport(0, 0, 512, 512);
const programInfo = twgl.createProgramInfo(gl, ["vs", "fs"]);
const bufferInfo = twgl.createBufferInfoFromArrays(gl, {
a_Position: {
numComponents: 2,
data: [-1, -1, -1, 3, 3, -1]
},
});
gl.useProgram(programInfo.program);
twgl.setBuffersAndAttributes(gl, programInfo, bufferInfo);
twgl.drawBufferInfo(gl, bufferInfo);Run Code Online (Sandbox Code Playgroud)
<script src="https://twgljs.org/dist/4.x/twgl-full.min.js"></script>
<script id="vs" type="x-shader/x-vertex"> …Run Code Online (Sandbox Code Playgroud)读取文件然后将内容写入同一文件的最快/最优雅的方法是什么?
在Linux上,这并不总是与“触摸”文件相同,例如,如果文件代表某个硬件设备。
对我echo $(cat $file) > $file有用的一种可能性是,但我想知道这是否是最佳实践。
是否可以获取 SVG 路径的边界框而不将其放入 dom 中?
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute('width', '391');
svg.setAttribute('height', '391');
svg.setAttribute('viewBox', "-70.5 -70.5 391 391");
svg.innerHTML = `<rect fill="#fff" stroke="#000" x="-70" y="-70" width="390" height="390"/>
<g opacity="0.8">
<rect x="25" y="25" width="200" height="200" fill="lime" stroke-width="4" stroke="pink" />
<circle cx="125" cy="125" r="75" fill="orange" />
<polyline points="50,150 50,200 200,200 200,100" stroke="red" stroke-width="4" fill="none" />
<line x1="50" y1="50" x2="200" y2="200" stroke="blue" stroke-width="4" />
</g>`;
let box = svg.getBBox();
document.body.innerHTML += `<p>x:${box.x}, y:${box.y}, width:${box.width}, height:${box.height}</p>`;
document.body.appendChild(svg);
box = svg.getBBox();
document.body.innerHTML += `<p>x:${box.x}, …Run Code Online (Sandbox Code Playgroud)我刚刚偶然发现了overflow: hiddenon的这种用法html,这对我来说似乎不合逻辑:
* {
all: unset;
display: revert;
}
html {
height: 100vh;
overflow: hidden;
background: black;
}
body {
height: 50vh;
font-size: 5rem;
background: white;
scroll-snap-type: y mandatory;
scroll-behavior: smooth;
overflow-y: scroll;
}Run Code Online (Sandbox Code Playgroud)
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen …Run Code Online (Sandbox Code Playgroud)