mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-25 12:25:52 -08:00
Compare commits
5 Commits
21/10/2022
...
v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64fcc777de | ||
|
|
0f74b5e94f | ||
|
|
5799482dde | ||
|
|
416c20cecc | ||
|
|
09ef8418bb |
@@ -1,3 +1,6 @@
|
||||
2020-08
|
||||
- polyline improvements (by @imbasimba)
|
||||
|
||||
2020-07
|
||||
- new method stopAnimation
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ Polyline= (function() {
|
||||
// constructor
|
||||
Polyline = function(radecArray, options) {
|
||||
options = options || {};
|
||||
this.color = options['color'] || undefined;
|
||||
this.color = options['color'] || "white";
|
||||
this.lineWidth = options["lineWidth"] || 2;
|
||||
|
||||
this.radecArray = radecArray;
|
||||
this.overlay = null;
|
||||
@@ -89,6 +90,22 @@ Polyline= (function() {
|
||||
this.overlay.reportChange();
|
||||
}
|
||||
};
|
||||
|
||||
Polyline.prototype.setLineWidth = function(lineWidth) {
|
||||
if (this.lineWidth == lineWidth) {
|
||||
return;
|
||||
}
|
||||
this.lineWidth = lineWidth;
|
||||
this.overlay.reportChange();
|
||||
};
|
||||
|
||||
Polyline.prototype.setColor = function(color) {
|
||||
if (this.color == color) {
|
||||
return;
|
||||
}
|
||||
this.color = color;
|
||||
this.overlay.reportChange();
|
||||
};
|
||||
|
||||
Polyline.prototype.draw = function(ctx, projection, frame, width, height, largestDim, zoomFactor) {
|
||||
if (! this.isShowing) {
|
||||
@@ -103,22 +120,44 @@ Polyline= (function() {
|
||||
ctx.strokeStyle= this.color;
|
||||
}
|
||||
var start = AladinUtils.radecToViewXy(this.radecArray[0][0], this.radecArray[0][1], projection, frame, width, height, largestDim, zoomFactor);
|
||||
if (! start) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(start.vx, start.vy);
|
||||
var pt;
|
||||
for (var k=1; k<this.radecArray.length; k++) {
|
||||
pt = AladinUtils.radecToViewXy(this.radecArray[k][0], this.radecArray[k][1], projection, frame, width, height, largestDim, zoomFactor);
|
||||
if (!pt) {
|
||||
|
||||
for (var k = 0; k < this.radecArray.length; k++) {
|
||||
start = AladinUtils.radecToViewXy(this.radecArray[k][0], this.radecArray[k][1], projection, frame, width, height, largestDim, zoomFactor);
|
||||
if (start) {
|
||||
break;
|
||||
}
|
||||
ctx.lineTo(pt.vx, pt.vy);
|
||||
}
|
||||
|
||||
|
||||
if (!start) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.moveTo(start.vx, start.vy);
|
||||
var pt;
|
||||
var newSeg = false;
|
||||
var drawingNewSeg = true;
|
||||
for (var k = 1; k < this.radecArray.length; k++) {
|
||||
pt = AladinUtils.radecToViewXy(this.radecArray[k][0], this.radecArray[k][1], projection, frame, width, height, largestDim, zoomFactor);
|
||||
if (!pt) {
|
||||
if (drawingNewSeg) {
|
||||
//console.log("closing segment");
|
||||
ctx.stroke();
|
||||
}
|
||||
drawingNewSeg = false;
|
||||
newSeg = true;
|
||||
} else {
|
||||
if (newSeg) {
|
||||
//console.log ("starting newSeg at "+pt.vx+" "+pt.vy);
|
||||
drawingNewSeg = true;
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = this.lineWidth;
|
||||
ctx.moveTo(pt.vx, pt.vy);
|
||||
newSeg = false;
|
||||
} else {
|
||||
ctx.lineTo(pt.vx, pt.vy);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ctx.stroke();
|
||||
};
|
||||
|
||||
|
||||
@@ -71,11 +71,7 @@ function relMouseCoords(event) {
|
||||
|
||||
var clientX = e.clientX;
|
||||
var clientY = e.clientY;
|
||||
if (e.clientX) {
|
||||
clientX = e.clientX;
|
||||
clientY = e.clientY;
|
||||
}
|
||||
else {
|
||||
if (e.clientX == undefined) {
|
||||
clientX = e.originalEvent.changedTouches[0].clientX;
|
||||
clientY = e.originalEvent.changedTouches[0].clientY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user