Lucas Kent e39465ad2f Changes to be committed:
new file:   Files/flashplayer_32_sa.exe
	new file:   favicon.ico
	new file:   globe.gif
	new file:   imgs/download.png
	new file:   imgs/zuck.jpg
	new file:   index.html
	new file:   other.ico
	new file:   script.js
	new file:   site.webmanifest
	new file:   sitemap.html
	new file:   styles/backround.css
	new file:   styles/border.css
	new file:   styles/fonts/Titillium_Web/OFL.txt
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Black.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Bold.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-BoldItalic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-ExtraLightItalic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Italic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Light.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-LightItalic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Regular.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-SemiBoldItalic.ttf
	new file:   styles/fonts/webfontkit-20221027-163353/generator_config.txt
	new file:   styles/fonts/webfontkit-20221027-163353/specimen_files/grid_12-825-55-15.css
	new file:   styles/fonts/webfontkit-20221027-163353/specimen_files/specimen_stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-163353/stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-demo.html
	new file:   styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff
	new file:   styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff2
	new file:   styles/fonts/webfontkit-20221027-165950/generator_config.txt
	new file:   styles/fonts/webfontkit-20221027-165950/specimen_files/grid_12-825-55-15.css
	new file:   styles/fonts/webfontkit-20221027-165950/specimen_files/specimen_stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-165950/stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-demo.html
	new file:   styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff
	new file:   styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff2
	new file:   styles/style.css
	new file:   tools/2048/.gitignore
	new file:   tools/2048/.jshintrc
	new file:   tools/2048/CONTRIBUTING.md
	new file:   tools/2048/LICENSE.txt
	new file:   tools/2048/README.md
	new file:   tools/2048/Rakefile
	new file:   tools/2048/favicon.ico
	new file:   tools/2048/index.html
	new file:   tools/2048/js/animframe_polyfill.js
	new file:   tools/2048/js/application.js
	new file:   tools/2048/js/bind_polyfill.js
	new file:   tools/2048/js/classlist_polyfill.js
	new file:   tools/2048/js/game_manager.js
	new file:   tools/2048/js/grid.js
	new file:   tools/2048/js/html_actuator.js
	new file:   tools/2048/js/keyboard_input_manager.js
	new file:   tools/2048/js/local_storage_manager.js
	new file:   tools/2048/js/tile.js
    new file:   tools/2048/meta/apple-touch-icon.png
	new file:   tools/webretro/cores/neocd_libretro.js
	new file:   tools/webretro/cores/neocd_libretro.wasm
	new file:   tools/webretro/cores/nestopia_libretro.js
	new file:   tools/webretro/cores/nestopia_libretro.wasm
	new file:   tools/webretro/cores/o2em_libretro.js
	new file:   tools/webretro/cores/o2em_libretro.wasm
	new file:   tools/webretro/cores/opera_libretro.js
	new file:   tools/webretro/cores/opera_libretro.wasm
2022-11-02 08:40:01 -04:00

148 lines
3.0 KiB
JavaScript

var pgli = pgli || {};
pgli.diagram = pgli.diagram || {};
pgli.diagram.Diagram = gamecore.Base.extend('Diagram',
{ // static
},
{ // instance
dom: null,
container: null,
width: 1024,
height: 768,
timer: null,
redrawDelay: 1000/30,
stage: null,
layers: {
background: null,
nodes: null,
links: null
},
background: null,
links: null,
project: null,
nodes: [],
/**
* Bind a new renderer to given canvas
* @param HTMLElement domContainer [description]
* @param Integer width [description]
* @param Integer height [description]
* @param Integer autoRedraw If defined, sets redraw rate to given FPS
*/
init: function(domContainer, autoRedraw)
{
var self = this;
this.dom = domContainer;
this.container = $('#'+domContainer);
this.width = this.container.width();
this.height = this.container.height();
this.stage = new Kinetic.Stage({
container: this.dom,
width: this.width,
height: this.height
});
this.layers.background = new Kinetic.Layer();
this.layers.nodes = new Kinetic.Layer();
this.layers.links = new Kinetic.Layer();
this.background = new Kinetic.Rect({
width: this.width,
height: this.height,
fill: "#272822"
});
this.layers.background.add(this.background);
this.links = new pgli.diagram.Links(this);
this.layers.links.add(this.links.shape);
this.stage.add(this.layers.background);
this.stage.add(this.layers.nodes);
this.stage.add(this.layers.links);
// Stage drag hack to trigger only on background drag
var self = this;
this.background.on("mousedown", function(){
self.stage.setDraggable(true);
self.stage.on("dragmove", function(){
self.layers.background.setX(-this.getX());
self.layers.background.setY(-this.getY());
});
self.stage.on("dragend", function(){
this.off("dragend");
this.off("dragmove");
this.setDraggable(false);
});
});
if(autoRedraw != undefined && autoRedraw != false && autoRedraw > 0)
{
this.redrawDelay = 1000 / autoRedraw;
this.timer = new bkcore.Timer();
this.timer.start();
this.autoRedraw(true);
}
},
addNode: function(node)
{
this.nodes.push(node);
this.layers.nodes.add(node.shape);
this.layers.nodes.draw();
},
getNode: function(nodeKey)
{
var i = 0, len = this.nodes.length;
while(i < len)
{
if(this.nodes[i].key == nodeKey)
return this.nodes[i];
i++;
}
console.warn("Error in Diagram: Unable to find node["+nodeKey+"]");
return false;
},
draw: function()
{
this.layers.background.draw();
this.layers.nodes.draw();
this.layers.links.draw();
},
autoRedraw: function(keep)
{
var self = this;
if(this.timer.update() > this.redrawDelay)
{
this.timer.start();
this.draw();
}
if(keep)
requestAnimFrame(function(){
self.autoRedraw(true);
});
},
resize: function()
{
this.width = this.container.width();
this.height = this.container.height();
this.stage.setSize(this.width, this.height);
this.background.setSize(this.width, this.height);
this.draw();
}
});