Particle Text
This pen shows the new slide from Text feature of pcoming ParticleSlider Version. Start typing and interact with mouse to see it in action.
See http://particleslider.com for more informations
<html>
<html>
<head>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/stats.js/r11/Stats.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/dat-gui/0.5/dat.gui.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://particleslider.com/js/particleslider/current/particleslider-0.9.1.core.min.js"></script> </head>
<body>
<div class="particles"></div>
<textarea>start typing</textarea>
</body>
</html>
html, body, div.particles {
html, body, div.particles {
background-color: #000;
color: #fff;
margin: 0;
padding: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
textarea {
opacity: 0.0;
position: absolute;
z-index: 10;
top: 10em;
}
# Tamino Martinius -All rights reserved
# Tamino Martinius - All rights reserved
# Copyright © 2013 Tamino Martinius (http://zaku.eu)
# Copyright © 2013 Particleslider.com (http://particleslider.com
# Terms of usage: http://particleslider.com/legal/license
#Stats
$(window).load(() ->
oStats = new Stats()
oStats.setMode(0)
oStats.domElement.style.position = 'absolute'
oStats.domElement.style.left = '0px'
oStats.domElement.style.top = '0px'
document.body.appendChild(oStats.domElement);
ps = plText = plCursor = plText = null
fW2 = fH2 = 0.0
nTxt = $('textarea')
window.bAutoFocusText = true
oParams =
nRoot: $('.particles')[0]
bIsRunning: true
bRestless: false
bIsMonochrome: true
iPxSize: 2,
iPxGap: 1,
aColorDefault: [255, 255, 255, 255]
evPreUpdate: () ->
oStats.begin()
return
evPostRender: () ->
oStats.end()
return
evPostResize: () ->
plText.fnSetText(nTxt.val())
plCursor.iOffsetX = (plText.iWidth / 2) + 10
return
ps = new ParticleSystem(oParams)
plCursor = ps.plcRender.fnAdd()
plText = ps.plcRender.fnAdd()
plCursor.sAnimationIn = 'SlideInBottom'
plCursor.sAnimationOut = 'SlideOutBottom'
plCursor.oAnimationInParams.iAvgTtl = 10
plCursor.oAnimationOutParams.iAvgTtl = 10
plCursor.fnSetText('_')
plText.sAnimationOut = 'Warp'
plText.sAnimationIn = 'SlideInRight'
setInterval(() ->
plCursor.fnUnloadParticles()
return
, 3000
)
setTimeout(() ->
setInterval(() ->
plCursor.fnLoadParticles()
plCursor.iOffsetX = plText.iWidth / 2 + 5
return
, 3000
)
return
, 1000)
setTimeout(() ->
ps.fnResize()
plText.fnSetText(nTxt.val().replace('\n', ''))
plCursor.iOffsetX = plText.iWidth / 2 + 5
return
, 300)
fnSetText = () ->
s = nTxt.val()
s = s.replace('\n', '')
plText.fnSetText(s)
plCursor.iOffsetX = plText.iWidth / 2 + 5
if window.bAutoFocusText is true
nTxt.focus().val('')
nTxt.val(s)
nTxt.blur(() ->
if window.bAutoFocusText is true
setTimeout(() ->
fnSetText()
return
, 10)
)
$(window).keyup(() ->
fnSetText()
return
)
gui = new dat.GUI()
gui.add(window, 'bAutoFocusText').name('auto focus text')
gui.add(ps, 'iPxSize').min(1).max(10).step(1).name('size')
gui.add(ps, 'iPxGap').min(0).max(9).step(1).name('gap').onChange(() ->
fnSetText()
return
)
gui.add(ps, 'iMaxFontSize').min(10).max(100).step(1).name('font size').onChange(() ->
fnSetText()
return
)
gui.add(ps, 'sFont',['sans-serif', 'monospace', 'serif']).name('font').onChange(() ->
plText.fnSetText(nTxt.val())
return
)
gui.add(ps, 'bRestless').name('restless')
gui.addColor(ps, 'aColorDefault').name('color').onChange(() ->
ps.aColorDefault[0] = ~~ps.aColorDefault[0]
ps.aColorDefault[1] = ~~ps.aColorDefault[1]
ps.aColorDefault[2] = ~~ps.aColorDefault[2]
ps.aColorDefault[3] = ~~ps.aColorDefault[3]
plText.fnSetText(nTxt.val())
return
)
gui.add(ps, 'fnStopRunning').name('pause')
gui.add(ps, 'fnStartRunning').name('play')
if window.innerWidth < 1000
gui.close()
else
$(window).keyup()
)