Last active
December 17, 2015 09:39
-
-
Save ikekou/5589109 to your computer and use it in GitHub Desktop.
[JavScript][CoffeeScript] dat.GUIマイテンプレ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Config | |
_instance = null | |
constructor:()-> | |
throw new Error 'Cant create instance, use \'getInstance\'.' | |
@getInstance: () -> | |
_instance ?= new _PrivateClass() | |
class _PrivateClass | |
str:'some string !' | |
num1:1 | |
num2:1 | |
num3:2 | |
num4:2 | |
bool:true | |
func:()-> | |
console.log 'some function !' | |
constructor: () -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<script type="text/javascript" src="http://dat-gui.googlecode.com/git/build/dat.gui.js"></script> | |
<script type="text/javascript" src="main.js"></script> | |
</head> | |
<body> | |
Hello dat.GUI ! | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload=()-> | |
c=Config.getInstance() | |
g=new dat.GUI() | |
g.remember(c) | |
g.add(c,'str') | |
controller=g.add(c,'num1',-10,10) | |
g.add(c,'num2').min(-10).max(10).step(1) | |
g.add(c,'num3',[1,2,3]) | |
g.add(c,'num4',{first:'1',second:'2',third:'3'}) | |
g.add(c,'bool') | |
g.add(c,'func') | |
controller.onChange((value)-> | |
console.log("#onChange : " + value) | |
) | |
controller.onFinishChange((value)-> | |
console.log("#onFinishChange : " + value) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment