JQuery SVG绘图文本(JQuery SVG Drawing Text)
我正在创建一个HTML 5站点,使用Keith Wood的JQuery SVG库在SVG中执行某种形式的图表。
我希望能够在SVG画布上绘制简单的文本 - 没有任何花哨的标准文本(例如单词或标题文本),在本网站上作为实际SVG给出了示例。
http://www.kevlindev.com/tutorials/basics/text/svg/index.htm
我查看了Jquery库网站上的API参考,我得到的是一个绘制波浪文本的复杂示例,我对此并不感兴趣。
任何人都可以给我一个简单的例子,说明我如何使用库API编写文本?
I am creating a HTML 5 site that performs some form of diagramming in SVG using the JQuery SVG library by Keith Wood.
I would like to be able to draw simple text on the SVG canvas - nothing fancy just standard text (i.e. like a word or title text) which is given as examples on this site as actual SVG.
http://www.kevlindev.com/tutorials/basics/text/svg/index.htm
I have looked at the API reference on the Jquery library site and all I get is a complicated example of drawing wavy text which I am not interested in.
Can anyone give me a simple example of how I write text using the library API?
原文:https://stackoverflow.com/questions/8028095
最满意答案
我已经解决了问题。 结果在下面:)我比较服务器时间和用户硬件时间并为按钮显示时间添加差异。 :)
function getTime() { $.ajax({ type : 'POST', async: false, url : 'time.php', success : function(response){ // date of button display var year = "2017", month = "03", day = "22", hour = "13", minute = "50", second = "01"; var startDate = new Date("" + year + "-" + month + "-" + day + "T" + hour + ":" + minute + ":" + second +"+01:00"); // +01:00 timezone correction var buttonTime = startDate.getTime() / 1000; // time - when display button var currentTime = parseInt(response); if (!Date.now) { Date.now = function now() { return new Date().getTime() / 1000; }; } var userPcTime = Math.floor(Date.now() / 1000); if (currentTime !== userPcTime) { var timeDiff = currentTime - userPcTime; buttonTime = buttonTime - timeDiff; console.log(timeDiff); } function testTime() { if (!Date.now) { Date.now = function now() { return new Date().getTime() / 1000; }; } var userPcTime = Math.floor(Date.now() / 1000); var diff = buttonTime - userPcTime; if (userPcTime > buttonTime ) { // triggers here" alert(' here will be trigger of show button'); } if (userPcTime <= buttonTime && diff <= 60 ) { // test after 1 s. var testDelay = 1000; setTimeout(function() { testTime(); }, testDelay); } if (userPcTime < buttonTime && diff > 60 ) { // test after 10 s. var testDelay = 10000; setTimeout(function() { testTime(); }, testDelay); } }; testTime(); }, complete(){}, error(){} }); }; getTime();
正确的time.php是:
<?php $timestamp = time(); $date_time = date($timestamp); echo $date_time; ?>
I have solve problem. Result is below :) I compare server time nad user hardware time and add difference to button show time. :)
function getTime() { $.ajax({ type : 'POST', async: false, url : 'time.php', success : function(response){ // date of button display var year = "2017", month = "03", day = "22", hour = "13", minute = "50", second = "01"; var startDate = new Date("" + year + "-" + month + "-" + day + "T" + hour + ":" + minute + ":" + second +"+01:00"); // +01:00 timezone correction var buttonTime = startDate.getTime() / 1000; // time - when display button var currentTime = parseInt(response); if (!Date.now) { Date.now = function now() { return new Date().getTime() / 1000; }; } var userPcTime = Math.floor(Date.now() / 1000); if (currentTime !== userPcTime) { var timeDiff = currentTime - userPcTime; buttonTime = buttonTime - timeDiff; console.log(timeDiff); } function testTime() { if (!Date.now) { Date.now = function now() { return new Date().getTime() / 1000; }; } var userPcTime = Math.floor(Date.now() / 1000); var diff = buttonTime - userPcTime; if (userPcTime > buttonTime ) { // triggers here" alert(' here will be trigger of show button'); } if (userPcTime <= buttonTime && diff <= 60 ) { // test after 1 s. var testDelay = 1000; setTimeout(function() { testTime(); }, testDelay); } if (userPcTime < buttonTime && diff > 60 ) { // test after 10 s. var testDelay = 10000; setTimeout(function() { testTime(); }, testDelay); } }; testTime(); }, complete(){}, error(){} }); }; getTime();
And correct time.php is:
<?php $timestamp = time(); $date_time = date($timestamp); echo $date_time; ?>
相关问答
更多-
setTimeout的问题(Issues with setTimeout)[2023-05-29]
主要问题不在于javascript,而是在CSS中。 .social-circle类没有fill ,这意味着它实际上是#000 。 .social-circle { stroke-dasharray: 900; stroke-dashoffset: 900; fill: rgba(144, 17, 133, 0); } 这解决了初始动画 ,您可能已经或可能没有注意到“填充”动画使用从“无”到紫色的稍微明亮的过渡。 这似乎是因为TweenLite将fill: 'none'为fill: ... -
setTimeout不会延迟(setTimeout will not delay)[2023-05-19]
您的错误是您在this.tick()上调用this.tick() 。 当你在tick()函数中调用this ,你已经引用了tick函数, 所以你想使用setTimeout(this, 1000); 你的计时器将正常工作。 看到这个小提琴解决方案: https : //jsfiddle.net/sg7yf6r4/ 阅读有关该问题的更多信息: Javascript对象从其自身调用函数 Your error is that you call setTimeOut on this.tick(). When you ... -
执行循环不需要10秒。 Look将立即执行,匿名函数将enqueued 10次,在1秒后执行。 最后一次调用setTimeout将导致匿名函数在110秒后执行。 要确保循环中的匿名函数按顺序调用10次,每次间隔1秒后,执行以下操作: var c = 0; setTimeout(function() { if(c < 10) { gold = gold + clickPower; console.log("Clicked"); c++; ...
-
我建议使用jQuery的.delay() (结合.stop(true) )自动处理计时器的东西: $("nav.nav").hover(function () { $("nav.nav").stop(true).animate({left: '-5px'}, 100, "swing"); },function () { $("nav.nav").stop(true).delay(1000).animate({left: '-170px'}, 100, "swing"); }); 工作演示: ...
-
带setTimeout的日期 - 如何以安全的方式减少时间延迟?(date with setTimeout - how to reduce time lag in safety way?)[2023-02-08]
我已经解决了问题。 结果在下面:)我比较服务器时间和用户硬件时间并为按钮显示时间添加差异。 :) function getTime() { $.ajax({ type : 'POST', async: false, url : 'time.php', success : function(response){ // date of button di ... -
var tout = 10 * 1000; var t = setTimeout(function() { document.myform.submit(); }, tout); 在这里阅读有关如何正确使用setTimeout的信息 。 第一个参数应该是函数引用,第二个超时应该是毫秒。 var tout = 10 * 1000; var t = setTimeout(function() { document.myform.submit(); }, tout); Read about h ...
-
这实际上不是一个递归调用,因为第一次调用eternal()实际上已经在setTimeout()调用下一个调用之前完成。 因此,它不是技术上的递归,也不会随着时间的推移而堆积。 它可以在没有任何累积的情况下永远运行,这是保持一遍又一遍运行的完美方式。 为了回应您的一条评论,javascript不是多线程的,因此它不会为计时器创建多个线程。 触发的每个计时器事件只是将一个事件放入事件队列中,如果当时没有JS正在运行,则触发该事件(从而调用回调函数)。 如果JS当时正在运行,则JS引擎会等待,直到当前正在执行的J ...
-
你很亲密 setTimeout调用应位于单击处理程序内部,而不是位于其下方。 无需将函数名称作为字符串传递。 这是实现您所追求的目标的正确方法: $('div.skill').hide(); $('.btn_2').click(function (e) { setTimeout(showSkills, 3000); }); function showSkills() { alert("Hello") }; You're close. The setTimeout call should ...
-
简单。 所有20个UIView都有相同的UI东西,如Picker视图和2个按钮(OK,Cancel)。 Picker视图数据源可能不同。 因此,创建一个具有这些东西的UIView,并根据将要显示的选择器视图,您可以传递/显示不同的数据。 您还可以通过指定标记值来区分20个选择器 pickerview.tag =一个枚举常量(20个值)。 而已。 如果所有20个UIView包含不同的UI元素作为其子视图怎么办? 不要使用IB 创建视图时将创建所有这些内容 采用延迟加载/创建 编写将创建并提供视图的自定义函数或 ...
-
SetTimeOut问题(SetTimeOut problems)[2021-09-05]
如果我明白 - 锁定开关时,它完成解锁后: var lock = 0; function Switch() { if(lock == 0) { lock = 1; if(videoNieuw.className == "show"){ playNoise(1280, 720); btnswitch.className="controls now"; setTimeo ...