diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fa4a53 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env +npm-debug.log* +yarn-debug.log* +yarn-error.log* + diff --git a/package.json b/package.json new file mode 100644 index 0000000..cfe9c14 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "songsim", + "version": "0.1.0", + "private": true, + "devDependencies": { + "react-scripts": "0.9.0" + }, + "dependencies": { + "bootstrap": "^3.3.7", + "react": "^15.4.2", + "react-dom": "^15.4.2" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject" + } +} diff --git a/public/canned/badromance.txt b/public/canned/badromance.txt new file mode 100644 index 0000000..a8c5574 --- /dev/null +++ b/public/canned/badromance.txt @@ -0,0 +1,114 @@ +Oh, caught in a bad romance +Oh, caught in a bad romance + +Rah, rah, ah, ah, ah +Roma, roma, ma +Gaga, ooh, la, la la +Want your bad romance + +Rah, rah, ah, ah, ah +Roma, roma, ma +Gaga, ooh la la la +Want your bad romance + +I want your ugly, I want your disease +I want your everything as long as it's free +I want your love +Love, love, love, I want your love + +I want your drama, the touch of your hand +I want your leather studded kiss in the sand +I want your love +Love, love, love, I want your love +(Love, love, love, I want your love) + +You know that I want you +And you know that I need you +I want it bad, your bad romance + +I want your love, and I want your revenge +You and me could write a bad romance +I want your love, and all your love is revenge +You and me could write a bad romance + +Oh, caught in a bad romance +Oh, caught in a bad romance + +Rah, rah, ah, ah, ah +Roma, roma, ma +Gaga, ooh la la la +Want your bad romance + +I want your horror, I want your design +'Cause you're a criminal as long as you're mine +I want your love +Love, love, love, I want your love + +I want your psycho, your vertigo shtick +Want you in my rear window, baby, you're sick +I want your love +Love, love, love, I want your love +(Love, love, love, I want your love) + +You know that I want you +And you know that I need you +('Cause I'm a free bitch, baby) +I want it bad, your bad romance + +I want your love, and I want your revenge +You and me could write a bad romance +I want your love, and all your love is revenge +You and me could write a bad romance + +Oh, caught in a bad romance +Oh, caught in a bad romance + +Rah, rah, ah, ah, ah +Roma, roma, ma +Gaga, ooh la la la +Want your bad romance + +Rah, rah, ah, ah, ah +Roma, roma, ma +Gaga, ooh la la la +Want your bad romance + +Walk, walk, fashion, baby +Work it, move that bitch, crazy +Walk, walk, fashion, baby +Work it, move that bitch, crazy + +Walk, walk, fashion, baby +Work it, move that bitch, crazy +Walk, walk, passion, baby +Work it, I'm a free bitch, baby + +I want your love, and I want your revenge +I want your love, I don't wanna be friends +J'veux ton amour et je veux ta revanche +J'veux ton amour, I don't wanna be friends + +No, I don't wanna be friends +(Oh, caught in a bad romance) +I don't wanna be friends + +Want your bad romance +(Oh, caught in a bad romance) +Want your bad romance + +I want your love, and I want your revenge +You and me could write a bad romance +I want your love, and all your lover's revenge +You and me could write a bad romance + +Want your bad romance +(Oh, caught in a bad romance) +Want your bad romance +Want your bad romance +(Oh, caught in a bad romance) + +Rah, rah, ah, ah, ah +Roma, roma, ma +Gaga, ooh la la la +Want your bad romance + diff --git a/public/canned/barbiegirl.txt b/public/canned/barbiegirl.txt new file mode 100644 index 0000000..e239483 --- /dev/null +++ b/public/canned/barbiegirl.txt @@ -0,0 +1,72 @@ +Hiya Barbie +Hi Ken! +Do you want to go for a ride? +Sure Ken +Jump in + +I'm a Barbie girl, in a Barbie world +Life in plastic, it's fantastic +You can brush my hair, undress me everywhere +Imagination, life is your creation + +Come on Barbie, let's go party! + +I'm a Barbie girl, in a Barbie world +Life in plastic, it's fantastic +You can brush my hair, undress me everywhere +Imagination, life is your creation + +I'm a blond bimbo girl, in a fantasy world +Dress me up, make it tight, I'm your dolly +You're my doll, rock'n'roll, feel the glamor in pink +Kiss me here, touch me there, hanky panky +You can touch +you can play +if you say "I'm always yours" + +I'm a Barbie girl, in a Barbie world +Life in plastic, it's fantastic +You can brush my hair, undress me everywhere +Imagination, life is your creation + +Come on Barbie, let's go party! (Ah ah ah yeah) +Come on Barbie, let's go party! (Oh oh) +Come on Barbie, let's go party! (Ah ah ah yeah) +Come on Barbie, let's go party! (Oh oh) + +Make me walk, make me talk, do whatever you please +I can act like a star, I can beg on my knees +Come jump in, bimbo friend, let us do it again +Hit the town, fool around, let's go party + +You can touch +you can play +If you say "I'm always yours" +You can touch +you can play, +If you say "I'm always yours" + +Come on Barbie, let's go party! (Ah ah ah yeah) +Come on Barbie, let's go party! (Oh oh) +Come on Barbie, let's go party! (Ah ah ah yeah) +Come on Barbie, let's go party! (Oh oh) + +I'm a Barbie girl, in a Barbie world +Life in plastic, it's fantastic +You can brush my hair, undress me everywhere +Imagination, life is your creation + +I'm a Barbie girl, in a Barbie world +Life in plastic, it's fantastic +You can brush my hair, undress me everywhere +Imagination, life is your creation + +Come on Barbie, let's go party! (Ah ah ah yeah) +Come on Barbie, let's go party! (Oh oh) +Come on Barbie, let's go party! (Ah ah ah yeah) +Come on Barbie, let's go party! (Oh oh) + +Oh, I'm having so much fun! +Well Barbie, we are just getting started +Oh, I love you Ken + diff --git a/public/canned/buddyholly.txt b/public/canned/buddyholly.txt new file mode 100644 index 0000000..3aef346 --- /dev/null +++ b/public/canned/buddyholly.txt @@ -0,0 +1,45 @@ +What's with these homies, dissing my girl? +Why do they gotta front? +What did we ever do to these guys +That made them so violent? +Woo-hoo, but you know I'm yours +Woo-hoo, and I know you're mine +Woo-hoo, and that's for all time + +Oo-ee-oo I look just like Buddy Holly +Oh-oh, and you're Mary Tyler Moore +I don't care what they say about us anyway +I don't care bout that + +Don't you ever fear, I'm always near +I know that you need help +Your tongue is twisted, your eyes are slit +You need a guardian +Woo-hoo, and you know I'm yours +Woo-hoo, and I know you're mine +Woo-hoo, and that's for all time + +Oo-ee-oo I look just like Buddy Holly +Oh-oh, and you're Mary Tyler Moore +I don't care what they say about us anyway +I don't care bout that +I don't care bout that + +Bang, bang a knock on the door +Another big bang and you're down on the floor +Oh no! What do we do? +Don't look now but I lost my shoe +I can't run and I can't kick +What's a matter babe are you feeling sick? +what's a matter, what's a matter, what's a matter you? +What's a matter babe, are you feeling blue? oh-oh! +And that's for all time +And that's for all time + +Oo-ee-oo I look just like Buddy Holly +Oh-oh, and you're Mary Tyler Moore +I don't care what they say about us anyway +I don't care bout that +I don't care bout that +I don't care bout that +I don't care bout that diff --git a/public/canned/cgyoomh.txt b/public/canned/cgyoomh.txt new file mode 100644 index 0000000..121811e --- /dev/null +++ b/public/canned/cgyoomh.txt @@ -0,0 +1,59 @@ +La la la la la la la la +La la la la la la la la +La la la la la la la la +La la la la la la la la + +I just can't get you out of my head +Boy your loving is all I think about +I just can't get you out of my head +Boy it's more than I dare to think about + +La la la la la la la la +La la la la la la la la + +I just can't get you out of my head +Boy your loving is all I think about +I just can't get you out of my head +Boy it's more than I dare to think about + +Every night, every day +Just to be there in your arms +Won't you stay +Won't you lay +stay forever and ever and ever and ever + +La la la la la la la la +La la la la la la la la +La la la la la la la la +La la la la la la la la + +I just can't get you out of my head +Boy your loving is all I think about +I just can't get you out of my head +Boy it's more than I dare to think about + +There's a dark secret in me +Don't leave me locked in your heart +Set me free +Feel the need in me +Set me free +Stay forever +And ever and ever and ever + +La la la la la la la la +La la la la la la la la +La la la la la la la la +La la la la la la la la + +I just can't get you out of my head +La la la la la la la la +La la la la la la la la +I just can't get you out of my head +La la la la la la la la +La la la la la la la la +I just can't get you out of my head +La la la la la la la la +La la la la la la la la +I just can't get you out of my head +La la la la la la la la +La la la la la la la la \ No newline at end of file diff --git a/public/canned/humps.txt b/public/canned/humps.txt new file mode 100644 index 0000000..0caadb2 --- /dev/null +++ b/public/canned/humps.txt @@ -0,0 +1,141 @@ +Whatcha gonna do with all that junk +All that junk inside your trunk + +I'ma get get get get you drunk +Get you love drunk off my hump +My hump my hump my hump my hump my hump +My hump my hump my hump my lovely little lumps + +Check it out + +I drive these brothers crazy +I do it on the daily +They treat me really nicely +They buy me all these ice +Dolce and Gabbana +Fendi and Madonna +Caring they be sharin' +All their money got me wearing fly +Whether I ain't askin' +They say they love mah ass in +Seven jeans +True religion +I say no +But they keep givin' +So I keep on takin' +And no I ain't takin' +We can keep on datin' +Now keep on demonstratin' + +My love my love my love my love +You love my lady lumps +My hump my hump my hump +My humps they got you + +She's got me spending + +Oh, spending all your money on me +And spending time on me + +She's got me spending + +Oh, spending all your money on me +Uh on me on me + +Whatcha gonna do with all that junk +All that junk inside that trunk + +I'm a get get get get you drunk +Get you love drunk off my hump + +Whatcha gonna do with all that ass +All that ass inside your jeans + +I'm a make make make make you scream +Make you scream make you scream + +'Cause of my humps my hump my hump my hump +My hump my hump my hump my lovely lady lumps + +Check it out + +I met a girl down at the disco +She said hey hey hey ya lets go +I can be ya baby, you could be my honey +Let's spend time not money +And mix your milk with my coco puff +Milky milky coco +Mix your milk with my coco puff +Milky milky +Right + +They say I'm really sexy +The boys they wanna sex me +They always standin' next to me +Always dancin' next to me +Tryin' a feel my hump hump +Lookin' at my lump lump +You can look but you can't touch it +If you touch it +I'm a start some drama +You don't want no drama +No no drama no no no no drama +So don't pull on my hand boy +You ain't my man boy +I'm just tryin' a dance boy + +And move my hump +My hump my hump my hump my hump +My hump my hump my hump my hump my hump my hump +My lovely lady lumps +My lovely lady lumps my lovely lady lumps +In the back and in the front + +My loving got you + +She's got me spending + +Oh, spending all your money on me +And spending time on me + +She's got me spending + +Oh, spending all your money on me +Uh on me on me + +Whatcha gonna do with all that junk +All that junk inside that trunk + +I'm a get get get get you drunk +Get you love drunk off my hump + +Whatcha gonna do with all that ass +All that ass inside your jeans + +I'm a make make make make you scream +Make you scream make you scream + +Whatcha gonna do with all that junk +All that junk inside that trunk + +I'm a get get get get you drunk +Get you love drunk off this hump + +Whatcha gonna do with all that breast +All that breast inside that shirt + +I'm a make make make make you work +Make you work work make you work + +She's got me spending + +Oh, spending all your money on me +And spending time on me + +She's got me spending + +Oh, spending all your money on me +Uh on me on me + +(Surreal, surreal, surreal, surreal, surreal) + diff --git a/public/canned/judas.txt b/public/canned/judas.txt new file mode 100644 index 0000000..a9c1a30 --- /dev/null +++ b/public/canned/judas.txt @@ -0,0 +1,56 @@ +Oh oh, oh oh +I'm in love with Judas, Judas +Oh oh, oh oh +I'm in love with Judas, Judas +Judas, Juda-a-a, Judas, Juda-a-a +Judas Juda-a-a, Judas, Gaga +Judas Juda-a-a, Judas, Juda-a-a +Judas, Juda-a-a, Judas, Gaga +When he calls to me, I am ready +I'll wash his feet with my hair if he needs +Forgive him when his tongue lies through his brain +Even after three times, he betrays me +I'll bring him down, bring him down, down +A king with no crown, king with no crown +I'm just a holy fool, oh baby it's so cruel +But I'm still in love with Judas, baby +I'm just a holy fool, oh baby it's so cruel +But I'm still in love with Judas, baby +Oh oh, oh oh +I'm in love with Judas, Judas +Oh oh, oh oh +I'm in love with Judas, Judas +Judas, Juda-a-a, Judas, Juda-a-a +Judas, Juda-a-a, Judas, Gaga +I couldn't love a man so purely +Even prophets forgave his goofy way +I've learned love is like a brick you can +Build a house or sink a dead body +I'll bring him down, bring him down, down +A king with no crown, king with no crown +I'm just a holy fool, oh baby it's so cruel +But I'm still in love with Judas, baby +I'm just a holy fool, oh baby it's so cruel +But I'm still in love with Judas, baby +Oh oh, oh oh +I'm in love with Judas, Judas +Oh oh, oh oh +I'm in love with Judas, Judas +In the most biblical sense, I am beyond repentance +Fame hooker, prostitute wench, vomits her mind +But in the cultural sense I just speak in future tense +Judas kiss me if offense, don't wear ear condom next time +I wanna love you +But something's pulling me away from you +Jesus is my virtue +And Judas is the demon I cling to, I cling to +Just a holy fool, oh baby it's so cruel +But I'm still in love with Judas, baby +I'm just a holy fool, oh baby it's so cruel +But I'm still in love with Judas, baby +Oh oh, oh oh +I'm in love with Judas, Judas +Oh oh, oh oh +I'm in love with Judas, Judas +Judas, Juda-a-a, Judas, Juda-a-a +Judas, Juda-a-a, Judas, Gaga diff --git a/public/canned/plan.txt b/public/canned/plan.txt new file mode 100644 index 0000000..0156962 --- /dev/null +++ b/public/canned/plan.txt @@ -0,0 +1,43 @@ +In my prison cell I think these words +I was careless +I can see that now +I must be silent +Must contain my secret smile +I want to tell you +You my mirror +You my iron bars + +When I made a shadow on my window shade +They called the police and testified +But they're like the people chained up in the cave +In the allegory of the people in the cave by the Greek guy + +No one understands +No one knows my plan +Why the dancing, shouting +Why the shrieks of pain +The lovely music +Why the smell of burning autumn leaves + +No one understands +No one knows my plan +Why the dancing, shouting +Why the shrieks of pain +The lovely music +Why the smell of burning autumn leaves + +In my prison cell I bide my time +Always thinking +Always busy cooking up an angle +Working on the tiny blueprint of the angle +Sketching out the burning autumn leaves + +No one understands +No one knows my plan +I must be silent, must contain my secret smile +I want to tell you +You my mirror +You my iron bars + +No one understands +No one knows my plan diff --git a/public/canned/spiderwebs.txt b/public/canned/spiderwebs.txt new file mode 100644 index 0000000..be596c2 --- /dev/null +++ b/public/canned/spiderwebs.txt @@ -0,0 +1,66 @@ +You think that we connect +That the chemistry's correct +Your words walk right through my ears +Presuming I likn what I hear +And now I'm stuck in the +The web you're spinning +You've got me for you prey + +Yeah Sorry I'm not home right now +I'm walking into spiderwebs +So leave a message +And I'll call you back +A likely story, but Yeah leave a message +And I'll call you back + +You're intruding on what's mine +And you're taking up my time +Don't have the courage inside me +To tell you please let me be + +Communication, a telephonic invasion +I'm planning my escape... + +Yeah Sorry I'm not home right now +I'm walking into spiderwebs +So leave a message +And I'll call you back +A likely story, but Yeah leave a message +And I'll call you back + +And it's all your fault +I screen my phone calls +No matter who calls +I gotta screen my phone calls + +Now it's gone to deep Now, it's gone too deep +You wake me in my sleep Wake me in my sleep +My dreams become nightmares Dreams become nightmares +'Cause you're ringing in my ears + +Yeah Sorry I'm not home right now +I'm walking into spiderwebs +So leave a message +And I'll call you back +A likely story, but Yeah leave a message +And I'll call you back + +And it's all your fault +I screen my phone calls +No matter-matter-matter-matter who calls +I gotta screen my phone calls + +Oooh, the spiderwebs +Leave a message and I'll call you back +I'm walking into spiderwebs +So, leave a message and I'll call you back +I'm walkink into spiderwebs +It's all your fault, no mattter who calls +I gotta screen my phone calls +It's all your fault, it's all your fault +No matter who calls, no matter who calls + +I'm walking into spiderwebs so, +Leave a message and I'll call you back +I'm walking into spiderwebs so, +Leave a message and I'll call you back \ No newline at end of file diff --git a/public/canned/theecchoinggreen.txt b/public/canned/theecchoinggreen.txt new file mode 100644 index 0000000..c1aeabd --- /dev/null +++ b/public/canned/theecchoinggreen.txt @@ -0,0 +1,32 @@ +The sun does arise, +And make happy the skies. +The merry bells ring +To welcome the Spring. +The sky-lark and thrush, +The birds of the bush, +Sing louder around, +To the bells’ cheerful sound. +While our sports shall be seen +On the Ecchoing Green. + +Old John, with white hair +Does laugh away care, +Sitting under the oak, +Among the old folk, +They laugh at our play, +And soon they all say. +‘Such, such were the joys. +When we all girls & boys, +In our youth-time were seen, +On the Ecchoing Green.’ + +Till the little ones weary +No more can be merry +The sun does descend, +And our sports have an end: +Round the laps of their mothers, +Many sisters and brothers, +Like birds in their nest, +Are ready for rest; +And sport no more seen, +On the darkening Green. diff --git a/public/canned/thelamb.txt b/public/canned/thelamb.txt new file mode 100644 index 0000000..2f0a5bc --- /dev/null +++ b/public/canned/thelamb.txt @@ -0,0 +1,21 @@ +Little Lamb, who made thee? +Dost thou know who made thee? +Gave thee life & bid thee feed +By the stream & o’er the mead; +Gave thee clothing of delight, +Softest clothing, wooly, bright; +Gave thee such a tender voice, +Making all the vales rejoice? +Little Lamb, who made thee? +Dost thou know who made thee? + +Little Lamb, I’ll tell thee, +Little Lamb, I’ll tell thee: +He is callèd by thy name, +For he calls himself a Lamb. +He is meek, & he is mild; +He became a little child. +I a child, & thou a lamb, +We are callèd by his name. +Little Lamb, God bless thee! +Little Lamb, God bless thee! diff --git a/public/canned/thepasture.txt b/public/canned/thepasture.txt new file mode 100644 index 0000000..964971f --- /dev/null +++ b/public/canned/thepasture.txt @@ -0,0 +1,9 @@ +I’m going out to clean the pasture spring; +I’ll only stop to rake the leaves away +(And wait to watch the water clear, I may): +I sha’n’t be gone long.—You come too. + +I’m going out to fetch the little calf +That’s standing by the mother. It’s so young, +It totters when she licks it with her tongue. +I sha’n’t be gone long.—You come too. diff --git a/public/canned/thetyger.txt b/public/canned/thetyger.txt new file mode 100644 index 0000000..a559443 --- /dev/null +++ b/public/canned/thetyger.txt @@ -0,0 +1,29 @@ +Tyger Tyger. burning bright, +In the forests of the night; +What immortal hand or eye. +Could frame thy fearful symmetry? + +In what distant deeps or skies. +Burnt the fire of thine eyes? +On what wings dare he aspire? +What the hand, dare sieze the fire? + +And what shoulder, & what art, +Could twist the sinews of thy heart? +And when thy heart began to beat. +What dread hand? & what dread feet? + +What the hammer? what the chain, +In what furnace was thy brain? +What the anvil? what dread grasp. +Dare its deadly terrors clasp! + +When the stars threw down their spears +And water'd heaven with their tears: +Did he smile his work to see? +Did he who made the Lamb make thee? + +Tyger Tyger burning bright. +In the forests of the night: +What immortal hand or eye. +Dare frame thy fearful symmetry? diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..5c125de Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..aab5e3b --- /dev/null +++ b/public/index.html @@ -0,0 +1,31 @@ + + + + + + + + React App + + +
+ + + diff --git a/src/.Songsim.js.swp b/src/.Songsim.js.swp new file mode 100644 index 0000000..66d7718 Binary files /dev/null and b/src/.Songsim.js.swp differ diff --git a/src/.utils.js.swp b/src/.utils.js.swp new file mode 100644 index 0000000..bdc49f0 Binary files /dev/null and b/src/.utils.js.swp differ diff --git a/src/App.css b/src/App.css new file mode 100644 index 0000000..15adfdc --- /dev/null +++ b/src/App.css @@ -0,0 +1,24 @@ +.App { + text-align: center; +} + +.App-logo { + animation: App-logo-spin infinite 20s linear; + height: 80px; +} + +.App-header { + background-color: #222; + height: 150px; + padding: 20px; + color: white; +} + +.App-intro { + font-size: large; +} + +@keyframes App-logo-spin { + from { transform: rotate(0deg); } + to { transform: rotate(360deg); } +} diff --git a/src/App.js b/src/App.js new file mode 100644 index 0000000..afd45ab --- /dev/null +++ b/src/App.js @@ -0,0 +1,23 @@ +import React, { Component } from 'react'; +import logo from './logo.svg'; +import './App.css'; +import Songsim from './Songsim.js'; + +class App extends Component { + render() { + return ( +
+
+ logo +

Welcome to React

+
+

+ To get started, edit src/App.js and save to reload. +

+ +
+ ); + } +} + +export default App; diff --git a/src/App.test.js b/src/App.test.js new file mode 100644 index 0000000..b84af98 --- /dev/null +++ b/src/App.test.js @@ -0,0 +1,8 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); +}); diff --git a/src/LyricsPane.js b/src/LyricsPane.js new file mode 100644 index 0000000..50ad977 --- /dev/null +++ b/src/LyricsPane.js @@ -0,0 +1,34 @@ +import React, { Component } from 'react'; +import Word from './Word.js'; + +class LyricsPane extends Component { + constructor(props) { + super(props); + } + + handleHover = (e) => { + + } + + renderWord = (word) => { + return (); + } + + renderLine = (line, idx) => { + var words = line.map(this.renderWord); + return

{words}

; + } + + render() { + var lines = this.props.verse.lines.map(this.renderLine); + return ( +
+ {lines} +
+ ); + } +} + +export default LyricsPane; diff --git a/src/Matrix.css b/src/Matrix.css new file mode 100644 index 0000000..32cae37 --- /dev/null +++ b/src/Matrix.css @@ -0,0 +1,3 @@ +rect.focused { + fill: yellow; +} diff --git a/src/Matrix.js b/src/Matrix.js new file mode 100644 index 0000000..fceb6de --- /dev/null +++ b/src/Matrix.js @@ -0,0 +1,76 @@ +import React, { Component } from 'react'; +import './Matrix.css'; + +class Matrix extends Component { + constructor(props) { + super(props); + this.H = 800; + this.W = 800; + this.state = {focused_diagonal: undefined}; + } + + handleClick = (e) => { + console.log(`Clicky click of type ${e.type}`); + } + + handleRectEnter = (e) => { + var rect = e.target; + var x = rect.x.baseVal.value, y = rect.y.baseVal.value; + // Extend selection along diagonal + var diag = this.getLocalDiagonal(x, y); + this.setState({focused_diagonal: diag}); + // Highlight local chunk + corresponding chunks on main diag ( + corresp chunks off main diag?) + // transmit up the chain + this.props.hover_cb([x, y]); + } + + handleRectLeave = (e) => { + this.props.hover_cb([]); + // Clear any highlighting + this.setState({focused_diagonal: undefined}); + } + + shouldHighlight(x, y) { + // TODO: fancier + var d = this.state.focused_diagonal; + if (!d) return false; + return (d.x0 <= x && x <= d.x1 && ((x - y) === (d.x0 - d.y0))); + } + + RectFromCoords(coords) { + var x = coords.x, y = coords.y; + var key = (x * this.props.matrix.length) + y; + // I don't quite get why the 1s need to be quoted? + return ( + ); + } + + render() { + /** Given text, compute self-similarity matrix + * naive drawing impl: for each x,y draw rect + */ + var rects = this.props.matrix.adjacency_list.map( + this.RectFromCoords.bind(this) + ); + var scale = this.H / this.props.matrix.length; + var scalestr = `scale(${scale})`; + return ( + + + {rects} + + + ); + } +} + +Matrix.propTypes = { + // foo: React.PropTypes.string +}; + +export default Matrix; diff --git a/src/SongSelector.js b/src/SongSelector.js new file mode 100644 index 0000000..6f67c54 --- /dev/null +++ b/src/SongSelector.js @@ -0,0 +1,36 @@ +import React, { Component } from 'react'; + +class SongSelector extends Component { + CANNED = [ + {fname: 'badromance.txt', artist: 'Lady Gaga', title: 'Bad Romance'}, + {fname: 'buddyholly.txt', artist: 'Weezer', title: 'Buddy Holly'}, + ] + + constructor(props) { + super(props); + } + + renderOption = (song) => { + return (); + } + + handleChange = (e) => { + var r = new XMLHttpRequest(); + var url = process.env.PUBLIC_URL + '/canned/' + e.target.value; + r.open('GET', url); + r.onload = () => { + this.props.onSelect(r.response); + }; + r.onerror = () => { console.log("uh oh"); }; + r.send(); + } + + render() { + return ( + ); + } +} + +export default SongSelector; diff --git a/src/Songsim.js b/src/Songsim.js new file mode 100644 index 0000000..3aa8014 --- /dev/null +++ b/src/Songsim.js @@ -0,0 +1,83 @@ +import React, { Component } from 'react'; + +import Matrix from './Matrix.js'; +import LyricsPane from './LyricsPane.js'; +import SongSelector from './SongSelector.js'; +import {VerseMatrix, Verse} from './verse.js'; +import {NOINDEX} from './constants.js'; +import {Diagonal} from './utils.js'; + +class Songsim extends Component { + constructor(props) { + super(props); + var text = "I never wanna hear you say\nThat I want it that way"; + this.state = {verse: new Verse(text), + matrix_focal: {x: NOINDEX, y: NOINDEX}, + lyrics_focal: NOINDEX, + }; + } + + onTextChange = (t) => { + this.setState({verse: new Verse(t)}); + } + + get focal_rect() { + console.assert(this.lyrics_focal === NOINDEX + || this.matrix_focal.x === NOINDEX, "Shouldn't both be set"); + if (this.lyrics_focal !== NOINDEX) { + return {x: this.lyrics_focal, y: this.lyrics_focal}; + } + return this.matrix_focal; + } + + get focal_rowcols() { + if (this.lyrics_focal !== NOINDEX) { + var thing = [this.lyrics_focal, this.lyrics_focal]; + return [thing, thing]; + } + if (this.matrix_focal.x !== NOINDEX) { + var diag = this.focal_local_diag; + return [diag.yrange, diag.xrange]; + } + return [undefined, undefined]; + } + + get focal_local_diag() { + if (this.matrix_focal.x === NOINDEX) { + return undefined; + } + var matrix = this.state.verse.matrix; + return matrix.local_diagonal(this.matrix_focal.x, this.matrix_focal.y); + } + + render() { + return ( +
+ +
+ +
+ this.setState({matrix_hover: coords})} + focal_rect={this.focal_rect} + focal_rows={this.focal_rows} + focal_cols={this.focal_cols} + focal_diags={this.focal_diags} + /> +
+ +
+ +
+ +
+
+ ); + } +} + +export default Songsim; diff --git a/src/Word.css b/src/Word.css new file mode 100644 index 0000000..9ed589d --- /dev/null +++ b/src/Word.css @@ -0,0 +1,7 @@ +span { + padding-right: .75ch; +} + +.focus { + color: crimson; +} diff --git a/src/Word.js b/src/Word.js new file mode 100644 index 0000000..c30a8e5 --- /dev/null +++ b/src/Word.js @@ -0,0 +1,18 @@ +import React, { Component } from 'react'; + +import './Word.css'; + + +class Word extends Component { + constructor(props) { + super(props); + } + + render() { + var kls = this.props.focus ? "focus" : ""; + return ({this.props.raw}); + } + +} + +export default Word; diff --git a/src/constants.js b/src/constants.js new file mode 100644 index 0000000..66451ab --- /dev/null +++ b/src/constants.js @@ -0,0 +1,4 @@ + +var NOINDEX = -1; + +export {NOINDEX}; diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..b4cc725 --- /dev/null +++ b/src/index.css @@ -0,0 +1,5 @@ +body { + margin: 0; + padding: 0; + font-family: sans-serif; +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..f0990fb --- /dev/null +++ b/src/index.js @@ -0,0 +1,12 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; +import './index.css'; + +import 'bootstrap/dist/css/bootstrap.css'; +import 'bootstrap/dist/css/bootstrap-theme.css'; + +ReactDOM.render( + , + document.getElementById('root') +); diff --git a/src/logo.svg b/src/logo.svg new file mode 100644 index 0000000..6b60c10 --- /dev/null +++ b/src/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 0000000..3c596bb --- /dev/null +++ b/src/utils.js @@ -0,0 +1,36 @@ + +class Diagonal { + + constructor(x0, y0, x1, y1) { + console.assert(x0 <= x1 && y0 <= y1); + this.x0 = x0; + this.y0 = y0; + this.x1 = x1; + this.y1 = y1; + } + + get xrange() { + return [this.x0, this.x1]; + } + + get yrange() { + return [this.y0, this.y1]; + } + + isMain() { + return this.x0 === this.y0; + } + + /** Return the two main diagonal correlates of this diagonal. + * (Or nothing, if this is part of the main diagonal) + */ + mainCorrelates() { + var correlates = []; + if (this.isMain()) return correlates; + + } + + +} + +export {Diagonal}; diff --git a/src/verse.js b/src/verse.js new file mode 100644 index 0000000..d103f59 --- /dev/null +++ b/src/verse.js @@ -0,0 +1,96 @@ +import {Diagonal} from './utils.js'; + +/** + * A chunk of text, presumably some kind of poem/song. + */ +class Verse { + constructor(text) { + this.parse(text); + } + + static cleanWord(word) { + // TODO: punctuation + return word.toLowerCase(); + } + + parse(text) { + // TODO: portable newlines? + var raw_words = []; + var clean_words = []; + var newlines = []; + for (const line of text.split("\n")) { + for (const word of line.trim().split(/\s+/)) { + raw_words.push(word); + clean_words.push(Verse.cleanWord(word)); + } + newlines.push(clean_words.length - 1); + } + this.raw_words = raw_words; + this.clean_words = clean_words; + this.newline_indices = newlines; + } + + get lines() { + var lines = [] + var i = 0; + for (const eol of this.newline_indices) { + var line = []; + // TODO: this is stupid, don't need a loop + for (; i <= eol; i++) { + line.push({i: i, raw: this.raw_words[i]}); + } + lines.push(line); + } + return lines; + } + + get matrix() { + return new VerseMatrix(this.clean_words); + } +} + +/** TODO: the naive approach here is probably wildly inefficient. + * Is there some js implementation of bitstrings I could use here? + */ +class VerseMatrix { + constructor(words) { + this.length = words.length; + this.adjacency_list = []; + for (var x=0; x < words.length; x++) { + for (var y=0; y < words.length; y++) { + // TODO: wasteful to include diagonal and both reflections off diag + if (words[x] == words[y]) { + this.adjacency_list.push({x, y}); + } + } + } + } + + at(x, y) { + // TODO: sooo unoptimized + return this.adjacency_list.some((pt) => { return pt.x == x && pt.y == y }); + } + + local_diagonal(x, y) { + var x0 = x, x1 = x; + var y0 = y, y1 = y; + // Don't do anything further if this point is on the main diagonal. + if (x !== y) { + // Probe up and left + for (let x_ = x, y_ = y; x_ >= 0 && y_ >= 0 && this.at(x_, y_); x_--, y_--) { + x0 = x_; + y0 = y_; + } + // Probe down and to the right + for (let x_ = x, y_ = y; x_ < this.length && y_ < this.length + && this.at(x_, y_); x_++, y_++) { + x1 = x_; + y1 = y_; + } + } + return new Diagonal(x0, y0, x1, y1); + } + +} + +export {Verse, VerseMatrix};