diff --git a/animation/main.js b/animation/animate.js similarity index 77% rename from animation/main.js rename to animation/animate.js index dee49bf..176c4af 100644 --- a/animation/main.js +++ b/animation/animate.js @@ -1,35 +1,3 @@ -// (function(){ - -// var color = "rgb(255,133,0)" -// var color = "rgb(55,110,79)" -var color="white" - -// var color = "rgb(255,221,21)" -// var color = '#'+(16777216+Math.floor(Math.random()*16777215)).toString(16).slice(1) -// document.styleSheets[0].insertRule("a {color: "+color+"}",0) - -var lasttime, - canvas = document.getElementById('canvas'), - ctx = canvas.getContext('2d'); - -// canvas.style['background-color'] = color; - -var logo = new Image(), logo_small = new Image() -logo.src = 'img/logo.png' -logo_small.src = 'img/logo.png' - - -// var pixelRatio = (function(context) { -// var backingStore = context.backingStorePixelRatio || -// context.webkitBackingStorePixelRatio || -// context.mozBackingStorePixelRatio || -// context.msBackingStorePixelRatio || -// context.oBackingStorePixelRatio || -// context.backingStorePixelRatio || 1; - -// return (window.devicePixelRatio || 1) / backingStore; -// })(ctx); - function app1(p,a,c1,c2){ var l = Math.cos(a)*p[c1]+Math.sin(a)*p[c2] var k = -Math.sin(a)*p[c1]+Math.cos(a)*p[c2] @@ -91,6 +59,40 @@ function project(point, size){ } } +// (function(){ + +// var color = "rgb(255,133,0)" +// var color = "rgb(55,110,79)" +var color="white" + +// var color = "rgb(255,221,21)" +// var color = '#'+(16777216+Math.floor(Math.random()*16777215)).toString(16).slice(1) +// document.styleSheets[0].insertRule("a {color: "+color+"}",0) + +var lasttime, + canvas = document.getElementById('canvas'), + ctx = canvas.getContext('2d'); + +// canvas.style['background-color'] = color; + +var logo = new Image(), logo_small = new Image() +logo.src = 'img/logo.png' +logo_small.src = 'img/logo.png' + + +// var pixelRatio = (function(context) { +// var backingStore = context.backingStorePixelRatio || +// context.webkitBackingStorePixelRatio || +// context.mozBackingStorePixelRatio || +// context.msBackingStorePixelRatio || +// context.oBackingStorePixelRatio || +// context.backingStorePixelRatio || 1; + +// return (window.devicePixelRatio || 1) / backingStore; +// })(ctx); + + + function init () { fixdim() @@ -99,16 +101,39 @@ function init () { } function fixdim() { - if(dimensions.update()){ - var displaywidth = Math.sqrt(dimensions.width)*18//dimensions.width > 900 ? 900 : 450 - var displayheight = displaywidth * 4/15//dimensions.width > 900 ? 250 : 125 - canvas.width = displaywidth*window.devicePixelRatio - canvas.style.width = displaywidth - canvas.height = displayheight*window.devicePixelRatio - canvas.style.height = displayheight - } + dimensions.update() + + var displaywidth = Math.sqrt(dimensions.width)*18//dimensions.width > 900 ? 900 : 450 + + var doc = document.documentElement; + var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); + var header = document.querySelector('.stickyheader') + + document.getElementById('logo').style.top = top /2 + var rect = document.querySelector('.marterial').getBoundingClientRect() + var bottom = rect.top + rect.height + + // console.log(bottom) + // if(bottom < 100){ + // document.getElementById('logo').style.left = bottom - 100 + // } + var fadestart = Math.min(rect.height/2, 100) + + header.style['background-color'] = 'rgba(0, 219, 157,'+Math.max(Math.min((-bottom+fadestart),1),0)+')' + header.querySelector('.smalllogo').style.opacity = Math.max(Math.min((-bottom+fadestart)*2/fadestart,1),0) + document.getElementById('logo').style.opacity = Math.max(Math.min((bottom-fadestart)/fadestart,1),0) + + + + var displayheight = displaywidth * 4/15//dimensions.width > 900 ? 250 : 125 + canvas.width = displaywidth*window.devicePixelRatio + canvas.style.width = displaywidth + canvas.height = displayheight*window.devicePixelRatio + canvas.style.height = displayheight } +addEventListener('scroll', fixdim) + function drawtesseract(tesseract, opts){ var edges = tesseractedges() for (var i = 0; i < tesseract.length; i++) { diff --git a/codemirror/codemirror.css b/codemirror/codemirror.css index 9cdc1f9..bd17494 100644 --- a/codemirror/codemirror.css +++ b/codemirror/codemirror.css @@ -115,7 +115,7 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {} .cm-s-default .cm-operator {} .cm-s-default .cm-variable-2 {color: #05a;} .cm-s-default .cm-variable-3 {color: #085;} -.cm-s-default .cm-comment {color: #a50;} +.cm-s-default .cm-comment {color: #DB0000;} .cm-s-default .cm-string {color: #5426C9;} .cm-s-default .cm-string-2 {color: #f50;} .cm-s-default .cm-meta {color: #555;} diff --git a/css/color.css b/css/color.css deleted file mode 100644 index 66d181f..0000000 --- a/css/color.css +++ /dev/null @@ -1,93 +0,0 @@ -#wow { -} - -#splash { - /*border-bottom: solid 1px #ddd;*/ - /*background-color: #222*/ -} - -.desc { - /* text-shadow: 0px 0px 2px rgba(0, 131, 255, 0.53); */ -} - -.headernav { -} - -.vr { -} - -/*.ellipsis { - background-color: rgb(58, 51, 60); - color: white; - padding: 3px; - border-radius: 2px; - -}*/ - - -.getStarted { -} - - -.npm { -} - - - -#marterial { - /*background: linear-gradient(#27C6F9 80%, #0CB5EB 100%);*/ - /*background-attachment: fixed;*/ -} -.demoheader .CodeMirror { -} -.runbutton { -} - - - -.demo { - -} - -.hint { - -} - -body { -} - -hr { - -} - -a { -} - -.manyLanguages { - /*color: #C8D1F3;*/ -} - -button { - -} - -button:hover { -} - -@media (max-width: 914px) { - - button:hover { - background: rgba(255,255,255,.3); - border: solid 1px #fff; - } - - .desc { - color: #FFFFFF; - text-shadow: 0px 0px 3px rgba(58, 58, 58, 1); - } - - - /*#splash { - background-color: #27C6F9; - }*/ -} \ No newline at end of file diff --git a/css/explorer.css b/css/explorer.css index 952dce6..72ee3c9 100644 --- a/css/explorer.css +++ b/css/explorer.css @@ -1,22 +1,14 @@ #explorer { - max-width: 500px; max-height: 500px; white-space: nowrap; overflow: scroll; padding: 10px; - - border: 1px solid #eee; + /*border: 1px solid #eee;*/ border-radius: 5px; font-family: monospace; - + background-color: #fff; } -@media (max-width: 914px) { - #explorer { - margin: 8%; - - } -} .textNode { display: inline-block; diff --git a/css/wau.css b/css/wau.css index e41ff81..02d6123 100644 --- a/css/wau.css +++ b/css/wau.css @@ -3,24 +3,93 @@ width: 100%; min-height: 100%; } + + + +.stretch { + max-width: 100% +} + +.langpair { + display: inline-block; + padding: -1px; + font-family: monospace; + text-align: center; + /*border: 1px solid #F3F3F3;*/ + margin-bottom: 10px; + margin-right: 5px; + font-size: initial; + line-height: 1.5em; + flex-grow:1; +} +.footer { + width: 100%; + color: #fff; + margin-top: 8%; + background-color: #6A6A6A; + text-align: right; +} +.lengle { + margin-top: 8%; + margin-bottom: 8%; + + line-height: normal; + display: inline-block; + vertical-align: middle; +} + +.shortlang { + /*background-color: #FFEEAE;*/ +} + +.longlang { + background-color: #59C6FF; + color:#fff; + padding-left: 5px; + padding-right: 5px; + border-radius: 3px; +} +.explorersection{ + background-color: rgb(255, 238, 174); + width: 100%; + padding-top: 8%; + padding-bottom: 8%; +} +.noheight{ + height: 0; +} +.columnwrap { + max-width: 1100; + margin-left: auto; + margin-right: auto; +} +.column { + padding-left: 8%; + padding-right: 8%; +} +.smalllogo { + height: 50px; + vertical-align: middle; + position: absolute; + left: 3%; + opacity: 0; +} .stickyheader { position: fixed; width: 100%; z-index: 3; - height: 50px; - vertical-align: middle; text-align: right; line-height: 50px; + background-color: #00DB9D; } .headernav { - padding-right: 35px; - vertical-align: middle; + padding-right: 3%; color: #fff; } .run, .running { width: 100%; - height: 42px; + height: 47px; text-align: center; } .running { @@ -63,10 +132,9 @@ a { svg { height: 100% } -#marterial { - position: absolute; +.marterial { + /*position: absolute;*/ width: 100%; - height: 330px; z-index: -1; overflow: hidden; background-color: #00DB9D; @@ -91,13 +159,15 @@ svg { flex-grow: 1; height: 40px; line-height: 40px; + + cursor: pointer; color: #fff; background-color: #6A6A6A; } .selected { background-color: #00DB9D; - font-weight: bold; + /*font-weight: bold;*/ } .bookend { @@ -115,6 +185,7 @@ svg { text-align: center; /*display: flex*/ } + #wow .demofooter { display: flex; padding: 0px; @@ -123,26 +194,40 @@ svg { } #logo { text-align: center; - padding-top: 70px; + margin-top: 8%; + margin-bottom: 8%; height: 182px; + position: relative; + /*z-index: 4;*/ } .to_ocr { width: 100%; } -#wow { - margin-top: 25px; -} + .demo { border-radius: 5px; width: 500px; max-width: 100%; text-align: left; + top:-50px; overflow: hidden; - box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, .2); + box-shadow: 0px 40px 60px 10px rgba(0, 0, 0, .2); position: relative; background-color: #f3f3f3; + opacity: 1; + -webkit-transition: .7s ease-out; + -moz-transition: .7s ease-out; + -ms-transition: .7s ease-out; + -o-transition: .7s ease-out; + transition: .7s ease-out; } + +/*.opaque { + top:-30; + box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, .2); +}*/ + .demoheader { overflow: hidden; border-radius: 5px 5px 0px 0px; @@ -156,10 +241,7 @@ svg { background-image: url(../img/logowhite.png); background-size: cover; } -#splash { - text-align: center; - position: relative; -} + .desc { text-align: left; font-size: 18px; @@ -168,7 +250,7 @@ svg { .vr { display: inline-block; height: 40px; - border-left: 1px solid #ddd; + border-left: 1px solid #5C5C5C; } .getStarted { display: inline-block; @@ -182,13 +264,9 @@ svg { padding-right: 50px; cursor: pointer; } -#notconvinced { - max-width: 960; - margin-left: auto; - margin-right: auto; - margin-top: 8%; -} -.randombold { + +.randombold + { font-size: 18px; /*font-family: Georgia;*/ @@ -202,11 +280,12 @@ svg { .npm { margin-top: 20px; padding-left: 15px; - background-color: rgb(255, 238, 174); + background-color: #F3F3F3; + border-radius: 5px; margin-bottom: 0px; padding-top: 10px; padding-bottom: 10px; - border-left: 10px solid #303061; + border-left: 6px solid #303061; color: rgb(48, 48, 97); font-size: 19px; font-family: monospace; @@ -220,9 +299,9 @@ svg { text-align: center; width: 335px; border-radius: 5px; - margin-right: 40px; - margin-left: 40px; - margin-top: 120px; + margin-top: 80px; + margin-bottom: 80px; + max-width: 100%; } .woloasdf { padding-top: 8%; @@ -241,14 +320,11 @@ svg { width: 100%; display: flex; flex-wrap: wrap; - justify-content: space-around; + justify-content: space-between; max-width: 1100px; margin-left: auto; margin-right: auto; } -#two { - margin-bottom: 8%; -} .demoheader .CodeMirror { padding-bottom: 9px; padding-top: 9px; @@ -260,13 +336,13 @@ hr { border-top: 1px solid #ddd; margin: 0px; } -#ocroutput { +.ocroutput { position: relative; + z-index: 2; } -.manyLanguages { - font-size: 7px; - padding-top: 10px; - opacity: .3; +.manylangs{ + display: flex; + flex-wrap: wrap; } body { padding: 0px; @@ -296,31 +372,35 @@ button:hover { background: rgba(255, 255, 255, 1); border: solid 1px #ddd; } -@media (max-width: 914px) { +@media (max-width: 1015px) { button { color: #fff; background-color: rgba(0, 0, 0, 0) } - .desc { +/* .desc { color: #FFFFFF; text-shadow: 0px 0px 3px rgba(58, 58, 58, 1); } .desc a { - color: #B8EEFF; + color: #FFEEAE; } - .npm { - box-shadow: 0px 0px 20px 4px rgb(180, 146, 150); +*/ + .getStarted { + font-size: 33px; } - #logo { - padding-top: 8%; + .noheight { height: auto; } - #marterial { - height: 100%; - } .demo { - margin-right: 8%; - margin-left: 8%; + top:0; + margin-bottom: 20px; + box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, .2); + } + #logo { + height: auto; + } + .two { + justify-content: space-around; } #code { margin-top: 20px; diff --git a/img/chi_sim.png b/img/chi_sim.png new file mode 100644 index 0000000..184d067 Binary files /dev/null and b/img/chi_sim.png differ diff --git a/img/chinese.png b/img/chinese.png deleted file mode 100644 index 84b663d..0000000 Binary files a/img/chinese.png and /dev/null differ diff --git a/img/poem.png b/img/eng.png similarity index 100% rename from img/poem.png rename to img/eng.png diff --git a/img/redstars.png b/img/redstars.png new file mode 100644 index 0000000..4d7737d Binary files /dev/null and b/img/redstars.png differ diff --git a/img/rus.png b/img/rus.png new file mode 100644 index 0000000..992cd51 Binary files /dev/null and b/img/rus.png differ diff --git a/img/tha.png b/img/tha.png new file mode 100644 index 0000000..11ec9e1 Binary files /dev/null and b/img/tha.png differ diff --git a/index.html b/index.html index fac84d7..5d96ae7 100644 --- a/index.html +++ b/index.html @@ -12,170 +12,125 @@ - + + + + +
+ -
-
- - - -
- -
-
- Tesseract.js is a pure javascript version of the Tesseract OCR Engine - that can recognize - English, - Chinese, - Russian, - Meme, and 60 other languages. - - -
- -
- Get Started +
+ + + +
+
+
+ - -
-
-
-
-
-
- Hint: you can, like, edit this code yo -
-
-
Initializing Magic...
-
-
-
Run Code
-
- - - - -
-
-
English
-
Chinese
-
Russian
-
Meme
+
+
+
+
+
+
+
+ Hint: you can, like, edit this code yo +
+
+
Initializing Magic...
+ +
+
+
Run Code
+
+ +
+ + + +
+
+
English
+
Chinese
+
Russian
+
Meme
+
+
-
-
+ +
-
-
The output of the demo will magically appear here :)
+ --> +
+
+
-
+ +
The output of the demo will magically appear here :)
+
-
- - -
-
npm install tesseract.js
- - -
<script src="https://cdn.rawgit.com/naptha/tesseract.js/master/lib/Tesseract.2015.07.25.v0.js"></script>
-
+
+
-
- "Last time I got here, before I even arrived, they had ‘fuck Kanye’ on the motherfuckin’ port-a-potties. But this year, we gon’ piss on ‘em, on they motherfuckin’ port-a-potties. How many of y'all don't give a fuck about what the press say? It's 2014. College Dropout came out 2004. I want y'all to know, every time I go to the studio, every time I do an interview, every time I make a motherfuckin' t-shirt, the thing I do, I give it everything I got. And when I talk that shit, it's so that you can talk that shit. If you a fan of me, you a fan of your motherfuckin' self. You can do something that'll change the world. Look at how they try to make me look. They try to make me look crazy.", - "I need a new cool. What's the new shit out? What's the new shit out with the most commercials at the Super Bowl? Let's just stop the music and play a Bruno Mars song right now, how about that? They told me I would never play at the Super Bowl. They told me I could never play at the Super Bowl. Not until I'm super old. Not until I'm super old... They told me I would never play at the Super Bowl. They told me I would never play at the Super Bowl, at least not until I'm super old. So I think it's time–hold up, f—k that toast.", - "I know people get mad at me when I compare myself, but that's the only way I can explain what my aspirations are. When I'm talkin' 'bout Walt Disney, when I'm talkin' 'bout Howard Hughes, when I'm talkin' 'bout Henry Ford, when I'm talkin' 'bout Beethoven, when I talk about Mozart, when I talk about Shakespeare, and they all had their time on this earth. And I'm only 37. And right now I'm rockin' to 90,000, of y'all motherfuckers right now. So I ain't goin' at anybody on the radio. I'm goin' after Shakespeare. I'm goin' after Walt Disney. I'm going after Howard Hughes. I'm going after David Stern. I'm goin' after Henry Ford. I'm going after Elon Musk. Okay, he is living, but he's my boy.", +
+

