- dat-gui is a lightweight controller library for JavaScript.
- website:http://workshop.chromeexperiments.com/e ... asic-Usage
- source:https://github.com/dataarts/dat.gui
Code: Select all
; ******************************
; utility functions
; ******************************
Procedure UsePlugin(Plugin.s, Path.s, *FunctionUsingPlugin, EnforceDefine=#False)
!cfg={ enforceDefine: v_enforcedefine, paths: {} };
!cfg.paths[v_plugin]=v_path;
!requirejs.config(cfg);
!require([v_plugin], function(plug) {
! p_functionusingplugin(plug);
!});
EndProcedure
; *************************
; Create custom GUI bound to data
; *************************
Import ""
CreateGUIPanel() As "var datGuiItem, datGuiPanel, datGuiParent=datGuiPanel=new dat.GUI"
OpenGUIFolder(FolderName.s) As "datGuiParent=datGuiPanel.addFolder"
CloseGUIFolder() As "datGuiParent=datGuiPanel;//"
GUIItem(Object, Property.s) As "datGuiItem=datGuiParent.add"
GUIColorItem(Object, Property.s) As "datGuiItem=datGuiParent.addColor"
SetGUIItemMin(Min.f) As "datGuiItem=datGuiItem.min"
SetGUIItemMax(Max.f) As "datGuiItem=datGuiItem.max"
SetGUIItemStep(Value.f) As "datGuiItem=datGuiItem.step"
SetGUIItemName(Name.s) As "datGuiItem.name"
EndImport
Structure ROBOT
Name.s
Speed.f
PosX.i
PosY.i
Color.i
IsActive.b
EndStructure
Procedure CreateYourGui()
Protected MyRobot.ROBOT
MyRobot\Name="T800"
MyRobot\PosX=33
MyRobot\Speed=0.5
MyRobot\Color=$FF0000
MyRobot\IsActive=1
!v_myrobot._isactive=!!v_myrobot._isactive;
Debug MyRobot\IsActive
CreateGUIPanel();
GUIItem(MyRobot, "_name")
OpenGUIFolder("position of robot")
GUIItem(MyRobot, "_posx"): SetGUIItemStep(5)
GUIItem(MyRobot, "_posy"): SetGUIItemStep(5)
CloseGUIFolder()
GUIItem(MyRobot, "_speed"): SetGUIItemMin(0.0): SetGUIItemMax(10.0): SetGUIItemName("speed of robot")
GUIColorItem(MyRobot, "_color")
GUIItem(MyRobot, "_isactive")
EndProcedure
;original URL (converted by rawgit): https://raw.githubusercontent.com/jaxry/dat.gui/master/build/dat.gui.js
UsePlugin("dat.gui","//rawgit.com/jaxry/dat.gui/master/build/dat.gui",@CreateYourGui())