Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Ellipsis #5

Open
crystaltong opened this issue Jan 21, 2015 · 0 comments
Open

Adding Ellipsis #5

crystaltong opened this issue Jan 21, 2015 · 0 comments

Comments

@crystaltong
Copy link

hello,

I have a function that adds an ellipsis (...) at the end of my canvas text. I was wondering, how would one go about adding that function to your script? Any advice would be much appreciated!

function ellipsis1(context,text1) {
var words = text1.split();
var dot = '...';
var more2 = '';
var maxWidth = 115;
var x = 48;
var y = 28;

        for(var n = 0; n < words.length; n++) {
          var metrics = context.measureText(words);
          var textWidth = metrics.width;
          if (textWidth > maxWidth) {
            more2 = words + dot;
          }
        }
        context.fillText(more2, x, y);
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant