Skip to content

Commit

Permalink
finishRandomRhymes
Browse files Browse the repository at this point in the history
  • Loading branch information
System Administrator authored and System Administrator committed Aug 18, 2020
1 parent 6964aeb commit 6cc89ff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
8 changes: 3 additions & 5 deletions examples/dom/RandomRhymes/code.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
$(function () {

findRhymes();

function findRhymes() {

let word, tmp = '';
do {
word = RiTa.randomWord();
tmp = RiTa.rhymes(word);
tmp = RiTa.rhymes(word,{limit:13});
} while (tmp.length < 3)

const rhymes = tmp.slice(0, Math.min(tmp.length, 13));

$('#word').html(word);
$('#rhyme').html(rhymes.join("<br>"));
$('#rhyme').html(tmp.join("<br>"));

setTimeout(findRhymes, 2000);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/dom/RandomRhymes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel='stylesheet' href='../../lib/prism.css' />
<style>
body {
font-family: sans-serif;
font-family: Georgia,serif;
}
.canvas {
position:relative;
Expand All @@ -22,15 +22,15 @@
}
#word {
position:absolute;
top:20px;
top:15px;
right:20px;
font-size: 36px;
color:white;
text-align: right;
}
#rhyme{
position:absolute;
top:70px;
top:65px;
left:30px;
font-size: 14px;
color:white;
Expand Down
10 changes: 4 additions & 6 deletions examples/p5/RandomRhymes/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ function setup()
fill(255);
textFont("Georgia");

lexicon = RiTa.lexicon();
findRhymes();

setInterval(findRhymes, 2000);
Expand All @@ -31,10 +30,9 @@ function findRhymes() { // called by timer

let tmp = '';
do {
word = lexicon.randomWord();
tmp = lexicon.rhymes(word);
word = RiTa.randomWord();
tmp = RiTa.rhymes(word,{limit: 13});
} while ( word && tmp.length < 3)

const arr = subset(tmp, 0, min(tmp.length, 13)); // max of 13 words
rhymes = arr.join("\n");
// use argument instead of subsetting afterward
rhymes = tmp.join("\n");
}

0 comments on commit 6cc89ff

Please sign in to comment.