Letter Shadows from User Input

巧了我就是萌 提交于 2019-12-02 13:21:53

Do you really need raphael? What I did was simply print out your words onto an element and get the shadow with css's text-shadow. To get the vertical text I added a </br> after each letter.

Take a look at the fiddle: http://jsfiddle.net/joplomacedo/wVGbF/

Here's the code in case you can't see the fiddle:

HTML

Text: <input type="text" id="words" value="" /> 
      <input id="animateBtn" type="button" value="Animate" />
      <div class="print"></div>

CSS

.print {
    font: 44px/0.8em "Lobster", cursive;
    color: gold;
    text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6);
}​

JS

var join = Array.prototype.join;

$('#animateBtn').on('click', function() {
    var txt = $('#words').val(),
        spaced_txt = join.call(txt, "</br>");

    $('.print').html(spaced_txt);
});​

Here is also the text output function with Raphael:

function draw_text() {
  var txt = document.getElementById("words").value;
  var posy = txt.length*10;
  r.clear();
  var attr = {font: "50px Helvetica", opacity: 0.5};
  var text = r.text(40, 40+posy, txt).attr(attr).attr({fill: "#0f0"}); // underlayer or "shadow"
  text.attr({transform: "r270"}); // rotate 270 degrees
  var text2 = r.text(43, 43+posy, txt).attr(attr).attr({fill: "#aa0"}); // text above
  text2.attr({transform: "r270"}); // rotate 270 degrees
  r.safari();
}

var r = new Raphael("draw-here-raphael");

The full script, based on this example, is here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!