Skip to content

Commit a3a3375

Browse files
committed
prettier everything
1 parent a4c9d67 commit a3a3375

29 files changed

+2725
-2164
lines changed

affine.ts

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,77 +8,87 @@ namespace microcode {
88
* Affine transformations can be chained thru the `parent` property, in which case `worldPos` will report the composed value.
99
*/
1010
export class Affine {
11-
private localPos_: Vec2;
12-
private parent_: Affine;
13-
private dirty_: boolean;
14-
private worldPos_: Vec2;
15-
public tag: string;
11+
private localPos_: Vec2
12+
private parent_: Affine
13+
private dirty_: boolean
14+
private worldPos_: Vec2
15+
public tag: string
1616

1717
//% blockCombine block="dirty" callInDebugger
1818
public get dirty(): boolean {
19-
return this.dirty_ || this.localPos_.dirty || (this.parent && this.parent.dirty);
19+
return (
20+
this.dirty_ ||
21+
this.localPos_.dirty ||
22+
(this.parent && this.parent.dirty)
23+
)
2024
}
2125

2226
//% blockCombine block="worldPos" callInDebugger
2327
public get worldPos() {
24-
if (this.dirty) { this.recalc(); }
25-
return this.worldPos_;
28+
if (this.dirty) {
29+
this.recalc()
30+
}
31+
return this.worldPos_
2632
}
2733

2834
//% blockCombine block="localPos" callInDebugger
29-
public get localPos(): Vec2 { return this.localPos_; }
35+
public get localPos(): Vec2 {
36+
return this.localPos_
37+
}
3038
public set localPos(v: Vec2) {
31-
this.localPos_.copyFrom(v);
32-
this.dirty_ = true;
39+
this.localPos_.copyFrom(v)
40+
this.dirty_ = true
3341
}
3442

3543
//% blockCombine block="parent" callInDebugger
36-
public get parent() { return this.parent_; }
44+
public get parent() {
45+
return this.parent_
46+
}
3747
public set parent(p: Affine) {
38-
this.parent_ = p;
39-
this.dirty_ = true;
48+
this.parent_ = p
49+
this.dirty_ = true
4050
}
4151

4252
//% blockCombine block="root" callInDebugger
43-
public get root() {
44-
let node = this.parent;
53+
public get root() {
54+
let node = this.parent
4555
while (node && node.parent) {
46-
node = node.parent;
56+
node = node.parent
4757
}
48-
return node;
58+
return node
4959
}
5060

5161
constructor() {
52-
this.localPos_ = new Vec2();
53-
this.worldPos_ = new Vec2();
54-
this.dirty_ = true;
62+
this.localPos_ = new Vec2()
63+
this.worldPos_ = new Vec2()
64+
this.dirty_ = true
5565
}
5666

5767
public copyFrom(src: Affine): this {
58-
this.localPos.copyFrom(src.localPos);
59-
return this;
68+
this.localPos.copyFrom(src.localPos)
69+
return this
6070
}
6171

6272
public clone(): Affine {
63-
const aff = new Affine();
64-
aff.copyFrom(this);
65-
return aff;
73+
const aff = new Affine()
74+
aff.copyFrom(this)
75+
return aff
6676
}
6777

6878
public recalc(force = false) {
6979
if (this.dirty || force) {
70-
this.dirty_ = false;
80+
this.dirty_ = false
7181
if (this.parent) {
72-
const ppos = this.parent.worldPos;
73-
Vec2.TranslateToRef(this.localPos_, ppos, this.worldPos_);
82+
const ppos = this.parent.worldPos
83+
Vec2.TranslateToRef(this.localPos_, ppos, this.worldPos_)
7484
} else {
75-
this.worldPos_.copyFrom(this.localPos);
85+
this.worldPos_.copyFrom(this.localPos)
7686
}
7787
}
7888
}
7989

8090
public transformToRef(v: Vec2, ref: Vec2): Vec2 {
81-
return Vec2.TranslateToRef(ref, this.worldPos, ref);
91+
return Vec2.TranslateToRef(ref, this.worldPos, ref)
8292
}
8393
}
84-
}
94+
}

agent.ts

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
namespace microcode {
2-
/**
3-
* An Agent is an object that can execute a program. In this demo, there is only one agent: the micro:bit.
4-
*/
5-
export class Agent {
6-
public prog: Program;
7-
8-
constructor(public home: Home, public progdef: ProgramDefn) {
9-
this.prog = new Program(this);
10-
}
11-
12-
public destroy() {
13-
this.prog.destroy();
14-
this.prog = undefined;
15-
}
16-
17-
public update() {
18-
this.prog.execute();
19-
}
20-
21-
public logBoolean(name: string, val: boolean, color: number) {
22-
this.home.logBoolean(name, val, color);
23-
}
24-
25-
public logNumber(name: string, val: number, color: number) {
26-
this.home.logNumber(name, val, color);
27-
}
28-
29-
public logString(name: string, val: string, color: number) {
30-
this.home.logString(name, val, color);
31-
}
32-
33-
public plotBoolean(name: string, val: boolean, color: number) {
34-
this.home.plotBoolean(name, val, color);
35-
}
36-
37-
public plotNumber(name: string, val: number, color: number) {
38-
this.home.plotNumber(name, val, color);
39-
}
40-
}
41-
}
1+
namespace microcode {
2+
/**
3+
* An Agent is an object that can execute a program. In this demo, there is only one agent: the micro:bit.
4+
*/
5+
export class Agent {
6+
public prog: Program
7+
8+
constructor(public home: Home, public progdef: ProgramDefn) {
9+
this.prog = new Program(this)
10+
}
11+
12+
public destroy() {
13+
this.prog.destroy()
14+
this.prog = undefined
15+
}
16+
17+
public update() {
18+
this.prog.execute()
19+
}
20+
21+
public logBoolean(name: string, val: boolean, color: number) {
22+
this.home.logBoolean(name, val, color)
23+
}
24+
25+
public logNumber(name: string, val: number, color: number) {
26+
this.home.logNumber(name, val, color)
27+
}
28+
29+
public logString(name: string, val: string, color: number) {
30+
this.home.logString(name, val, color)
31+
}
32+
33+
public plotBoolean(name: string, val: boolean, color: number) {
34+
this.home.plotBoolean(name, val, color)
35+
}
36+
37+
public plotNumber(name: string, val: number, color: number) {
38+
this.home.plotNumber(name, val, color)
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)