Such Docs

+

Installation

+
npm install tesseract.js
+ +
<script src="https://cdn.rawgit.com/naptha/tesseract.js/master/lib/Tesseract.2015.07.26.js"></script>
+

Methods

+

Tesseract.recognize( img [, callback(err,result)] )

+ Go Kevin! You can write this! +

Tesseract.detect( img [, callback(err,result)] )

+ Go Kevin! You can write this! +

Supported Languages

+
+
eng
Enlish
chi_sim
Chinese
rus
Rusian
tha
Meme
deu
German
jpn
Japanese
spa
Spanish
fra
French
chi_tra
Traditional Chinese
por
Portuguese
ita
Italian
pol
Polish
tur
Turkish
nld
Dutch
ara
Arabic
ces
Czech
kor
Korean
swe
Swedish
vie
Vietnamese
ron
Romanian
ell
Greek
ind
Indonesian
hun
Hungarian
dan
Danish
bul
Bulgarian
fin
Finnish
nor
Norwegian
ukr
Ukrainian
cat
Catalan
hrv
Croatian
heb
Hebrew
lit
Lithuanian
slv
Slovenian
hin
Hindi
ben
Bengali
tel
Telugu
tam
Tamil
kan
Kannada
mal
Malayalam
tgl
Tagalog
swa
Swahili
aze
Azerbaijani
bel
Belarusian
afr
Afrikaans
sqi
Albanian
eus
Basque
epo
Esperanto
est
Estonian
glg
Galician
isl
Icelandic
lav
Latvian
mkd
Macedonian
msa
Malay
mlt
Maltese
grc
Ancient Greek
chr
Cherokee
enm
English (Old)
epo_alt
Esperanto alternative
frk
Frankish
frm
French (Old)
ita_old
Italian (Old)
equ
Math
srp
Serbian (Latin)
slk
Slovakian
spa_old
Old Spanish
+
@@ -183,15 +138,22 @@ + - + - + diff --git a/index_dev.html b/index_dev.html new file mode 100644 index 0000000..a7b0ffc --- /dev/null +++ b/index_dev.html @@ -0,0 +1,160 @@ + + + Wau Demo + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+
+
+
+
+
+ Tesseract.js is a pure javascript version of the Tesseract OCR Engine + that can recognize + English, + Chinese, + Russian, + Meme, and 60 other languages. + + +
+ +
+ Get Started +
+
+
+
+
+
+
+
+
+
+
+ Hint: you can, like, edit this code yo +
+
+
Initializing Magic...
+ +
+
+
Run Code
+
+ +
+ + + +
+
+
English
+
Chinese
+
Russian
+
Meme
+
+
+
+
+
+
+ + + +
+
+
+ + + +
The output of the demo will magically appear here :)
+ +
+ +
+
+
+ + + + +
+

