Skip to content
Browse files

Merge pull request #565 from AnalyticalGraphicsInc/labelOutlineWidth

Label clarity improvements
  • Loading branch information...
2 parents 5ac6bde + c93b81f commit 8a02251379f6d14b88f765418abcf35a398ff977 @pjcozzi pjcozzi committed Mar 13, 2013
View
94 Apps/CesiumViewer/Gallery/simple.czml
@@ -9,7 +9,7 @@
]
},
"horizontalOrigin":"CENTER",
- "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAC/SURBVDhPrZPRDYQgEEQpjVKuFEvhw0IoxU6QgQwMK+vdx5FsooT3GHdjCM4qZnnnHvvkYoxFi/uvIhwiRCClXFC6v5UQ1uQAsbrkHCLsbaPjFgIzQQc1yUOwu33ePGE3BQUaee2BpjhbP5YUmkAlbNzsAURfBDqJnMIyyv4JjsCCgCnIR32uZUfcJuGBOwEk6bOKhoAADh31EIq3MgFg1mgkE1BA2AoUZoo2iZ3gyqGgmMDC/xWwkfb3/eUd7A1v3kxjNW9taQAAAABJRU5ErkJggg==",
+ "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACvSURBVDhPrZDRDcMgDAU9GqN0lIzijw6SUbJJygUeNQgSqepJTyHG91LVVpwDdfxM3T9TSl1EXZvDwii471fivK73cBFFQNTT/d2KoGpfGOpSIkhUpgUMxq9DFEsWv4IXhlyCnhBFnZcFEEuYqbiUlNwWgMTdrZ3JbQFoEVG53rd8ztG9aPJMnBUQf/VFraBJeWnLS0RfjbKyLJA8FkT5seDYS1Qwyv8t0B/5C2ZmH2/eTGNNBgMmAAAAAElFTkSuQmCC",
"pixelOffset":{
"cartesian2":[
0.0,0.0
@@ -30,26 +30,27 @@
0,255,255,255
]
},
- "font":"10pt Lucida Console",
+ "font":"21pt Lucida Console",
"horizontalOrigin":"LEFT",
"outlineColor":{
"rgba":[
0,0,0,255
]
},
+ "outlineWidth":2.0,
"pixelOffset":{
"cartesian2":[
12.0,0.0
]
},
- "scale":1.0,
+ "scale":0.5,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
"boolean":true
}
],
- "style":"FILL",
+ "style":"FILL_AND_OUTLINE",
"text":"AGI",
"verticalOrigin":"CENTER"
},
@@ -69,7 +70,7 @@
]
},
"horizontalOrigin":"CENTER",
- "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADGSURBVDhPnVPbDcMgDGQ0RmGUjsIojNIR+p8Piq+5xvGDSo2EEgH3yNku5Y9nrucnLLt07ssrJsHJ59Bdko1aB1Z0DkRrDxy2Wm6XNLj1MWU5F1R+jjJ7cyRQJli+bwRf28drCgFJxI2yCwIHZqKWRICRk20VSALV5WZ0T8KgQyJdBVHXJAh3hcygwxBNifALQsIctLoLkTW2JASLcmpbg1kqC8waDA1EAt0ktKuVVUbXOJA56rBU1U7Trv9D1Wgctw2SzO8bB7GiztrZSh0AAAAASUVORK5CYII=",
+ "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADJSURBVDhPnZHRDcMgEEMZjVEYpaNklIzSEfLfD4qNnXAJSFWfhO7w2Zc0Tf9QG2rXrEzSUeZLOGm47WoH95x3Hl3jEgilvDgsOQUTqsNl68ezEwn1vae6lceSEEYvvWNT/Rxc4CXQNGadho1NXoJ+9iaqc2xi2xbt23PJCDIB6TQjOC6Bho/sDy3fBQT8PrVhibU7yBFcEPaRxOoeTwbwByCOYf9VGp1BYI1BA+EeHhmfzKbBoJEQwn1yzUZtyspIQUha85MpkNIXB7GizqDEECsAAAAASUVORK5CYII=",
"pixelOffset":{
"cartesian2":[
0.0,0.0
@@ -93,26 +94,27 @@
]
}
],
- "font":"10pt Lucida Console",
+ "font":"21pt Lucida Console",
"horizontalOrigin":"LEFT",
"outlineColor":{
"rgba":[
0,0,0,255
]
},
+ "outlineWidth":2.0,
"pixelOffset":{
"cartesian2":[
12.0,0.0
]
},
- "scale":1.0,
+ "scale":0.5,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
"boolean":true
}
],
- "style":"FILL",
+ "style":"FILL_AND_OUTLINE",
"text":"Geoeye 1",
"verticalOrigin":"CENTER"
},
@@ -125,13 +127,7 @@
]
}
],
- "outlineWidth":0.0,
- "width":[
- {
- "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
- "number":1.0
- }
- ],
+ "resolution":60.0,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
@@ -777,7 +773,7 @@
]
},
"horizontalOrigin":"CENTER",
- "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADCSURBVDhPnVPbDQMhDMtojMIoHYVRGKUj9L8f6RnVp0AelXoS0imJnWAHkT8+vb6fsKyI8ZQEiawI8dbmOpjAkSDQ+2Mle5OtyIL7mIoTEgD8nKKji54k6Eww/jeCe+z3S0FAEorFPAgc+CzSLwni0SSlCzYJojn8dSh0SGRdQHdLssS9RKbQoYinRSShbba7E5EeRz7T4nRsC6ZV7IqRqwVbG0UCuyQEkcBeY3sL1uNzw7K1do+p2n87fvkKywVJkB99VYHvubc6fQAAAABJRU5ErkJggg==",
+ "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADESURBVDhPnZHRDcMgDEQZLaMwSkfJKIzSEfLfD8pdecihIFV9EsK+8zlNmv6hNnq5ZzeEvvNtCGqLHfXHUXzobYCEnB8W85FuQ7oJ5/Nz8AYIz5LqmVOdl8SwanRDU19X1QKW2GzgL8OAyBLVq1/CvSSaWlTO79eJeDDSdRsKxiXS9JH50MwNJOj9qHWzBG1GulGjMAfNZkO1nhy1gcQY5q/CIyjQdA8kzOFIfLKLhoOAEMM2GtRRW7IbVA9d2vPT0I2U3n1Vge+EDDWxAAAAAElFTkSuQmCC",
"pixelOffset":{
"cartesian2":[
0.0,0.0
@@ -801,26 +797,27 @@
]
}
],
- "font":"10pt Lucida Console",
+ "font":"21pt Lucida Console",
"horizontalOrigin":"LEFT",
"outlineColor":{
"rgba":[
0,0,0,255
]
},
+ "outlineWidth":2.0,
"pixelOffset":{
"cartesian2":[
12.0,0.0
]
},
- "scale":1.0,
+ "scale":0.5,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
"boolean":true
}
],
- "style":"FILL",
+ "style":"FILL_AND_OUTLINE",
"text":"ISS",
"verticalOrigin":"CENTER"
},
@@ -833,13 +830,7 @@
]
}
],
- "outlineWidth":0.0,
- "width":[
- {
- "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
- "number":1.0
- }
- ],
+ "resolution":60.0,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
@@ -1511,7 +1502,7 @@
]
},
"horizontalOrigin":"CENTER",
- "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADCSURBVDhPnVPbDQMhDMtojMIoHYVRGKUj9L8f6RnVp0AelXoS0imJnWAHkT8+vb6fsKyI8ZQEiawI8dbmOpjAkSDQ+2Mle5OtyIL7mIoTEgD8nKKji54k6Eww/jeCe+z3S0FAEorFPAgc+CzSLwni0SSlCzYJojn8dSh0SGRdQHdLssS9RKbQoYinRSShbba7E5EeRz7T4nRsC6ZV7IqRqwVbG0UCuyQEkcBeY3sL1uNzw7K1do+p2n87fvkKywVJkB99VYHvubc6fQAAAABJRU5ErkJggg==",
+ "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADESURBVDhPnZHRDcMgDEQZLaMwSkfJKIzSEfLfD8pdecihIFV9EsK+8zlNmv6hNnq5ZzeEvvNtCGqLHfXHUXzobYCEnB8W85FuQ7oJ5/Nz8AYIz5LqmVOdl8SwanRDU19X1QKW2GzgL8OAyBLVq1/CvSSaWlTO79eJeDDSdRsKxiXS9JH50MwNJOj9qHWzBG1GulGjMAfNZkO1nhy1gcQY5q/CIyjQdA8kzOFIfLKLhoOAEMM2GtRRW7IbVA9d2vPT0I2U3n1Vge+EDDWxAAAAAElFTkSuQmCC",
"pixelOffset":{
"cartesian2":[
0.0,0.0
@@ -1535,26 +1526,27 @@
]
}
],
- "font":"10pt Lucida Console",
+ "font":"21pt Lucida Console",
"horizontalOrigin":"LEFT",
"outlineColor":{
"rgba":[
0,0,0,255
]
},
+ "outlineWidth":2.0,
"pixelOffset":{
"cartesian2":[
23.0,0.0
]
},
- "scale":1.0,
+ "scale":0.5,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
"boolean":true
}
],
- "style":"FILL",
+ "style":"FILL_AND_OUTLINE",
"text":"Landsat 7",
"verticalOrigin":"CENTER"
},
@@ -1567,13 +1559,7 @@
]
}
],
- "outlineWidth":0.0,
- "width":[
- {
- "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
- "number":1.0
- }
- ],
+ "resolution":60.0,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
@@ -2199,7 +2185,7 @@
]
},
"horizontalOrigin":"CENTER",
- "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADCSURBVDhPnVPbDQMhDMtojMIoHYVRGKUj9L8f6RnVp0AelXoS0imJnWAHkT8+vb6fsKyI8ZQEiawI8dbmOpjAkSDQ+2Mle5OtyIL7mIoTEgD8nKKji54k6Eww/jeCe+z3S0FAEorFPAgc+CzSLwni0SSlCzYJojn8dSh0SGRdQHdLssS9RKbQoYinRSShbba7E5EeRz7T4nRsC6ZV7IqRqwVbG0UCuyQEkcBeY3sL1uNzw7K1do+p2n87fvkKywVJkB99VYHvubc6fQAAAABJRU5ErkJggg==",
+ "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADESURBVDhPnZHRDcMgDEQZLaMwSkfJKIzSEfLfD8pdecihIFV9EsK+8zlNmv6hNnq5ZzeEvvNtCGqLHfXHUXzobYCEnB8W85FuQ7oJ5/Nz8AYIz5LqmVOdl8SwanRDU19X1QKW2GzgL8OAyBLVq1/CvSSaWlTO79eJeDDSdRsKxiXS9JH50MwNJOj9qHWzBG1GulGjMAfNZkO1nhy1gcQY5q/CIyjQdA8kzOFIfLKLhoOAEMM2GtRRW7IbVA9d2vPT0I2U3n1Vge+EDDWxAAAAAElFTkSuQmCC",
"pixelOffset":{
"cartesian2":[
0.0,0.0
@@ -2223,26 +2209,27 @@
]
}
],
- "font":"10pt Lucida Console",
+ "font":"21pt Lucida Console",
"horizontalOrigin":"LEFT",
"outlineColor":{
"rgba":[
0,0,0,255
]
},
+ "outlineWidth":2.0,
"pixelOffset":{
"cartesian2":[
6.0,-4.0
]
},
- "scale":1.0,
+ "scale":0.5,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
"boolean":true
}
],
- "style":"FILL",
+ "style":"FILL_AND_OUTLINE",
"text":"Molniya 1-92",
"verticalOrigin":"CENTER"
},
@@ -2255,13 +2242,7 @@
]
}
],
- "outlineWidth":0.0,
- "width":[
- {
- "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
- "number":1.0
- }
- ],
+ "resolution":60.0,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
@@ -2643,21 +2624,22 @@
255,0,0,255
]
},
- "font":"10pt Lucida Console",
+ "font":"21pt Lucida Console",
"horizontalOrigin":"LEFT",
"outlineColor":{
"rgba":[
0,0,0,255
]
},
- "scale":1.0,
+ "outlineWidth":2.0,
+ "scale":0.5,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
"boolean":true
}
],
- "style":"FILL",
+ "style":"FILL_AND_OUTLINE",
"text":"Pennsylvania",
"verticalOrigin":"CENTER"
},
@@ -2682,8 +2664,6 @@
255,0,0,255
]
},
- "outlineWidth":0.0,
- "width":1.0,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z",
@@ -2710,7 +2690,7 @@
},
"position":{
"cartesian":[
- 1152255.8015002306,-4694317.95133893,4147335.9067616328
+ 1152255.80150063,-4694317.951340558,4147335.9067563135
]
}
},
@@ -2722,8 +2702,6 @@
0,255,255,255
]
},
- "outlineWidth":0.0,
- "width":1.0,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-15T10:52:19.3940000000002Z",
@@ -2801,8 +2779,6 @@
]
}
],
- "outlineWidth":0.0,
- "width":1.0,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-15T10:16:06.97400000000198Z",
@@ -2908,8 +2884,6 @@
]
}
],
- "outlineWidth":0.0,
- "width":1.0,
"show":[
{
"interval":"2012-03-15T10:00:00Z/2012-03-15T22:32:58.8280000000086Z",
View
3 Apps/Sandcastle/gallery/Labels.html
@@ -53,9 +53,10 @@
position : ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-75.10, 39.57)),
text : 'Philadelphia',
// CSS font-family
- font : '36px Helvetica',
+ font : '24px Helvetica',
fillColor : { red : 0.0, blue : 1.0, green : 1.0, alpha : 1.0 },
outlineColor : { red : 0.0, blue : 0.0, green : 0.0, alpha : 1.0 },
+ outlineWidth : 2,
style : Cesium.LabelStyle.FILL_AND_OUTLINE
});
scene.getPrimitives().add(labels);
View
2 CHANGES.md
@@ -7,7 +7,7 @@ Beta Releases
### b15 - 2013-04-01
* Breaking changes:
- *
+ * Removed `clampToPixel` property from `BillboardCollection` and `LabelCollection`. This options is no longer be needed due to overall LabelCollection visualization improvements.
* Added `BoundingSphere.fromCornerPoints`.
* Added `fromArray` and `distance` functions to `Cartesian2`, `Cartesian3`, and `Cartesian4`.
* Added `DynamicPath.resolution` property for setting the maximum step size, in seconds, to take when sampling a position for path visualization.
View
22 Source/Core/writeTextToCanvas.js
@@ -24,6 +24,7 @@ define([
* @param {Boolean} [description.stroke=false] Whether to stroke the text.
* @param {Color} [description.fillColor=Color.WHITE] The fill color.
* @param {Color} [description.strokeColor=Color.BLACK] The stroke color.
+ * @param {Color} [description.strokeWidth=1] The stroke width.
*
* @returns {Canvas} A new canvas with the given text drawn into it. The dimensions object
* from measureText will also be added to the returned canvas. If text is
@@ -57,7 +58,12 @@ define([
canvas.style.visibility = 'hidden';
document.body.appendChild(canvas);
- var dimensions = measureText(context2D, text);
+ var stroke = defaultValue(description.stroke, false);
+ var fill = defaultValue(description.fill, true);
+ var strokeWidth = defaultValue(description.strokeWidth, 1) * 2;
+
+ context2D.lineWidth = strokeWidth;
+ var dimensions = measureText(context2D, text, stroke, fill);
canvas.dimensions = dimensions;
document.body.removeChild(canvas);
@@ -71,19 +77,19 @@ define([
// font must be explicitly set again after changing width and height
context2D.font = font;
- var fill = defaultValue(description.fill, true);
+ if (stroke) {
+ var strokeColor = defaultValue(description.strokeColor, Color.BLACK);
+ context2D.strokeStyle = strokeColor.toCssColorString();
+ context2D.lineWidth = strokeWidth;
+ context2D.strokeText(text, 0, y);
+ }
+
if (fill) {
var fillColor = defaultValue(description.fillColor, Color.WHITE);
context2D.fillStyle = fillColor.toCssColorString();
context2D.fillText(text, 0, y);
}
- var stroke = defaultValue(description.stroke, false);
- if (stroke) {
- var strokeColor = defaultValue(description.strokeColor, Color.BLACK);
- context2D.strokeStyle = strokeColor.toCssColorString();
- context2D.strokeText(text, 0, y);
- }
return canvas;
};
View
15 Source/DynamicScene/DynamicLabel.js
@@ -70,6 +70,11 @@ define([
*/
this.outlineColor = undefined;
/**
+ * A DynamicProperty of type CzmlNumber which determines the label's outline width.
+ * @type DynamicProperty
+ */
+ this.outlineWidth = undefined;
+ /**
* A DynamicProperty of type CzmlHorizontalOrigin which determines the label's horizontal origin.
* @type DynamicProperty
*/
@@ -152,6 +157,15 @@ define([
outlineColor.processCzmlIntervals(labelData.outlineColor, interval);
}
+ if (typeof labelData.outlineWidth !== 'undefined') {
+ var outlineWidth = label.outlineWidth;
+ if (typeof outlineWidth === 'undefined') {
+ label.outlineWidth = outlineWidth = new DynamicProperty(CzmlNumber);
+ labelUpdated = true;
+ }
+ outlineWidth.processCzmlIntervals(labelData.outlineWidth, interval);
+ }
+
if (typeof labelData.eyeOffset !== 'undefined') {
var eyeOffset = label.eyeOffset;
if (typeof eyeOffset === 'undefined') {
@@ -261,6 +275,7 @@ define([
targetLabel.style = defaultValue(targetLabel.style, labelToMerge.style);
targetLabel.fillColor = defaultValue(targetLabel.fillColor, labelToMerge.fillColor);
targetLabel.outlineColor = defaultValue(targetLabel.outlineColor, labelToMerge.outlineColor);
+ targetLabel.outlineWidth = defaultValue(targetLabel.outlineWidth, labelToMerge.outlineWidth);
targetLabel.scale = defaultValue(targetLabel.scale, labelToMerge.scale);
targetLabel.horizontalOrigin = defaultValue(targetLabel.horizontalOrigin, labelToMerge.horizontalOrigin);
targetLabel.verticalOrigin = defaultValue(targetLabel.verticalOrigin, labelToMerge.verticalOrigin);
View
9 Source/DynamicScene/DynamicLabelVisualizer.js
@@ -228,6 +228,7 @@ define([
label.setFont('30px sans-serif');
label.setFillColor(Color.WHITE);
label.setOutlineColor(Color.BLACK);
+ label.setOutlineWidth(1);
label.setStyle(LabelStyle.FILL);
label.setPixelOffset(Cartesian2.ZERO);
label.setEyeOffset(Cartesian3.ZERO);
@@ -281,6 +282,14 @@ define([
}
}
+ property = dynamicLabel.outlineWidth;
+ if (typeof property !== 'undefined') {
+ var outlineWidth = property.getValue(time);
+ if (typeof outlineWidth !== 'undefined') {
+ label.setOutlineWidth(outlineWidth);
+ }
+ }
+
property = dynamicLabel.style;
if (typeof property !== 'undefined') {
var style = property.getValue(time);
View
8 Source/Scene/Billboard.js
@@ -582,7 +582,7 @@ define([
return undefined;
};
- Billboard._computeScreenSpacePosition = function(modelMatrix, position, eyeOffset, pixelOffset, clampToPixel, uniformState) {
+ Billboard._computeScreenSpacePosition = function(modelMatrix, position, eyeOffset, pixelOffset, uniformState) {
// This function is basically a stripped-down JavaScript version of BillboardCollectionVS.glsl
// Model to eye coordinates
@@ -607,10 +607,6 @@ define([
positionWC.x += po.x;
positionWC.y += po.y;
- if (clampToPixel) {
- return new Cartesian2(Math.floor(positionWC.x), Math.floor(positionWC.y));
- }
-
return new Cartesian2(positionWC.x, positionWC.y);
};
@@ -644,7 +640,7 @@ define([
throw new DeveloperError('uniformState is required.');
}
- return Billboard._computeScreenSpacePosition(billboardCollection.modelMatrix, this._actualPosition, this._eyeOffset, this._pixelOffset, this.clampToPixel, uniformState);
+ return Billboard._computeScreenSpacePosition(billboardCollection.modelMatrix, this._actualPosition, this._eyeOffset, this._pixelOffset, uniformState);
};
/**
View
12 Source/Scene/BillboardCollection.js
@@ -183,15 +183,6 @@ define([
this._projection = undefined;
/**
- * If true, aligns all billboards to a pixel in screen space,
- * providing a crisper image at the cost of jumpier motion.
- * Defaults to false.
- *
- * @type Boolean
- */
- this.clampToPixel = false;
-
- /**
* The current morph transition time between 2D/Columbus View and 3D,
* with 0.0 being 2D or Columbus View and 1.0 being 3D.
*
@@ -220,9 +211,6 @@ define([
u_atlasSize : function() {
return that._textureAtlas.getTexture().getDimensions();
},
- u_clampToPixel : function() {
- return that.clampToPixel ? 1.0 : 0.0;
- },
u_morphTime : function() {
return that.morphTime;
}
View
40 Source/Scene/Label.js
@@ -57,6 +57,7 @@ define([
this._font = defaultValue(description.font, '30px sans-serif');
this._fillColor = Color.clone(defaultValue(description.fillColor, Color.WHITE));
this._outlineColor = Color.clone(defaultValue(description.outlineColor, Color.BLACK));
+ this._outlineWidth = defaultValue(description.outlineWidth, 1.0);
this._style = defaultValue(description.style, LabelStyle.FILL);
this._verticalOrigin = defaultValue(description.verticalOrigin, VerticalOrigin.BOTTOM);
this._horizontalOrigin = defaultValue(description.horizontalOrigin, HorizontalOrigin.LEFT);
@@ -324,6 +325,43 @@ define([
};
/**
+ * Gets the outline width of this label.
+ *
+ * @memberof Label
+ *
+ * @see Label#setOutlineWidth
+ * @see <a href='http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#fill-and-stroke-styles'>HTML canvas 2D context fill and stroke styles</a>
+ */
+ Label.prototype.getOutlineWidth = function() {
+ return this._outlineWidth;
+ };
+
+ /**
+ * Sets the outline width of this label.
+ *
+ * @memberof Label
+ *
+ * @param {Number} value The outline width.
+ *
+ * @exception {DeveloperError} value is required.
+ *
+ * @see Label#getOutlineWidth
+ * @see Label#setFillColor
+ * @see Label#setFont
+ * @see <a href='http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#fill-and-stroke-styles'>HTML canvas 2D context fill and stroke styles</a>
+ */
+ Label.prototype.setOutlineWidth = function(value) {
+ if (typeof value === 'undefined') {
+ throw new DeveloperError('value is required.');
+ }
+
+ if (this._outlineWidth !== value) {
+ this._outlineWidth = value;
+ rebindAllGlyphs(this);
+ }
+ };
+
+ /**
* Gets the style of this label.
*
* @memberof Label
@@ -658,7 +696,7 @@ define([
var modelMatrix = labelCollection.modelMatrix;
var actualPosition = Billboard._computeActualPosition(this._position, frameState, labelCollection.morphTime, modelMatrix);
- return Billboard._computeScreenSpacePosition(modelMatrix, actualPosition, this._eyeOffset, this._pixelOffset, labelCollection.clampToPixel, uniformState);
+ return Billboard._computeScreenSpacePosition(modelMatrix, actualPosition, this._eyeOffset, this._pixelOffset, uniformState);
};
/**
View
34 Source/Scene/LabelCollection.js
@@ -67,10 +67,11 @@ define([
// reusable object for calling writeTextToCanvas
var writeTextToCanvasParameters = {};
- function createGlyphCanvas(character, font, fillColor, outlineColor, style, verticalOrigin) {
+ function createGlyphCanvas(character, font, fillColor, outlineColor, outlineWidth, style, verticalOrigin) {
writeTextToCanvasParameters.font = font;
writeTextToCanvasParameters.fillColor = fillColor;
writeTextToCanvasParameters.strokeColor = outlineColor;
+ writeTextToCanvasParameters.strokeWidth = outlineWidth;
if (verticalOrigin === VerticalOrigin.BOTTOM) {
writeTextToCanvasParameters.textBaseline = 'bottom';
@@ -132,6 +133,7 @@ define([
var font = label._font;
var fillColor = label._fillColor;
var outlineColor = label._outlineColor;
+ var outlineWidth = label._outlineWidth;
var style = label._style;
var verticalOrigin = label._verticalOrigin;
@@ -142,13 +144,14 @@ define([
font,
fillColor.toString(),
outlineColor.toString(),
+ outlineWidth,
style.toString(),
verticalOrigin.toString()
]);
var glyphTextureInfo = glyphTextureCache[id];
if (typeof glyphTextureInfo === 'undefined') {
- var canvas = createGlyphCanvas(character, font, fillColor, outlineColor, style, verticalOrigin);
+ var canvas = createGlyphCanvas(character, font, fillColor, outlineColor, outlineWidth, style, verticalOrigin);
var index = -1;
if (canvas.width > 0 && canvas.height > 0) {
index = textureAtlas.addImage(canvas);
@@ -362,15 +365,6 @@ define([
this.modelMatrix = Matrix4.IDENTITY.clone();
/**
- * If true, aligns all text to a pixel in screen space,
- * providing crisper text at the cost of jumpier motion.
- * Defaults to true.
- *
- * @type Boolean
- */
- this.clampToPixel = true;
-
- /**
* The current morph transition time between 2D/Columbus View and 3D,
* with 0.0 being 2D or Columbus View and 1.0 being 3D.
*
@@ -463,17 +457,14 @@ define([
* labels.remove(l); // Returns true
*/
LabelCollection.prototype.remove = function(label) {
- if (typeof label === 'undefined') {
- return false;
- }
-
- if (label._labelCollection === this) {
- this._labels.splice(this._labels.indexOf(label), 1);
- destroyLabel(this, label);
-
- return true;
+ if (typeof label !== 'undefined' && label._labelCollection === this) {
+ var index = this._labels.indexOf(label);
+ if (index !== -1) {
+ this._labels.splice(index, 1);
+ destroyLabel(this, label);
+ return true;
+ }
}
-
return false;
};
@@ -596,7 +587,6 @@ define([
billboardCollection.modelMatrix = this.modelMatrix;
billboardCollection.morphTime = this.morphTime;
- billboardCollection.clampToPixel = this.clampToPixel;
var rebindAllGlyphsInAllLabels = false;
if (++this._frameCount % 100 === 0) {
View
2 Source/Shaders/BillboardCollectionVS.glsl
@@ -13,7 +13,6 @@ attribute vec4 color;
#endif
uniform vec2 u_atlasSize;
-uniform float u_clampToPixel; // clamp is 1.0 (true) or 0.0 (false)
uniform float u_morphTime;
@@ -55,7 +54,6 @@ void main()
positionWC.xy += (origin * abs(halfSize)) + halfSize;
positionWC.xy += (pixelOffset * czm_highResolutionSnapScale);
- positionWC.xy = mix(positionWC.xy, floor(positionWC.xy), u_clampToPixel);
gl_Position = czm_viewportOrthographic * vec4(positionWC.xy, -positionWC.z, 1.0);
v_textureCoordinates = textureCoordinates;
View
18 Source/ThirdParty/measureText.js
@@ -92,7 +92,7 @@ define(function() {
/**
* The new text metrics function
*/
- var measureText = function(context2D, textstring) {
+ var measureText = function(context2D, textstring, stroke, fill) {
var metrics = context2D.measureText(textstring),
fontFamily = getCSSValue(context2D.canvas,"font-family"),
fontSize = getCSSValue(context2D.canvas,"font-size").replace("px",""),
@@ -136,9 +136,19 @@ define(function() {
// Set all canvas pixeldata values to 255, with all the content
// data being 0. This lets us scan for data[i] != 255.
ctx.fillStyle = "white";
- ctx.fillRect(-1, -1, w+2, h+2);
- ctx.fillStyle = "black";
- ctx.fillText(textstring, padding/2, baseline);
+ ctx.fillRect(-1, -1, w + 2, h + 2);
+
+ if (stroke) {
+ ctx.strokeStyle = "black";
+ ctx.lineWidth = context2D.lineWidth;
+ ctx.strokeText(textstring, (padding / 2), baseline);
+ }
+
+ if (fill) {
+ ctx.fillStyle = "black";
+ ctx.fillText(textstring, padding / 2, baseline);
+ }
+
var pixelData = ctx.getImageData(0, 0, w, h).data;
// canvas pixel data is w*4 by h*4, because R, G, B and A are separate,
View
3 Specs/Core/writeTextToCanvasSpec.js
@@ -45,9 +45,6 @@ defineSuite([
});
var context2 = canvas2.getContext('2d');
- expect(canvas1.width).toEqual(canvas2.width);
- expect(canvas1.height).toEqual(canvas2.height);
-
var row = 5;
// exact pixel checks are problematic due to browser differences in how text is drawn
View
108 Specs/DynamicScene/DynamicLabelSpec.js
@@ -10,7 +10,8 @@ defineSuite([
'Core/TimeInterval',
'Scene/HorizontalOrigin',
'Scene/VerticalOrigin',
- 'Scene/LabelStyle'
+ 'Scene/LabelStyle',
+ 'Specs/MockProperty'
], function(
DynamicLabel,
DynamicObject,
@@ -22,7 +23,8 @@ defineSuite([
TimeInterval,
HorizontalOrigin,
VerticalOrigin,
- LabelStyle) {
+ LabelStyle,
+ MockProperty) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
@@ -38,6 +40,7 @@ defineSuite([
outlineColor : {
rgbaf : [0.2, 0.2, 0.2, 0.2]
},
+ outlineWidth : 3.14,
horizontalOrigin : 'LEFT',
verticalOrigin : 'CENTER',
eyeOffset : {
@@ -59,6 +62,7 @@ defineSuite([
expect(dynamicObject.label.style.getValue(Iso8601.MINIMUM_VALUE)).toEqual(LabelStyle.FILL);
expect(dynamicObject.label.fillColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.1, 0.1, 0.1, 0.1));
expect(dynamicObject.label.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2));
+ expect(dynamicObject.label.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.outlineWidth);
expect(dynamicObject.label.horizontalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HorizontalOrigin.LEFT);
expect(dynamicObject.label.verticalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(VerticalOrigin.CENTER);
expect(dynamicObject.label.eyeOffset.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 2.0, 3.0));
@@ -80,6 +84,7 @@ defineSuite([
outlineColor : {
rgbaf : [0.2, 0.2, 0.2, 0.2]
},
+ outlineWidth : 2.78,
horizontalOrigin : 'LEFT',
verticalOrigin : 'CENTER',
eyeOffset : {
@@ -104,6 +109,7 @@ defineSuite([
expect(dynamicObject.label.style.getValue(validTime)).toEqual(LabelStyle.FILL);
expect(dynamicObject.label.fillColor.getValue(validTime)).toEqual(new Color(0.1, 0.1, 0.1, 0.1));
expect(dynamicObject.label.outlineColor.getValue(validTime)).toEqual(new Color(0.2, 0.2, 0.2, 0.2));
+ expect(dynamicObject.label.outlineWidth.getValue(validTime)).toEqual(labelPacket.label.outlineWidth);
expect(dynamicObject.label.horizontalOrigin.getValue(validTime)).toEqual(HorizontalOrigin.LEFT);
expect(dynamicObject.label.verticalOrigin.getValue(validTime)).toEqual(VerticalOrigin.CENTER);
expect(dynamicObject.label.eyeOffset.getValue(validTime)).toEqual(new Cartesian3(1.0, 2.0, 3.0));
@@ -116,6 +122,7 @@ defineSuite([
expect(dynamicObject.label.style.getValue(invalidTime)).toBeUndefined();
expect(dynamicObject.label.fillColor.getValue(invalidTime)).toBeUndefined();
expect(dynamicObject.label.outlineColor.getValue(invalidTime)).toBeUndefined();
+ expect(dynamicObject.label.outlineWidth.getValue(invalidTime)).toBeUndefined();
expect(dynamicObject.label.horizontalOrigin.getValue(invalidTime)).toBeUndefined();
expect(dynamicObject.label.verticalOrigin.getValue(invalidTime)).toBeUndefined();
expect(dynamicObject.label.eyeOffset.getValue(invalidTime)).toBeUndefined();
@@ -132,31 +139,33 @@ defineSuite([
});
it('mergeProperties does not change a fully configured label', function() {
- var expectedText = 12;
- var expectedFont = 13;
- var expectedStyle = 14;
- var expectedFillColor = 15;
- var expectedOutlineColor = 16;
- var expectedHorizontalOrigin = 17;
- var expectedVerticalOrigin = 18;
- var expectedEyeOffset = 19;
- var expectedPixelOffset = 20;
- var expectedScale = 21;
- var expectedShow = 22;
+ var expectedText = new MockProperty();
+ var expectedFont = new MockProperty();
+ var expectedStyle = new MockProperty();
+ var expectedFillColor = new MockProperty();
+ var expectedOutlineColor = new MockProperty();
+ var expectedOutlineWidth = new MockProperty();
+ var expectedHorizontalOrigin = new MockProperty();
+ var expectedVerticalOrigin = new MockProperty();
+ var expectedEyeOffset = new MockProperty();
+ var expectedPixelOffset = new MockProperty();
+ var expectedScale = new MockProperty();
+ var expectedShow = new MockProperty();
var objectToMerge = new DynamicObject('objectToMerge');
objectToMerge.label = new DynamicLabel();
- objectToMerge.label.text = 1;
- objectToMerge.label.font = 2;
- objectToMerge.label.style = 3;
- objectToMerge.label.fillColor = 4;
- objectToMerge.label.outlineColor = 5;
- objectToMerge.label.horizontalOrigin = 6;
- objectToMerge.label.verticalOrigin = 7;
- objectToMerge.label.eyeOffset = 8;
- objectToMerge.label.pixelOffset = 9;
- objectToMerge.label.scale = 10;
- objectToMerge.label.show = 11;
+ objectToMerge.label.text = new MockProperty();
+ objectToMerge.label.font = new MockProperty();
+ objectToMerge.label.style = new MockProperty();
+ objectToMerge.label.fillColor = new MockProperty();
+ objectToMerge.label.outlineColor = new MockProperty();
+ objectToMerge.label.outlineWidth = new MockProperty();
+ objectToMerge.label.horizontalOrigin = new MockProperty();
+ objectToMerge.label.verticalOrigin = new MockProperty();
+ objectToMerge.label.eyeOffset = new MockProperty();
+ objectToMerge.label.pixelOffset = new MockProperty();
+ objectToMerge.label.scale = new MockProperty();
+ objectToMerge.label.show = new MockProperty();
var targetObject = new DynamicObject('targetObject');
targetObject.label = new DynamicLabel();
@@ -165,6 +174,7 @@ defineSuite([
targetObject.label.style = expectedStyle;
targetObject.label.fillColor = expectedFillColor;
targetObject.label.outlineColor = expectedOutlineColor;
+ targetObject.label.outlineWidth = expectedOutlineWidth;
targetObject.label.horizontalOrigin = expectedHorizontalOrigin;
targetObject.label.verticalOrigin = expectedVerticalOrigin;
targetObject.label.eyeOffset = expectedEyeOffset;
@@ -179,6 +189,7 @@ defineSuite([
expect(targetObject.label.style).toEqual(expectedStyle);
expect(targetObject.label.fillColor).toEqual(expectedFillColor);
expect(targetObject.label.outlineColor).toEqual(expectedOutlineColor);
+ expect(targetObject.label.outlineWidth).toEqual(expectedOutlineWidth);
expect(targetObject.label.horizontalOrigin).toEqual(expectedHorizontalOrigin);
expect(targetObject.label.verticalOrigin).toEqual(expectedVerticalOrigin);
expect(targetObject.label.eyeOffset).toEqual(expectedEyeOffset);
@@ -190,17 +201,18 @@ defineSuite([
it('mergeProperties creates and configures an undefined label', function() {
var objectToMerge = new DynamicObject('objectToMerge');
objectToMerge.label = new DynamicLabel();
- objectToMerge.text = 1;
- objectToMerge.font = 2;
- objectToMerge.style = 3;
- objectToMerge.fillColor = 4;
- objectToMerge.outlineColor = 5;
- objectToMerge.horizontalOrigin = 6;
- objectToMerge.verticalOrigin = 7;
- objectToMerge.eyeOffset = 8;
- objectToMerge.pixelOffset = 9;
- objectToMerge.scale = 10;
- objectToMerge.show = 11;
+ objectToMerge.label.text = new MockProperty();
+ objectToMerge.label.font = new MockProperty();
+ objectToMerge.label.style = new MockProperty();
+ objectToMerge.label.fillColor = new MockProperty();
+ objectToMerge.label.outlineColor = new MockProperty();
+ objectToMerge.label.outlineWidth = new MockProperty();
+ objectToMerge.label.horizontalOrigin = new MockProperty();
+ objectToMerge.label.verticalOrigin = new MockProperty();
+ objectToMerge.label.eyeOffset = new MockProperty();
+ objectToMerge.label.pixelOffset = new MockProperty();
+ objectToMerge.label.scale = new MockProperty();
+ objectToMerge.label.show = new MockProperty();
var targetObject = new DynamicObject('targetObject');
@@ -211,6 +223,7 @@ defineSuite([
expect(targetObject.label.style).toEqual(objectToMerge.label.style);
expect(targetObject.label.fillColor).toEqual(objectToMerge.label.fillColor);
expect(targetObject.label.outlineColor).toEqual(objectToMerge.label.outlineColor);
+ expect(targetObject.label.outlineWidth).toEqual(objectToMerge.label.outlineWidth);
expect(targetObject.label.horizontalOrigin).toEqual(objectToMerge.label.horizontalOrigin);
expect(targetObject.label.verticalOrigin).toEqual(objectToMerge.label.verticalOrigin);
expect(targetObject.label.eyeOffset).toEqual(objectToMerge.label.eyeOffset);
@@ -220,17 +233,18 @@ defineSuite([
});
it('mergeProperties does not change when used with an undefined label', function() {
- var expectedText = 12;
- var expectedFont = 13;
- var expectedStyle = 14;
- var expectedFillColor = 15;
- var expectedOutlineColor = 16;
- var expectedHorizontalOrigin = 17;
- var expectedVerticalOrigin = 18;
- var expectedEyeOffset = 19;
- var expectedPixelOffset = 20;
- var expectedScale = 21;
- var expectedShow = 22;
+ var expectedText = new MockProperty();
+ var expectedFont = new MockProperty();
+ var expectedStyle = new MockProperty();
+ var expectedFillColor = new MockProperty();
+ var expectedOutlineColor = new MockProperty();
+ var expectedOutlineWidth = new MockProperty();
+ var expectedHorizontalOrigin = new MockProperty();
+ var expectedVerticalOrigin = new MockProperty();
+ var expectedEyeOffset = new MockProperty();
+ var expectedPixelOffset = new MockProperty();
+ var expectedScale = new MockProperty();
+ var expectedShow = new MockProperty();
var objectToMerge = new DynamicObject('objectToMerge');
@@ -241,6 +255,7 @@ defineSuite([
targetObject.label.style = expectedStyle;
targetObject.label.fillColor = expectedFillColor;
targetObject.label.outlineColor = expectedOutlineColor;
+ targetObject.label.outlineWidth = expectedOutlineWidth;
targetObject.label.horizontalOrigin = expectedHorizontalOrigin;
targetObject.label.verticalOrigin = expectedVerticalOrigin;
targetObject.label.eyeOffset = expectedEyeOffset;
@@ -255,6 +270,7 @@ defineSuite([
expect(targetObject.label.style).toEqual(expectedStyle);
expect(targetObject.label.fillColor).toEqual(expectedFillColor);
expect(targetObject.label.outlineColor).toEqual(expectedOutlineColor);
+ expect(targetObject.label.outlineWidth).toEqual(expectedOutlineWidth);
expect(targetObject.label.horizontalOrigin).toEqual(expectedHorizontalOrigin);
expect(targetObject.label.verticalOrigin).toEqual(expectedVerticalOrigin);
expect(targetObject.label.eyeOffset).toEqual(expectedEyeOffset);
View
4 Specs/DynamicScene/DynamicLabelVisualizerSpec.js
@@ -145,6 +145,7 @@ defineSuite([
label.style = new MockProperty(LabelStyle.FILL);
label.fillColor = new MockProperty(new Color(0.5, 0.8, 0.6, 0.7));
label.outlineColor = new MockProperty(new Color(0.4, 0.3, 0.2, 0.1));
+ label.outlineWidth = new MockProperty(4.5);
label.horizontalOrigin = new MockProperty(HorizontalOrigin.RIGHT);
label.verticalOrigin = new MockProperty(VerticalOrigin.TOP);
label.eyeOffset = new MockProperty(new Cartesian3(1.0, 2.0, 3.0));
@@ -165,6 +166,7 @@ defineSuite([
expect(l.getStyle()).toEqual(testObject.label.style.getValue(time));
expect(l.getFillColor()).toEqual(testObject.label.fillColor.getValue(time));
expect(l.getOutlineColor()).toEqual(testObject.label.outlineColor.getValue(time));
+ expect(l.getOutlineWidth()).toEqual(testObject.label.outlineWidth.getValue(time));
expect(l.getHorizontalOrigin()).toEqual(testObject.label.horizontalOrigin.getValue(time));
expect(l.getVerticalOrigin()).toEqual(testObject.label.verticalOrigin.getValue(time));
expect(l.getEyeOffset()).toEqual(testObject.label.eyeOffset.getValue(time));
@@ -178,6 +180,7 @@ defineSuite([
label.style = new MockProperty(LabelStyle.FILL_AND_OUTLINE);
label.fillColor = new MockProperty(new Color(0.1, 0.2, 0.3, 0.4));
label.outlineColor = new MockProperty(new Color(0.8, 0.7, 0.6, 0.5));
+ label.outlineWidth = new MockProperty(0.5);
label.horizontalOrigin = new MockProperty(HorizontalOrigin.CENTER);
label.verticalOrigin = new MockProperty(VerticalOrigin.BOTTOM);
label.eyeOffset = new MockProperty(new Cartesian3(3.0, 1.0, 2.0));
@@ -192,6 +195,7 @@ defineSuite([
expect(l.getStyle()).toEqual(testObject.label.style.getValue(time));
expect(l.getFillColor()).toEqual(testObject.label.fillColor.getValue(time));
expect(l.getOutlineColor()).toEqual(testObject.label.outlineColor.getValue(time));
+ expect(l.getOutlineWidth()).toEqual(testObject.label.outlineWidth.getValue(time));
expect(l.getHorizontalOrigin()).toEqual(testObject.label.horizontalOrigin.getValue(time));
expect(l.getVerticalOrigin()).toEqual(testObject.label.verticalOrigin.getValue(time));
expect(l.getEyeOffset()).toEqual(testObject.label.eyeOffset.getValue(time));
View
1 Specs/Scene/CompositePrimitiveSpec.js
@@ -75,7 +75,6 @@ defineSuite([
function createLabels(position) {
position = position || { x : -1.0, y : 0.0, z : 0.0 };
var labels = new LabelCollection();
- labels.clampToPixel = false;
labels.add({
position : position,
text : 'x',
View
132 Specs/Scene/LabelCollectionSpec.js
@@ -46,7 +46,7 @@ defineSuite([
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
- // TODO: rendering tests for pixel offset, eye offset, horizontal origin, vertical origin, font, style, outlineColor and fillColor properties
+ // TODO: rendering tests for pixel offset, eye offset, horizontal origin, vertical origin, font, style, outlineColor, outlineWidth, and fillColor properties
var context;
var labels;
@@ -80,6 +80,7 @@ defineSuite([
expect(label.getFont()).toEqual('30px sans-serif');
expect(label.getFillColor()).toEqual(Color.WHITE);
expect(label.getOutlineColor()).toEqual(Color.BLACK);
+ expect(label.getOutlineWidth()).toEqual(1);
expect(label.getStyle()).toEqual(LabelStyle.FILL);
expect(label.getPixelOffset()).toEqual(Cartesian2.ZERO);
expect(label.getEyeOffset()).toEqual(Cartesian3.ZERO);
@@ -105,6 +106,8 @@ defineSuite([
blue : 2.0,
alpha : 1.0
};
+ var outlineWidth = 2;
+
var style = LabelStyle.FILL_AND_OUTLINE;
var pixelOffset = new Cartesian2(4.0, 5.0);
var eyeOffset = new Cartesian3(6.0, 7.0, 8.0);
@@ -118,6 +121,7 @@ defineSuite([
font : font,
fillColor : fillColor,
outlineColor : outlineColor,
+ outlineWidth : outlineWidth,
style : style,
pixelOffset : pixelOffset,
eyeOffset : eyeOffset,
@@ -132,6 +136,7 @@ defineSuite([
expect(label.getFont()).toEqual(font);
expect(label.getFillColor()).toEqual(fillColor);
expect(label.getOutlineColor()).toEqual(outlineColor);
+ expect(label.getOutlineWidth()).toEqual(outlineWidth);
expect(label.getStyle()).toEqual(style);
expect(label.getPixelOffset()).toEqual(pixelOffset);
expect(label.getEyeOffset()).toEqual(eyeOffset);
@@ -195,6 +200,18 @@ defineSuite([
expect(labels.getLength()).toEqual(1);
});
+ it('returns false when removing a previously removed label', function() {
+ var label = labels.add();
+ expect(labels.getLength()).toEqual(1);
+ expect(labels.remove(label)).toEqual(true);
+ expect(labels.remove(label)).toEqual(false);
+ expect(labels.getLength()).toEqual(0);
+ });
+
+ it('isDestroyed returns false', function() {
+ expect(labels.isDestroyed()).toEqual(false);
+ });
+
it('adding and removing multiple labels works', function() {
var one = labels.add();
var two = labels.add();
@@ -730,6 +747,11 @@ defineSuite([
label.setFont('30px sans-serif');
labels.update(context, frameState, []);
expect(labels._textureCount).toEqual(15);
+
+ //Changing thickness requires new glyphs
+ label.setOutlineWidth(3);
+ labels.update(context, frameState, []);
+ expect(labels._textureCount).toEqual(17);
});
it('should reuse billboards that are not needed any more', function() {
@@ -805,6 +827,7 @@ defineSuite([
blue : 2.0,
alpha : 1.0
};
+ var outlineWidth = 2;
var style = LabelStyle.FILL_AND_OUTLINE;
var pixelOffset = new Cartesian2(4.0, 5.0);
var eyeOffset = new Cartesian3(6.0, 7.0, 8.0);
@@ -818,6 +841,7 @@ defineSuite([
label.setFont(font);
label.setFillColor(fillColor);
label.setOutlineColor(outlineColor);
+ label.setOutlineWidth(outlineWidth);
label.setStyle(style);
label.setPixelOffset(pixelOffset);
label.setEyeOffset(eyeOffset);
@@ -831,6 +855,7 @@ defineSuite([
expect(label.getFont()).toEqual(font);
expect(label.getFillColor()).toEqual(fillColor);
expect(label.getOutlineColor()).toEqual(outlineColor);
+ expect(label.getOutlineWidth()).toEqual(outlineWidth);
expect(label.getStyle()).toEqual(style);
expect(label.getPixelOffset()).toEqual(pixelOffset);
expect(label.getEyeOffset()).toEqual(eyeOffset);
@@ -1404,4 +1429,109 @@ defineSuite([
expect(bs.center).toEqualEpsilon(actual.center, CesiumMath.EPSILON8);
expect(bs.radius).toBeLessThan(actual.radius);
});
+
+ it('Label.setShow throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setShow(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setPosition throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setPosition(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setText throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setText(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setFont throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setFont(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setFillColor throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setFillColor(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setOutlineColor throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setOutlineColor(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setOutlineWidth throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setOutlineWidth(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setStyle throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setStyle(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setPixelOffset throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setPixelOffset(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setEyeOffset throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setEyeOffset(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setHorizontalOrigin throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setHorizontalOrigin(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setVerticalOrigin throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setVerticalOrigin(undefined);
+ }).toThrow();
+ });
+
+ it('Label.setScale throws with undefined', function() {
+ var label = labels.add();
+ expect(function() {
+ label.setScale(undefined);
+ }).toThrow();
+ });
+
+ it('Label.computeScreenSpacePosition throws with undefined uniformState', function() {
+ var label = labels.add();
+ expect(function() {
+ label.computeScreenSpacePosition(undefined, frameState);
+ }).toThrow();
+ });
+
+ it('Label.computeScreenSpacePosition throws with undefined frameState', function() {
+ var label = labels.add();
+ expect(function() {
+ label.computeScreenSpacePosition(us, undefined);
+ }).toThrow();
+ });
}, 'WebGL');
View
2 Specs/Scene/PrimitiveCullingSpec.js
@@ -328,7 +328,6 @@ defineSuite([
function createLabels(position) {
position = position || { x : -1.0, y : 0.0, z : 0.0 };
var labels = new LabelCollection();
- labels.clampToPixel = false;
labels.add({
position : position,
text : 'x',
@@ -355,7 +354,6 @@ defineSuite([
it('label occlusion', function() {
var labels = new LabelCollection();
- labels.clampToPixel = false;
labels.add({
position : Ellipsoid.WGS84.cartographicToCartesian(new Cartographic.fromDegrees(-75.10, 39.57)),
text : 'x',

0 comments on commit 8a02251

Please sign in to comment.
Something went wrong with that request. Please try again.