Skip to content

Instantly share code, notes, and snippets.

@mio-U-M
mio-U-M / class chenged by computed
Last active June 5, 2018 04:39
computedで切り替えるクラス
// js
var app = new Vue({
el: '#app',
data: {
activeClass: ""
},
computed: {
classObject : function () {
return {
decorationRed: this.activeClass.includes("0"),
@mio-U-M
mio-U-M / class chenged by computed(HTML)
Last active June 5, 2018 04:40
computedで切り替えるクラス
<div id="app">
<p class="text-basic" v-bind:class="classObject">CLASS CHANGE SAMPLE</p>
<input type="text" v-model="activeClass"/>
<p class="explain">type below strings</p>
<ul class="typelist">
<li>"0":text color change into red.</li>
<li>"1":text color change into blue.</li>
<li>"2":text color change into green.</li>
<li>"-":add underline to text.</li>
<li>".":change background color into gray.</li>
float random (in vec2 _st) {
return fract(sin(dot(_st.xy, vec2(12.9898,78.233))) * 43758.5453123);
}
@mio-U-M
mio-U-M / Value Random
Last active February 22, 2020 16:47
最大値と最小値を設定してランダムに返してくれる
// min(含む)からmax(含む)までのランダムな数
// @min : 最小値
// @max : 最大値
function random(min, max) {
return Math.random() * (max - min) + min
}
@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);
@mio-U-M
mio-U-M / Value linear interpolation
Last active February 22, 2020 17:02
値の線形補間の公式
// 値の線形補間の公式
// @from : 始点
// @to : 終点
// @alpha : 位置
function lerp(from, to, alpha) {
return (from * (1 - alpha)) + (to * alpha);
}
@mio-U-M
mio-U-M / Value Map
Last active February 22, 2020 17:02
値の範囲変換の公式
// 値の範囲変換の公式
// @val : 変換したい値
// @toMin : 変換後の最小値
// @toMax : 変換後の最大値
// @fromMin : 変換前の最小値
// @fromMax : 変換前の最大値
function map(val, toMin, toMax, fromMin, fromMax) {
if(val <= fromMin) {
return toMin;
}
@mio-U-M
mio-U-M / manupulate vector
Created January 17, 2020 09:08
Vector class
class Vector {
static calcLength(x, y){
return Math.sqrt(x * x + y * y);
}
static calcDistance(x0, y0, x1, y1){
let x = x1 - x0;
let y = y1 - y0;
return Vector.calcLength(x, y);
}
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 flex-center {
display: flex;
justify-content: center;
align-items: center;
}