Skip to content

Commit 2c8a53b

Browse files
committed
Fixes to the order preserver. Still buggy...
1 parent 2a7d2b1 commit 2c8a53b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ You can find specific info about the alphabet here: http://www.shermansplanet.co
1616

1717
TODO:
1818

19+
fixes:
20+
- the part that limits angles in order to preserve letter/word order bugs out in rare cases
21+
- the same with the word circle drawing, it's even more important as it makes it impossible to make overlapping letters
22+
1923
features:
2024
- doubled vowels/consonants
2125
- manual addition/deletion of lines

gallifreyan.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ function Circle(owner,type,subtype, d, r, a){
112112
angles.push(child.a+an, child.a-an);
113113
}
114114
}
115+
if(angles.length==0) angles=[0, 2*PI];
115116
for(var i=angles.length;i>0;i-=2){ //we're going in the oppposite direction as that's how arc() draws
116117
ctx.beginPath(); ctx.arc(this.x,this.y,this.r,angles[i%angles.length],angles[i-1]);ctx.stroke();
117118
}
@@ -140,7 +141,8 @@ function Circle(owner,type,subtype, d, r, a){
140141
var dx, dy;
141142
var oldA=this.a;
142143
dx=Math.cos(a)*(d), dy=Math.sin(a)*(d);
143-
this.x=this.owner.x+dx;this.y=this.owner.y+dy;this.a=a;this.d=d;
144+
this.x=this.owner.x+dx;this.y=this.owner.y+dy;this.d=d;
145+
if(a<-PI) this.a=a+2*PI; else if(a>PI) this.a=a-2*PI; else this.a=a;
144146
for(var i=0;i<this.children.length;i++){
145147
if(mainCircles.contains(this))
146148
this.children[i].update(this.children[i].d, this.children[i].a);
@@ -248,14 +250,16 @@ $('canvas').mousemove(function(e){
248250
if(selectedCircle != -1){
249251
var selected=selectedCircle;
250252
var a=Math.atan2(mouse.y-selected.owner.y,mouse.x-selected.owner.x);
253+
if(a<0) a+=2*PI;
251254
var d=dist(mouse.x, mouse.y, selected.owner.x, selected.owner.y);
252-
if(selected.type!=6 && currentCircle.children.length>2){ //need extra logic to enforce location of first word/letter
255+
if(selected.type!=6 && currentCircle.children.length>2){ //todo: extra logic to enforce location of first word/letter
253256
var index=currentCircle.children.indexOf(selectedCircle);
254257
var splus=(index+1 >= currentCircle.children.length ? 0 : index+1),
255258
sminus=(index-1 < 0 ? currentCircle.children.length-1 : index-1); //preserves order
256259
var aplus=currentCircle.children[splus].a,
257260
aminus=currentCircle.children[sminus].a;
258261
if(aplus>aminus) {a>0?aminus+=2*PI:aplus-=2*PI;} //still buggy
262+
if(a-aplus>2*PI || a-aminus>2*PI) a-=2*PI; if(a-aplus<-2*PI || a-aminus<-2*PI) a+=2*PI;
259263
if(a<aplus) a=aplus;else if(a>aminus) a=aminus;
260264
}
261265
updateLocation(selected, d, a);

0 commit comments

Comments
 (0)