-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHw1Controller.js
More file actions
62 lines (62 loc) · 1.98 KB
/
Hw1Controller.js
File metadata and controls
62 lines (62 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright © Sam Savage 2016
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
//declare var d3: any;
var y_scale, x_scale;
//init_svg = function () {
// var svg = d3.select("#graph");
// svg.attr("width", 1000).attr("height", 1000);
// x_scale = d3.scale.linear()
// .domain([-10, 10])
// .range([0, 1000]);
// y_scale = d3.scale.linear()
// .domain([-10, 10])
// .range([1000, 0]);
//}
//plot = function (x, y) {
// var svg = d3.select("#graph");
// svg.append("circle")
// .attr("cx", x_scale(x))
// .attr("cy", y_scale(y))
// .attr("r", 2)
// .style("fill", "purple");
// //alert("plot " + String(x) + " " + String(y));
//}
var Hw1Controller = (function (_super) {
__extends(Hw1Controller, _super);
function Hw1Controller(elementId) {
_super.call(this, elementId);
this.x = this.y = 0;
this.a = 1.4;
this.b = 0.3;
var svg = d3.select("main").append("svg");
svg.attr("width", 1000).attr("height", 1000);
this.svg = svg;
x_scale = d3.scale.linear()
.domain([-10, 10])
.range([0, 1000]);
y_scale = d3.scale.linear()
.domain([-10, 10])
.range([1000, 0]);
}
Hw1Controller.prototype.dostuff = function () {
this.plot(this.x, this.y);
var x = 1 - this.a * (this.x * this.x) + this.y;
var y = this.b * this.x;
this.x = x;
this.y = y;
return;
};
Hw1Controller.prototype.plot = function (x, y) {
this.svg.append("circle")
.attr("cx", x_scale(x))
.attr("cy", y_scale(y))
.attr("r", 2)
.style("fill", "purple");
};
return Hw1Controller;
})(BaseTimer);
//# sourceMappingURL=Hw1Controller.js.map