Such Docs

+

Installation

+
npm install tesseract.js
+ +
<script src="http://localhost:1234/master/lib/Tesseract_dev.js"></script>
+

Methods

+

Tesseract.recognize( img [, callback(err,result)] )

+ Go Kevin! You can write this! +

Tesseract.detect( img [, callback(err,result)] )

+ Go Kevin! You can write this! +

Supported Languages

+
+
eng
Enlish
chi_sim
Chinese
rus
Rusian
tha
Meme
deu
German
jpn
Japanese
spa
Spanish
fra
French
chi_tra
Traditional Chinese
por
Portuguese
ita
Italian
pol
Polish
tur
Turkish
nld
Dutch
ara
Arabic
ces
Czech
kor
Korean
swe
Swedish
vie
Vietnamese
ron
Romanian
ell
Greek
ind
Indonesian
hun
Hungarian
dan
Danish
bul
Bulgarian
fin
Finnish
nor
Norwegian
ukr
Ukrainian
cat
Catalan
hrv
Croatian
heb
Hebrew
lit
Lithuanian
slv
Slovenian
hin
Hindi
ben
Bengali
tel
Telugu
tam
Tamil
kan
Kannada
mal
Malayalam
tgl
Tagalog
swa
Swahili
aze
Azerbaijani
bel
Belarusian
afr
Afrikaans
sqi
Albanian
eus
Basque
epo
Esperanto
est
Estonian
glg
Galician
isl
Icelandic
lav
Latvian
mkd
Macedonian
msa
Malay
mlt
Maltese
grc
Ancient Greek
chr
Cherokee
enm
English (Old)
epo_alt
Esperanto alternative
frk
Frankish
frm
French (Old)
ita_old
Italian (Old)
equ
Math
srp
Serbian (Latin)
slk
Slovakian
spa_old
Old Spanish
+
+ +
+
+ + + + + + + + + + + + + + + + diff --git a/main.js b/main.js index 25f978f..bb38d2c 100644 --- a/main.js +++ b/main.js @@ -1,193 +1,229 @@ function builddemo(id, val){ - var demo = document.getElementById(id) - var prog = demo.querySelector('.prog') - var out = demo.querySelector('.out') - - var disp = demo.querySelector('.display') - var dctx = disp.getContext('2d') - disp.width = 0 - disp.height = 0 - - demo.querySelector('.runbutton').onclick = function(){ - setrunning(0) - run(editor) - } - - function show_progress(p){ - - setrunning(0) - console.log(p) - if(p.loaded_lang_model) prog.value = p.loaded_lang_model - if(p.recognized) prog.value = p.recognized - out.innerText = JSON.stringify(p) - out.innerText = JSON.stringify(p) - - } - - function setrunning(v){ - if (v == 1) { - demo.querySelector('.running').style.display = 'none' - demo.querySelector('.notrunning').style.display = 'block' - // out.style.visibility = 'hidden' - } - else { - demo.querySelector('.running').style.display = 'block' - demo.querySelector('.notrunning').style.display = 'none' - } - } - - function display(result) { - - React.render(React.createElement(Node, { node: result, expanded: true, label: "output_of_above_demo"}), document.getElementById("explorer")); - - setrunning(1) - - out.innerText = "Lightning Speeeeeeed" - prog.value = 0 - - console.log(result) - - disp.width = demo.querySelector('.to_ocr').naturalWidth - disp.height = demo.querySelector('.to_ocr').naturalHeight - - disp.style.width = demo.querySelector('.to_ocr').offsetWidth - disp.style.height = demo.querySelector('.to_ocr').offsetHeight - - - dctx.shadowColor = "rgba(255,255,255,.1)" - dctx.shadowOffsetX = 0; - dctx.shadowOffsetY = 0; - dctx.shadowBlur = 10; - - dctx.fillRect(0,0,disp.width, disp.height) - - var m = result.words.map(function(w){ - - var b = w.bbox - dctx.font = '20px Times' - var font = 20*(b.x1-b.x0)/dctx.measureText(w.text).width+"px Times" - - - var k = function(){ - dctx.font = font - dctx.fillText(w.text, b.x0, w.baseline.y0); - return font - } - - return k - }) - - var times = 0 - var maxtimes = m.length + 100 - function draw(i){ - - times++ - dctx.fillStyle="rgba(30, 29, 49, .8)" - dctx.fillStyle="#00DB9D" - // dctx.globalAlpha = .1; - dctx.clearRect(0,0,disp.width, disp.height) - dctx.fillRect(0,0,disp.width, disp.height) - - for (var j = 0; j < Math.min(i,m.length); j++) { - var asdf = Math.min(Math.max(i - j,0), 100) - dctx.fillStyle = "rgba(255,255,255,"+asdf*.01+")" - m[j]() - }; - - if(i', {name: 'xml', htmlMode: true}, scdiv) - - // var scripttag = CodeMirror(,{ - // mode: {name: 'xml', htmlMode: true}, - // readOnly: 'nocursor', - // value: - // }); - - - return { - - run: function(){ - var img = demo.querySelector('.to_ocr') - - if (img.complete) { - run(editor) - } else{ - img.onload = function(){ - run(editor) - } - } - - } - } + var demo = document.getElementById(id) + var prog = demo.querySelector('.prog') + var out = demo.querySelector('.out') + + var disp = demo.querySelector('.display') + var dctx = disp.getContext('2d') + disp.width = 0 + disp.height = 0 + + demo.querySelector('.runbutton').onclick = function(){ + setrunning(0) + run(editor) + } + + function show_progress(p){ + + setrunning(0) + console.log(p) + if(p.loaded_lang_model) prog.value = p.loaded_lang_model + if(p.recognized) prog.value = p.recognized + out.innerText = JSON.stringify(p) + out.innerText = JSON.stringify(p) + + } + + function setrunning(v){ + if (v == 1) { + demo.querySelector('.running').style.display = 'none' + demo.querySelector('.notrunning').style.display = 'block' + // out.style.visibility = 'hidden' + } + else { + demo.querySelector('.running').style.display = 'block' + demo.querySelector('.notrunning').style.display = 'none' + } + } + + function display(result) { + + React.render(React.createElement(Node, { node: result, expanded: true, label: "output_of_above_demo_plz_click_stuff"}), document.getElementById("explorer")); + + setrunning(1) + + out.innerText = "Lightning Speeeeeeed" + prog.value = 0 + + console.log(result) + + disp.width = demo.querySelector('.to_ocr').naturalWidth + disp.height = demo.querySelector('.to_ocr').naturalHeight + + disp.style.width = demo.querySelector('.to_ocr').offsetWidth + disp.style.height = demo.querySelector('.to_ocr').offsetHeight + + + dctx.shadowColor = "rgba(255,255,255,.1)" + dctx.shadowOffsetX = 0; + dctx.shadowOffsetY = 0; + dctx.shadowBlur = 10; + + dctx.fillRect(0,0,disp.width, disp.height) + + var m = result.words.map(function(w){ + + var b = w.bbox + dctx.font = '20px Times' + var font = 20*(b.x1-b.x0)/dctx.measureText(w.text).width+"px Times" + + + var k = function(){ + dctx.font = font + dctx.fillText(w.text, b.x0, w.baseline.y0); + return font + } + + return k + }) + + var times = 0 + var maxtimes = m.length + 100 + function draw(i){ + + times++ + // dctx.fillStyle="rgba(30, 29, 49, .8)" + dctx.fillStyle="rgba(0, 219, 157, "+Math.min(i/100,1)+")" + // dctx.globalAlpha = .1; + dctx.clearRect(0,0,disp.width, disp.height) + dctx.fillRect(0,0,disp.width, disp.height) + + for (var j = 0; j < Math.min(i,m.length); j++) { + var asdf = Math.min(Math.max(i - j,0), 100) + dctx.fillStyle = "rgba(255,255,255,"+asdf*.01+")" + m[j]() + }; + + if(i', { + name: 'xml', + htmlMode: true + }, scdiv) + + // var scripttag = CodeMirror(,{ + // mode: {name: 'xml', htmlMode: true}, + // readOnly: 'nocursor', + // value: + // }); + editor.clear = function(){ + dctx.clearRect(0,0,disp.width, disp.height) + document.querySelector('.ocroutput').innerHTML = '' + + } + + editor.img = demo.querySelector('.to_ocr') + + editor.run = function(){ + + if (editor.img.complete) { + run(editor) + } else{ + editor.img.onload = function(){ + run(editor) + } + } + } + + return editor } -builddemo('wow', +setTimeout(function(){ + document.getElementById('wow').className += ' opaque' +}, 100) + +var wow = builddemo('wow', "var img = demo.querySelector('img.to_ocr')\n\n\ Tesseract\n\ - .recognize( img, {progress: show_progress} )\n\ - .then( display )") -.run() - -addEventListener('scroll', function(e){ - //frum jcurry - var doc = document.documentElement; - var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); - if(top >= 227) { - document.querySelector('.stickyheader').style['background-color'] = '#00DB9D' - } - else { - document.querySelector('.stickyheader').style['background-color'] = 'rgba(0,0,0,0)' - } + .recognize( img, {\n\ + progress: show_progress} )\n\ + .then( display ) // scroll down for full output ") + +wow.run() + + +var tabs = Array.prototype.slice.call(document.querySelectorAll('.langlabel')) +var ltabs = Array.prototype.slice.call(document.querySelectorAll('.ltab')) +var langs = ['eng', 'chi_sim', 'rus', 'tha'] + +function setlang(i){ + tabs.forEach(function(t){ + t.className = 'langlabel' + }) + tabs[i].className = 'langlabel selected' + console.log(tabs[i]) + wow.setValue( + "var img = demo.querySelector('img.to_ocr')\n\n" + +"Tesseract\n" + +" .recognize( img, {\n" + +" progress: show_progress, lang: '"+langs[i]+"'} )\n" + +" .then( display ) // scroll down for full output ") + wow.img.src = 'img/'+langs[i]+'.png' + wow.clear() + +} + + +ltabs.forEach(function(ltab,i){ + ltab.onclick = function(){ + setlang(i) + } }) + +tabs.forEach(function(tab,i){ + tab.onclick = function(){ + setlang(i) + } +}) // document.querySelector('.getStarted')[0].onclick = function(){ -// location.href = '#' -// location.href = '#get_started' +// location.href = '#' +// location.href = '#get_started' // } // builddemo('demo2', diff --git a/main_dev.js b/main_dev.js new file mode 100644 index 0000000..c971bd4 --- /dev/null +++ b/main_dev.js @@ -0,0 +1,233 @@ +function builddemo(id, val){ + var demo = document.getElementById(id) + var prog = demo.querySelector('.prog') + var out = demo.querySelector('.out') + + var disp = demo.querySelector('.display') + var dctx = disp.getContext('2d') + disp.width = 0 + disp.height = 0 + + demo.querySelector('.runbutton').onclick = function(){ + setrunning(0) + run(editor) + } + + function show_progress(p){ + + setrunning(0) + console.log(p) + if(p.loaded_lang_model) prog.value = p.loaded_lang_model + if(p.recognized) prog.value = p.recognized + out.innerText = JSON.stringify(p) + out.innerText = JSON.stringify(p) + + } + + function setrunning(v){ + if (v == 1) { + demo.querySelector('.running').style.display = 'none' + demo.querySelector('.notrunning').style.display = 'block' + // out.style.visibility = 'hidden' + } + else { + demo.querySelector('.running').style.display = 'block' + demo.querySelector('.notrunning').style.display = 'none' + } + } + + function display(result) { + + React.render(React.createElement(Node, { node: result, expanded: true, label: "output_of_above_demo_plz_click_stuff"}), document.getElementById("explorer")); + + setrunning(1) + + out.innerText = "Lightning Speeeeeeed" + prog.value = 0 + + console.log(result) + + disp.width = demo.querySelector('.to_ocr').naturalWidth + disp.height = demo.querySelector('.to_ocr').naturalHeight + + disp.style.width = demo.querySelector('.to_ocr').offsetWidth + disp.style.height = demo.querySelector('.to_ocr').offsetHeight + + + dctx.shadowColor = "rgba(255,255,255,.1)" + dctx.shadowOffsetX = 0; + dctx.shadowOffsetY = 0; + dctx.shadowBlur = 10; + + dctx.fillRect(0,0,disp.width, disp.height) + + var m = result.words.map(function(w){ + + var b = w.bbox + dctx.font = '20px Times' + var font = 20*(b.x1-b.x0)/dctx.measureText(w.text).width+"px Times" + + + var k = function(){ + dctx.font = font + dctx.fillText(w.text, b.x0, w.baseline.y0); + return font + } + + return k + }) + + var times = 0 + var maxtimes = m.length + 100 + function draw(i){ + + times++ + // dctx.fillStyle="rgba(30, 29, 49, .8)" + dctx.fillStyle="rgba(0, 219, 157, "+Math.min(i/100,1)+")" + // dctx.globalAlpha = .1; + dctx.clearRect(0,0,disp.width, disp.height) + dctx.fillRect(0,0,disp.width, disp.height) + + for (var j = 0; j < Math.min(i,m.length); j++) { + var asdf = Math.min(Math.max(i - j,0), 100) + dctx.fillStyle = "rgba(255,255,255,"+asdf*.01+")" + m[j]() + }; + + if(i', { + name: 'xml', + htmlMode: true + }, scdiv) + + // var scripttag = CodeMirror(,{ + // mode: {name: 'xml', htmlMode: true}, + // readOnly: 'nocursor', + // value: + // }); + editor.clear = function(){ + dctx.clearRect(0,0,disp.width, disp.height) + document.querySelector('.ocroutput').innerHTML = '' + + } + + editor.img = demo.querySelector('.to_ocr') + + editor.run = function(){ + + if (editor.img.complete) { + run(editor) + } else{ + editor.img.onload = function(){ + run(editor) + } + } + } + + return editor +} + +setTimeout(function(){ + document.getElementById('wow').className += ' opaque' +}, 100) + +var wow = builddemo('wow', +"var img = demo.querySelector('img.to_ocr')\n\n\ +Tesseract\n\ + .recognize( img, {\n\ + progress: show_progress} )\n\ + .then( display ) // scroll down for full output ") + +wow.run() + + +var tabs = Array.prototype.slice.call(document.querySelectorAll('.langlabel')) +var ltabs = Array.prototype.slice.call(document.querySelectorAll('.ltab')) +var langs = ['eng', 'chi_sim', 'rus', 'tha'] + +function setlang(i){ + tabs.forEach(function(t){ + t.className = 'langlabel' + }) + tabs[i].className = 'langlabel selected' + console.log(tabs[i]) + wow.setValue( + "var img = demo.querySelector('img.to_ocr')\n\n" + +"Tesseract\n" + +" .recognize( img, {\n" + +" progress: show_progress, lang: '"+langs[i]+"'} )\n" + +" .then( display ) // scroll down for full output ") + wow.img.src = 'img/'+langs[i]+'.png' + wow.clear() + +} + + +ltabs.forEach(function(ltab,i){ + ltab.onclick = function(){ + setlang(i) + } +}) + + +tabs.forEach(function(tab,i){ + tab.onclick = function(){ + setlang(i) + } +}) +// document.querySelector('.getStarted')[0].onclick = function(){ +// location.href = '#' +// location.href = '#get_started' +// } + +// builddemo('demo2', +// "var img = demo.querySelector('img.to_ocr')\n\n\ +// Tesseract\n\ +// .recognize( img, {progress: show_progress, lang:'chi_sim'} )\n\ +// .then( display )") diff --git a/explorer_src/explorer.js b/src/explorer.js similarity index 100% rename from explorer_src/explorer.js rename to src/explorer.js diff --git a/src/index.html b/src/index.html index 105be5b..5db34cb 100644 --- a/src/index.html +++ b/src/index.html @@ -12,170 +12,125 @@ - + + + + +
+ -
-
- - - -
- -
-
- Tesseract.js is a pure javascript version of the Tesseract OCR Engine - that can recognize - English, - Chinese, - Russian, - Meme, and 60 other languages. - - -
- -
- Get Started +
+ + + +
+
+
+ - -
-
-
-
-
-
- Hint: you can, like, edit this code yo -
-
-
Initializing Magic...
- -
-
-
Run Code
- - - - -
-
-
English
-
Chinese
-
Russian
-
Meme
+
+
+
+
+
+
+
+ Hint: you can, like, edit this code yo +
+
+
Initializing Magic...
+ +
+
+
Run Code
+
+ +
+ + + +
+
+
English
+
Chinese
+
Russian
+
Meme
+
+
-
-
+ +
-
-
The output of the demo will magically appear here :)
+ --> +
+
+
-
+ +
The output of the demo will magically appear here :)
+
-
- - -
-
npm install tesseract.js
- - -
<script src="__tesseractjs__"></script>
-
+
+
-
- "Last time I got here, before I even arrived, they had ‘fuck Kanye’ on the motherfuckin’ port-a-potties. But this year, we gon’ piss on ‘em, on they motherfuckin’ port-a-potties. How many of y'all don't give a fuck about what the press say? It's 2014. College Dropout came out 2004. I want y'all to know, every time I go to the studio, every time I do an interview, every time I make a motherfuckin' t-shirt, the thing I do, I give it everything I got. And when I talk that shit, it's so that you can talk that shit. If you a fan of me, you a fan of your motherfuckin' self. You can do something that'll change the world. Look at how they try to make me look. They try to make me look crazy.", - "I need a new cool. What's the new shit out? What's the new shit out with the most commercials at the Super Bowl? Let's just stop the music and play a Bruno Mars song right now, how about that? They told me I would never play at the Super Bowl. They told me I could never play at the Super Bowl. Not until I'm super old. Not until I'm super old... They told me I would never play at the Super Bowl. They told me I would never play at the Super Bowl, at least not until I'm super old. So I think it's time–hold up, f—k that toast.", - "I know people get mad at me when I compare myself, but that's the only way I can explain what my aspirations are. When I'm talkin' 'bout Walt Disney, when I'm talkin' 'bout Howard Hughes, when I'm talkin' 'bout Henry Ford, when I'm talkin' 'bout Beethoven, when I talk about Mozart, when I talk about Shakespeare, and they all had their time on this earth. And I'm only 37. And right now I'm rockin' to 90,000, of y'all motherfuckers right now. So I ain't goin' at anybody on the radio. I'm goin' after Shakespeare. I'm goin' after Walt Disney. I'm going after Howard Hughes. I'm going after David Stern. I'm goin' after Henry Ford. I'm going after Elon Musk. Okay, he is living, but he's my boy.", +
+

Such Docs

+

Installation

+
npm install tesseract.js
+ +
<script src="__tesseractjs__"></script>
+

Methods

+

Tesseract.recognize( img [, callback(err,result)] )

+ Go Kevin! You can write this! +

Tesseract.detect( img [, callback(err,result)] )

+ Go Kevin! You can write this! +

Supported Languages

+
+
eng
Enlish
chi_sim
Chinese
rus
Rusian
tha
Meme
deu
German
jpn
Japanese
spa
Spanish
fra
French
chi_tra
Traditional Chinese
por
Portuguese
ita
Italian
pol
Polish
tur
Turkish
nld
Dutch
ara
Arabic
ces
Czech
kor
Korean
swe
Swedish
vie
Vietnamese
ron
Romanian
ell
Greek
ind
Indonesian
hun
Hungarian
dan
Danish
bul
Bulgarian
fin
Finnish
nor
Norwegian
ukr
Ukrainian
cat
Catalan
hrv
Croatian
heb
Hebrew
lit
Lithuanian
slv
Slovenian
hin
Hindi
ben
Bengali
tel
Telugu
tam
Tamil
kan
Kannada
mal
Malayalam
tgl
Tagalog
swa
Swahili
aze
Azerbaijani
bel
Belarusian
afr
Afrikaans
sqi
Albanian
eus
Basque
epo
Esperanto
est
Estonian
glg
Galician
isl
Icelandic
lav
Latvian
mkd
Macedonian
msa
Malay
mlt
Maltese
grc
Ancient Greek
chr
Cherokee
enm
English (Old)
epo_alt
Esperanto alternative
frk
Frankish
frm
French (Old)
ita_old
Italian (Old)
equ
Math
srp
Serbian (Latin)
slk
Slovakian
spa_old
Old Spanish
+
@@ -183,6 +138,13 @@ + @@ -191,7 +153,7 @@ - + diff --git a/src/main.js b/src/main.js index e28208c..3f247b5 100644 --- a/src/main.js +++ b/src/main.js @@ -1,193 +1,229 @@ function builddemo(id, val){ - var demo = document.getElementById(id) - var prog = demo.querySelector('.prog') - var out = demo.querySelector('.out') - - var disp = demo.querySelector('.display') - var dctx = disp.getContext('2d') - disp.width = 0 - disp.height = 0 - - demo.querySelector('.runbutton').onclick = function(){ - setrunning(0) - run(editor) - } - - function show_progress(p){ - - setrunning(0) - console.log(p) - if(p.loaded_lang_model) prog.value = p.loaded_lang_model - if(p.recognized) prog.value = p.recognized - out.innerText = JSON.stringify(p) - out.innerText = JSON.stringify(p) - - } - - function setrunning(v){ - if (v == 1) { - demo.querySelector('.running').style.display = 'none' - demo.querySelector('.notrunning').style.display = 'block' - // out.style.visibility = 'hidden' - } - else { - demo.querySelector('.running').style.display = 'block' - demo.querySelector('.notrunning').style.display = 'none' - } - } - - function display(result) { - - React.render(React.createElement(Node, { node: result, expanded: true, label: "output_of_above_demo"}), document.getElementById("explorer")); - - setrunning(1) - - out.innerText = "Lightning Speeeeeeed" - prog.value = 0 - - console.log(result) - - disp.width = demo.querySelector('.to_ocr').naturalWidth - disp.height = demo.querySelector('.to_ocr').naturalHeight - - disp.style.width = demo.querySelector('.to_ocr').offsetWidth - disp.style.height = demo.querySelector('.to_ocr').offsetHeight - - - dctx.shadowColor = "rgba(255,255,255,.1)" - dctx.shadowOffsetX = 0; - dctx.shadowOffsetY = 0; - dctx.shadowBlur = 10; - - dctx.fillRect(0,0,disp.width, disp.height) - - var m = result.words.map(function(w){ - - var b = w.bbox - dctx.font = '20px Times' - var font = 20*(b.x1-b.x0)/dctx.measureText(w.text).width+"px Times" - - - var k = function(){ - dctx.font = font - dctx.fillText(w.text, b.x0, w.baseline.y0); - return font - } - - return k - }) - - var times = 0 - var maxtimes = m.length + 100 - function draw(i){ - - times++ - dctx.fillStyle="rgba(30, 29, 49, .8)" - dctx.fillStyle="#00DB9D" - // dctx.globalAlpha = .1; - dctx.clearRect(0,0,disp.width, disp.height) - dctx.fillRect(0,0,disp.width, disp.height) - - for (var j = 0; j < Math.min(i,m.length); j++) { - var asdf = Math.min(Math.max(i - j,0), 100) - dctx.fillStyle = "rgba(255,255,255,"+asdf*.01+")" - m[j]() - }; - - if(i', {name: 'xml', htmlMode: true}, scdiv) - - // var scripttag = CodeMirror(,{ - // mode: {name: 'xml', htmlMode: true}, - // readOnly: 'nocursor', - // value: - // }); - - - return { - - run: function(){ - var img = demo.querySelector('.to_ocr') - - if (img.complete) { - run(editor) - } else{ - img.onload = function(){ - run(editor) - } - } - - } - } + var demo = document.getElementById(id) + var prog = demo.querySelector('.prog') + var out = demo.querySelector('.out') + + var disp = demo.querySelector('.display') + var dctx = disp.getContext('2d') + disp.width = 0 + disp.height = 0 + + demo.querySelector('.runbutton').onclick = function(){ + setrunning(0) + run(editor) + } + + function show_progress(p){ + + setrunning(0) + console.log(p) + if(p.loaded_lang_model) prog.value = p.loaded_lang_model + if(p.recognized) prog.value = p.recognized + out.innerText = JSON.stringify(p) + out.innerText = JSON.stringify(p) + + } + + function setrunning(v){ + if (v == 1) { + demo.querySelector('.running').style.display = 'none' + demo.querySelector('.notrunning').style.display = 'block' + // out.style.visibility = 'hidden' + } + else { + demo.querySelector('.running').style.display = 'block' + demo.querySelector('.notrunning').style.display = 'none' + } + } + + function display(result) { + + React.render(React.createElement(Node, { node: result, expanded: true, label: "output_of_above_demo_plz_click_stuff"}), document.getElementById("explorer")); + + setrunning(1) + + out.innerText = "Lightning Speeeeeeed" + prog.value = 0 + + console.log(result) + + disp.width = demo.querySelector('.to_ocr').naturalWidth + disp.height = demo.querySelector('.to_ocr').naturalHeight + + disp.style.width = demo.querySelector('.to_ocr').offsetWidth + disp.style.height = demo.querySelector('.to_ocr').offsetHeight + + + dctx.shadowColor = "rgba(255,255,255,.1)" + dctx.shadowOffsetX = 0; + dctx.shadowOffsetY = 0; + dctx.shadowBlur = 10; + + dctx.fillRect(0,0,disp.width, disp.height) + + var m = result.words.map(function(w){ + + var b = w.bbox + dctx.font = '20px Times' + var font = 20*(b.x1-b.x0)/dctx.measureText(w.text).width+"px Times" + + + var k = function(){ + dctx.font = font + dctx.fillText(w.text, b.x0, w.baseline.y0); + return font + } + + return k + }) + + var times = 0 + var maxtimes = m.length + 100 + function draw(i){ + + times++ + // dctx.fillStyle="rgba(30, 29, 49, .8)" + dctx.fillStyle="rgba(0, 219, 157, "+Math.min(i/100,1)+")" + // dctx.globalAlpha = .1; + dctx.clearRect(0,0,disp.width, disp.height) + dctx.fillRect(0,0,disp.width, disp.height) + + for (var j = 0; j < Math.min(i,m.length); j++) { + var asdf = Math.min(Math.max(i - j,0), 100) + dctx.fillStyle = "rgba(255,255,255,"+asdf*.01+")" + m[j]() + }; + + if(i', { + name: 'xml', + htmlMode: true + }, scdiv) + + // var scripttag = CodeMirror(,{ + // mode: {name: 'xml', htmlMode: true}, + // readOnly: 'nocursor', + // value: + // }); + editor.clear = function(){ + dctx.clearRect(0,0,disp.width, disp.height) + document.querySelector('.ocroutput').innerHTML = '' + + } + + editor.img = demo.querySelector('.to_ocr') + + editor.run = function(){ + + if (editor.img.complete) { + run(editor) + } else{ + editor.img.onload = function(){ + run(editor) + } + } + } + + return editor } -builddemo('wow', +setTimeout(function(){ + document.getElementById('wow').className += ' opaque' +}, 100) + +var wow = builddemo('wow', "var img = demo.querySelector('img.to_ocr')\n\n\ Tesseract\n\ - .recognize( img, {progress: show_progress} )\n\ - .then( display )") -.run() - -addEventListener('scroll', function(e){ - //frum jcurry - var doc = document.documentElement; - var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); - if(top >= 227) { - document.querySelector('.stickyheader').style['background-color'] = '#00DB9D' - } - else { - document.querySelector('.stickyheader').style['background-color'] = 'rgba(0,0,0,0)' - } + .recognize( img, {\n\ + progress: show_progress} )\n\ + .then( display ) // scroll down for full output ") + +wow.run() + + +var tabs = Array.prototype.slice.call(document.querySelectorAll('.langlabel')) +var ltabs = Array.prototype.slice.call(document.querySelectorAll('.ltab')) +var langs = ['eng', 'chi_sim', 'rus', 'tha'] + +function setlang(i){ + tabs.forEach(function(t){ + t.className = 'langlabel' + }) + tabs[i].className = 'langlabel selected' + console.log(tabs[i]) + wow.setValue( + "var img = demo.querySelector('img.to_ocr')\n\n" + +"Tesseract\n" + +" .recognize( img, {\n" + +" progress: show_progress, lang: '"+langs[i]+"'} )\n" + +" .then( display ) // scroll down for full output ") + wow.img.src = 'img/'+langs[i]+'.png' + wow.clear() + +} + + +ltabs.forEach(function(ltab,i){ + ltab.onclick = function(){ + setlang(i) + } }) + +tabs.forEach(function(tab,i){ + tab.onclick = function(){ + setlang(i) + } +}) // document.querySelector('.getStarted')[0].onclick = function(){ -// location.href = '#' -// location.href = '#get_started' +// location.href = '#' +// location.href = '#get_started' // } // builddemo('demo2',