Skip to content

Instantly share code, notes, and snippets.

@desireesantos
Last active December 11, 2015 00:49
Show Gist options
  • Save desireesantos/4519401 to your computer and use it in GitHub Desktop.
Save desireesantos/4519401 to your computer and use it in GitHub Desktop.
Controlar a posição da coordenada x,y
var LinePositionControl = function (word, position) {
var YPosition = 180;
var marginRight = 980;
var coordinateXPosition = position;
this.currentPositionX = function () {
var textWidth = context.measureText(word).width;
coordinateXPosition < (coordinateXPosition - textWidth) ? coordinateXPosition + 10 : coordinateXPosition = 0;
printWord();
return coordinateXPosition;
};
var printWord = function () {
context.fillText(word, coordinateXPosition, YPosition);
}
};
@desireesantos
Copy link
Author

Classe js responsável por controlar a posição da coordenada (X,Y) que representa a posição na linha onde a letra será exibida via canvas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment