首页 \ 问答 \ JQuery SVG绘图文本(JQuery SVG Drawing Text)

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
更新时间:2022-07-11 08:07

最满意答案

我已经解决了问题。 结果在下面:)我比较服务器时间和用户硬件时间并为按钮显示时间添加差异。 :)

    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;

?>

相关问答

更多
  • 主要问题不在于javascript,而是在CSS中。 .social-circle类没有fill ,这意味着它实际上是#000 。 .social-circle { stroke-dasharray: 900; stroke-dashoffset: 900; fill: rgba(144, 17, 133, 0); } 这解决了初始动画 ,您可能已经或可能没有注意到“填充”动画使用从“无”到紫色的稍微明亮的过渡。 这似乎是因为TweenLite将fill: 'none'为fill: ...
  • 您的错误是您在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"); }); 工作演示: ...
  • 我已经解决了问题。 结果在下面:)我比较服务器时间和用户硬件时间并为按钮显示时间添加差异。 :) 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 创建视图时将创建所有这些内容 采用延迟加载/创建 编写将创建并提供视图的自定义函数或 ...
  • 如果我明白 - 锁定开关时,它完成解锁后: var lock = 0; function Switch() { if(lock == 0) { lock = 1; if(videoNieuw.className == "show"){ playNoise(1280, 720); btnswitch.className="controls now"; setTimeo ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。