Skip to content

Instantly share code, notes, and snippets.

@mio-U-M
mio-U-M / rgbshift.frag
Created February 22, 2020 16:57
RGBずらしのフィルタ
varying vec2 vTextureCoord;
uniform vec4 filterArea;
uniform sampler2D uSampler;
uniform float colorShiftR;
uniform float colorShiftG;
uniform float colorShiftB;
void main() {
vec2 rOffset = vec2(colorShiftR) / filterArea.xy;
@mio-U-M
mio-U-M / hexToRgb.js
Last active August 24, 2020 11:52
Color code exchange. Return rgb value as array.
function hexToRgb(color) {
// remove # if exist
const replacedColor = color.replace(/#/g, "");
return [
parseInt(replacedColor.substr(0, 2), 16),
parseInt(replacedColor.substr(2, 2), 16),
parseInt(replacedColor.substr(4, 2), 16)
];
}
// textures should be object
export function threeTextureLoad(textures) {
const texturePromises = [];
const loadedTextures = {};
const loader = new THREE.TextureLoader();
Object.keys(textures).forEach(key => {
texturePromises.push(
new Promise((resolve, reject) => {
const entry = textures[key];
@mio-U-M
mio-U-M / getDate.js
Last active May 13, 2020 10:27
日付を分割して返却する
function getDate(d) {
const date = new Date(d)
return (
date.getFullYear() +
'.' +
(date.getMonth() + 1) +
'.' +
date.getDate() +
' ' +
this.days[date.getDay()]
class CanvasUtil {
constructor(canvas){
this.canvas = canvas;
this.ctx = this.canvas.getContext('2d');
}
clear(){
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
}
@mixin form-style-reset {
margin: 0;
padding: 0;
background: none;
border: none;
border-radius: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
@mixin abs-center {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
@mixin flex-center {
display: flex;
justify-content: center;
align-items: center;
}
@mio-U-M
mio-U-M / position-ab-center2.scss
Last active March 26, 2020 07:11
position:absoluteで中央よせ
@mixin position-ab-center1 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
@mio-U-M
mio-U-M / Good CubicBizer
Last active March 4, 2020 11:42
Good CubicBizer
// pattern
$ease : cubic-bezier(0.25, 0.1, 0.25, 1);
$linear : cubic-bezier(0, 0, 1, 1);
$easeIn : cubic-bezier(0.42, 0, 1, 1);
$easeOut : cubic-bezier(0, 0, 0.58, 1);
$easeInOut : cubic-bezier(0.42, 0, 0.58, 1);
$easeInSine : cubic-bezier(0.47, 0, 0.745, 0.715);
$easeOutSine : cubic-bezier(0.39, 0.575, 0.565, 1);
$easeInOutSine : cubic-bezier(0.445, 0.05, 0.55, 0.95);