pacman button

This commit is contained in:
Nils Schneider 2012-06-12 01:02:49 +02:00
parent 3ba43d8536
commit 30526f51a9
4 changed files with 65 additions and 85 deletions

View file

@ -54,6 +54,12 @@ var style_btn = cp.append("button")
.text("Farbwechsler")
.on("click", next_style)
cp.append("button")
.attr("class", "btn")
.attr("value", "reload")
.text("Click me!")
.on("click", pacman)
var btns = cp.append("div")
.attr("class", "btn-group")

View file

@ -9,6 +9,7 @@
<link href='force-light.css' rel='stylesheet' type='text/css' title='light'/>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="d3.v2.js"></script>
<script type="text/javascript" src="pacman.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="https://raw.github.com/HPNeo/gmaps/master/gmaps.js"></script>
</head>

View file

@ -1,27 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Freifunk Lübeck - Knotengraph</title>
<link href='style.css' rel='stylesheet' type='text/css' />
<link href='force.css' rel='stylesheet' type='text/css' />
<link href='force-big.css' rel='alternate stylesheet' type='text/css' title='big' disabled/>
<link href='force-light.css' rel='stylesheet' type='text/css' title='light'/>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="d3.v2.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="https://raw.github.com/HPNeo/gmaps/master/gmaps.js"></script>
</head>
<body>
<header>
<h1>luebeck.freifunk.net</h1>
<ul>
<li><a href="nodes.html">Knotengraph</a></li>
<li><a href="geomap.html">Knotenkarte</a></li>
</ul>
</header>
<div id="chart"></div>
<script src='force.js' type='text/javascript'></script>
<script src='pacman.js' type='text/javascript'></script>
</body>
</html>

View file

@ -1,8 +1,9 @@
function pacman() {
var angle = d3.scale.linear()
.domain([0, 1, 2, 3])
.range([0.01, Math.PI/4, 0.01, Math.PI/4])
d3.timer(pacman)
d3.timer(pacman_animate)
var a = 0
var p = {x: 0, y: 0}
@ -12,7 +13,7 @@ var pm = vis.append("path")
.style("stroke-width", 2.5)
.style("stroke-linejoin", "round")
function pacman() {
function pacman_animate() {
var size = force.size()
var nodes = force.nodes()
var n = nodes.length
@ -44,10 +45,9 @@ function pacman() {
dx = dx/d
dy = dy/d
if (d>1) {
p.x += dx
p.y += dy
if (d>8) {
p.x += dx * 2
p.y += dy * 6
} else {
var snd;
if (closest.flags.client) {
@ -69,4 +69,4 @@ function pacman() {
pm.attr("transform", "matrix(" + [dx, dy, -dy, dx, p.x, p.y].join(",") + ")")
}
}