Skip to content

Change typography examples to ES6 #3400

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

Merged
merged 1 commit into from
Dec 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/typography/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ p5.prototype.textAlign = function(horizAlign, vertAlign) {
* <div>
* <code>
* // Text to display. The "\n" is a "new line" character
* var lines = 'L1\nL2\nL3';
* let lines = 'L1\nL2\nL3';
* textSize(12);
*
* textLeading(10); // Set leading to 10
Expand Down Expand Up @@ -199,13 +199,13 @@ p5.prototype.textStyle = function(theStyle) {
* <code>
* textSize(28);
*
* var aChar = 'P';
* var cWidth = textWidth(aChar);
* let aChar = 'P';
* let cWidth = textWidth(aChar);
* text(aChar, 0, 40);
* line(cWidth, 0, cWidth, 50);
*
* var aString = 'p5.js';
* var sWidth = textWidth(aString);
* let aString = 'p5.js';
* let sWidth = textWidth(aString);
* text(aString, 0, 85);
* line(sWidth, 50, sWidth, 100);
* </code>
Expand All @@ -232,11 +232,11 @@ p5.prototype.textWidth = function(theText) {
* @example
* <div>
* <code>
* var base = height * 0.75;
* var scalar = 0.8; // Different for each font
* let base = height * 0.75;
* let scalar = 0.8; // Different for each font
*
* textSize(32); // Set initial text size
* var asc = textAscent() * scalar; // Calc ascent
* let asc = textAscent() * scalar; // Calc ascent
* line(0, base - asc, width, base - asc);
* text('dp', 0, base); // Draw text on baseline
*
Expand All @@ -261,11 +261,11 @@ p5.prototype.textAscent = function() {
* @example
* <div>
* <code>
* var base = height * 0.75;
* var scalar = 0.8; // Different for each font
* let base = height * 0.75;
* let scalar = 0.8; // Different for each font
*
* textSize(32); // Set initial text size
* var desc = textDescent() * scalar; // Calc ascent
* let desc = textDescent() * scalar; // Calc ascent
* line(0, base + desc, width, base + desc);
* text('dp', 0, base); // Draw text on baseline
*
Expand Down
12 changes: 6 additions & 6 deletions src/typography/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ require('../core/error_helpers');
* operation will have completed before <a href="#/p5/setup">setup()</a> and <a href="#/p5/draw">draw()</a> are called.</p>
*
* <div><code>
* var myFont;
* let myFont;
* function preload() {
* myFont = loadFont('assets/AvenirNextLTPro-Demi.otf');
* }
Expand Down Expand Up @@ -74,7 +74,7 @@ require('../core/error_helpers');
* }
*
* function setup() {
* var myDiv = createDiv('hello there');
* let myDiv = createDiv('hello there');
* myDiv.style('font-family', 'Avenir');
* }
* </code></div>
Expand Down Expand Up @@ -186,15 +186,15 @@ p5.prototype.loadFont = function(path, onSuccess, onError) {
* </div>
* <div>
* <code>
* var s = 'The quick brown fox jumped over the lazy dog.';
* let s = 'The quick brown fox jumped over the lazy dog.';
* fill(50);
* text(s, 10, 10, 70, 80); // Text wraps within text box
* </code>
* </div>
*
* <div modernizr='webgl'>
* <code>
* var avenir;
* let avenir;
* function preload() {
* avenir = loadFont('assets/Avenir.otf');
* }
Expand All @@ -206,7 +206,7 @@ p5.prototype.loadFont = function(path, onSuccess, onError) {
* }
* function draw() {
* background(0);
* var time = millis();
* let time = millis();
* rotateX(time / 1000);
* rotateZ(time / 1234);
* text('p5.js', 0, 0);
Expand Down Expand Up @@ -248,7 +248,7 @@ p5.prototype.text = function(str, x, y, maxWidth, maxHeight) {
* </div>
* <div>
* <code>
* var fontRegular, fontItalic, fontBold;
* let fontRegular, fontItalic, fontBold;
* function preload() {
* fontRegular = loadFont('assets/Regular.otf');
* fontItalic = loadFont('assets/Italic.ttf');
Expand Down
16 changes: 8 additions & 8 deletions src/typography/p5.Font.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ p5.Font.prototype.list = function() {
* @example
* <div>
* <code>
* var font;
* var textString = 'Lorem ipsum dolor sit amet.';
* let font;
* let textString = 'Lorem ipsum dolor sit amet.';
* function preload() {
* font = loadFont('./assets/Regular.otf');
* }
* function setup() {
* background(210);
*
* var bbox = font.textBounds(textString, 10, 30, 12);
* let bbox = font.textBounds(textString, 10, 30, 12);
* fill(255);
* stroke(0);
* rect(bbox.x, bbox.y, bbox.w, bbox.h);
Expand Down Expand Up @@ -179,13 +179,13 @@ p5.Font.prototype.textBounds = function(str, x, y, fontSize, options) {
* @example
* <div>
* <code>
* var font;
* let font;
* function preload() {
* font = loadFont('./assets/Avenir.otf');
* }
*
* var points;
* var bounds;
* let points;
* let bounds;
* function setup() {
* createCanvas(100, 100);
* stroke(0);
Expand All @@ -202,8 +202,8 @@ p5.Font.prototype.textBounds = function(str, x, y, fontSize, options) {
* background(255);
* beginShape();
* translate(-bounds.x * width / bounds.w, -bounds.y * height / bounds.h);
* for (var i = 0; i < points.length; i++) {
* var p = points[i];
* for (let i = 0; i < points.length; i++) {
* let p = points[i];
* vertex(
* p.x * width / bounds.w +
* sin(20 * p.y / bounds.h + millis() / 1000) * width / 30,
Expand Down