Skip to content

Instantly share code, notes, and snippets.

View lumixraku's full-sized avatar
🌴
On vacation

lumix lumixraku

🌴
On vacation
View GitHub Profile
const getOffset = el => {
const {
top,
left
} = el.getBoundingClientRect()
const {
scrollTop,
scrollLeft
} = document.body
return {
@lumixraku
lumixraku / Unit8Array to Image, SkiaImage
Last active January 5, 2024 11:55
Unit8Array to Image, SkiaImage
const blob = new Blob([skiaImage.encodeToBytes()], { type: 'image/png' })
const imageUrl = URL.createObjectURL(blob);
const img = new Image();
img.src = imageUrl;
document.body.appendChild(img)
@lumixraku
lumixraku / gist:64e07d4960b533261e88fa7f5bb28072
Created January 27, 2024 13:58
createImageBitmap & fetch
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<img hidden id="img" src="" />
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>上下分层提高 Canvas 书写性能</title>
<style>
body,
html {
#Requires AutoHotkey v2.0
LAlt::RCtrl
^e::Send "#1"
CapsLock & E::Send "{End}"
CapsLock & A::Send "{Home}"
CapsLock & c::Send "^z"
@lumixraku
lumixraku / GLSL-Noise.md
Created July 24, 2024 14:58 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);