play-co / timestep

GNU General Public License v3.0
16 stars 27 forks source link

Drop shadow broken for TextView #19

Closed roosmaa closed 11 years ago

roosmaa commented 11 years ago

It seems that the strokeWidth parameter is not used for the drop shadow offset, as it should be according to the docs. Thus the drop shadow gets rendered beneath the text, leaving the impression nothing works.

https://github.com/gameclosure/timestep/blob/master/src/ui/backend/canvas/TextView.js#L310 line should include the strokeWidth as another offset to both of the parameters.

roosmaa commented 11 years ago

This seems to make drop down shadows functional again.


diff --git a/src/ui/backend/canvas/TextView.js b/src/ui/backend/canvas/TextView.js
index 4e633bf..86a0cf7 100755
--- a/src/ui/backend/canvas/TextView.js
+++ b/src/ui/backend/canvas/TextView.js
@@ -306,8 +306,9 @@ var TextView = exports = Class(View, function (supr) {
                                ctx.strokeText(word, x + lineOffset, y + lineOffset, maxWidth);
                        }
                        if (shadowColor) {
+                               var shadowOffset = this._opts.strokeWidth || 0;
                                ctx.fillStyle = shadowColor;
-                               ctx.fillText(word, x + lineOffset, y + lineOffset, maxWidth);
+                               ctx.fillText(word, x + lineOffset + shadowOffset, y + lineOffset + shadowOffset, maxWidth);
                        }

                        ctx.fillStyle = color;
bubbleboy14 commented 11 years ago

Thanks roosmaa! Nice work, as usual :) We applied your patch upstream.