Skip to content

Instantly share code, notes, and snippets.

View monkianer's full-sized avatar
🐵
_

monkianer monkianer

🐵
_
  • .tw
View GitHub Profile
@monkianer
monkianer / Color.js
Created February 19, 2020 16:46 — forked from darkwing/Color.js
/*
Script: Color.js
Class for creating and manipulating colors in JavaScript. Includes basic color manipulations and HSB <-> RGB <-> HEX Conversions.
License:
MIT-style license.
*/
function Color(params){
var ptype = $type(params);
@monkianer
monkianer / In-app browser open chrome with link
Created June 12, 2019 13:44
在 in-app browser 開啟 Chrome
@monkianer
monkianer / line-open-external-browser
Created January 8, 2019 04:37
讓 line 不使用內建瀏覽器
https://www.yahoo.co.jp/
→ Open in LINE browser
https://www.yahoo.co.jp/?openExternalBrowser=1
→ Open in default browser
@monkianer
monkianer / unicodeToChinese.js
Created October 17, 2018 17:30
Convert Unicode to Chinese
var str= '\u6e2c\u8a66';
var msg = unescape(str.replace(/\\u/g, '%u'));
// -> 測試
@monkianer
monkianer / Cookie.js
Created August 21, 2018 08:01
Set Or Get Web Cookie
@monkianer
monkianer / _mixin.scss
Created March 17, 2018 09:44
Useful scss mixins
@mixin border-radius($radius){
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
@mixin border-radius-4-variables($radiusTL, $radiusTR, $radiusBR, $radiusBL){
-webkit-border-radius: $radiusTL $radiusTR $radiusBR $radiusBL;
-moz-border-radius: $radiusTL $radiusTR $radiusBR $radiusBL;
@monkianer
monkianer / Degree Radians Conversion
Created February 20, 2018 09:25
Degree Radians Conversion
// Converts from degrees to radians.
Math.radians = function(degrees) {
return degrees * Math.PI / 180;
};
// Converts from radians to degrees.
Math.degrees = function(radians) {
return radians * 180 / Math.PI;
};
@monkianer
monkianer / getCanvasMousePosition.js
Last active August 3, 2017 17:15
Get mouse position on the canvas
function getCanvasMousePosition(e, canvas) {
var isRetina = true;
var offsetX = 0, offsetY = 0, mx, my;
if (canvas.offsetParent !== undefined) {
do {
offsetX += canvas.offsetLeft - canvas.scrollLeft;
offsetY += canvas.offsetTop - canvas.scrollTop;
} while ((canvas = canvas.offsetParent));
}
@monkianer
monkianer / getScrollTop.js
Created July 31, 2017 14:53
Fix the 'ie' is not compatible with window.scrollY
/**
* Fix the 'ie' is not compatible with window.scrollY
* test with ie 9, 10, 11, edge.
**/
function getScrollTop(){
var t = typeof window.scrollY === 'undefined' ? window.pageYOffset : window.scrollY;
return t;
}
@monkianer
monkianer / randomColor.js
Created June 10, 2017 10:37
generate colors based on RGB or HSL
function randomRGBColor(){
var r = Math.floor(Math.random()*256);
var g = Math.floor(Math.random()*256);
var b = Math.floor(Math.random()*256);
return "rgb("+ r + "," + g + "," + b +")";
}
function randomHSLColor(){
var h = Math.floor(Math.random()*360);