Added shapes

This commit is contained in:
Devine Lu Linvega 2017-01-04 10:48:08 -07:00
parent 867bd68389
commit 7e098564ce
4 changed files with 72 additions and 2 deletions

View File

@ -146,6 +146,29 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
reset();
}
this.draw_dot = function()
{
var s = document.createElementNS("http://www.w3.org/2000/svg", "circle");
s.setAttribute("cx",-from[0]);
s.setAttribute("cy",from[1]);
s.setAttribute("r","2");
s.setAttribute("fill","black");
vector_element.appendChild(s);
reset();
}
this.draw_circle = function()
{
var s = document.createElementNS("http://www.w3.org/2000/svg", "circle");
s.setAttribute("cx",-from[0]);
s.setAttribute("cy",from[1]);
s.setAttribute("r",(from[0] - to[0]));
vector_element.appendChild(s);
reset();
}
this.reset = function()
{
reset();

View File

@ -11,6 +11,9 @@ function Keyboard()
case 81 : dotgrid.reset(); break;
case 87 : dotgrid.erase(); break;
case 80 : dotgrid.export(); break;
case 90 : dotgrid.draw_dot(); break;
case 88 : dotgrid.draw_circle(); break;
}
}
}

View File

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="links/reset.css"/>
<link rel="stylesheet" type="text/css" href="links/fonts.css"/>
<link rel="stylesheet" type="text/css" href="links/main.css"/>
<title>Dotgrid</title>
<title>Dotgrid(Interface)</title>
</head>
<body>
<pre>
@ -18,6 +18,14 @@
sS <b>COUNTERWISE</b>
d <b>LINE</b>
</pre>
<script type="text/javascript" src="scripts/init.js"></script>
<script>
dotgrid = new Dotgrid(300,300,31,31,5,5, 10,"square","#000000");
dotgrid.install();
var keyboard = new Keyboard();
document.onkeyup = function myFunction(){ keyboard.listen(event); };
document.addEventListener('mousedown', function(e){ dotgrid.mouse_down(e); }, false);
document.addEventListener('mousemove', function(e){ dotgrid.mouse_move(e); }, false);
document.addEventListener('mouseup', function(e){ dotgrid.mouse_up(e);}, false);
</script>
</body>
</html>

36
template.interface.html Normal file
View File

@ -0,0 +1,36 @@
<html>
<head>
<script type="text/javascript" src="scripts/dotgrid.js"></script>
<script type="text/javascript" src="scripts/keyboard.js"></script>
<link rel="stylesheet" type="text/css" href="links/reset.css"/>
<link rel="stylesheet" type="text/css" href="links/fonts.css"/>
<link rel="stylesheet" type="text/css" href="links/main.css"/>
<title>Dotgrid(Interface)</title>
</head>
<body>
<pre>
q <b>CLEAR</b>
w <b>DELETE LAST</b>
e <b>EXPORT</b>
aA <b>CLOCKWISE</b>
sS <b>COUNTERWISE</b>
d <b>LINE</b>
z <b>DOT</b>
x <b>CIRCLE</b>
c <b>--</b>
</pre>
<script>
dotgrid = new Dotgrid(320,568,31,61,6,6, 1,"square","#000000");
dotgrid.install();
var keyboard = new Keyboard();
document.onkeyup = function myFunction(){ keyboard.listen(event); };
document.addEventListener('mousedown', function(e){ dotgrid.mouse_down(e); }, false);
document.addEventListener('mousemove', function(e){ dotgrid.mouse_move(e); }, false);
document.addEventListener('mouseup', function(e){ dotgrid.mouse_up(e);}, false);
</script>
</body>
</html>