Forgot password?
 Register account
View 1472|Reply 135

Asymptote测试

[Copy link]

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

hbghlyj Posted 2022-6-3 10:15 |Read mode
Last edited by hbghlyj 2025-3-2 15:10


Asymptote代码:

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2023-1-10 19:58
Last edited by hbghlyj 2025-3-24 02:32

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2023-1-10 23:52
kuing 发表于 2023-1-10 16:49
let asys = document.getElementsByTagName('asy');
for (let item of asys) {
        var str = item.innerHTML ...
我觉得
  1. var str = item.innerHTML.replace(/<br>/g, "").replace(/&nbsp;/g,' ');
Copy the Code
可以用innerText或textContent写成
  1. var str = item.innerText;
Copy the Code

Comment

哦  Posted 2023-1-11 00:04

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2023-1-11 00:47
hbghlyj 发表于 2023-1-10 23:52
我觉得可以用innerText或textContent写成
&nbsp; 还是有必要替换掉的,否则转换后它会变成 %C2%A0 ,从而在图中会产生真的空格。

test:



(《Asymptote 范例教程》里的例子)

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2023-1-28 18:34
@kuing

用同样的方法利用mpppreview可以使论坛支持metapost
同样地, 发送一个post请求, mpsource参数是代码😃

Comment

不搞了😌  Posted 2023-1-28 22:38

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2023-4-19 19:31
hbghlyj 发表于 2023-1-10 16:52
我觉得可以用innerText或textContent写成
使用textContent的优点是保留换行\n😀
若使用innerText则\n都会变成空格,导致代码中的单行注释把后面所有行都注释了

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2023-4-19 19:36
kk/zdy3pc.js
  1.     item.innerHTML = item.innerHTML.replace(/&nbsp;/g,' ');
  2.     var str = item.textContent;
Copy the Code
这2行应该可以简化为1行吧
  1.     var str = item.textContent.replace(/\\u00a0/g, " ")
Copy the Code

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2023-11-20 15:47
貌似挂了,这帖只有 7# 用 format=png 那图能显示,其他都不行,不知为啥。

而 1# 的三个提交,第二个也出错,看来是 svg 不行?

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2023-11-21 14:12
Last edited by kuing 2023-11-21 14:21
kuing 发表于 2023-11-20 15:47
貌似挂了,这帖只有 7# 用 format=png 那图能显示,其他都不行,不知为啥。

而 1# 的三个提交,第二个也出 ...
不是 svg 不行,而是似乎现在必须指定 format 😳

那尝试将自定义 js 里的其中一行改成
  1. item.innerHTML = '<img src="/asy/?format=svg&code='+str_for_link+'" onclick="show_tikz_window(\''+str_for_show+'\');" />';
Copy the Code

现在是有时行有时不行😳每次刷新都不一定同😳

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-1-31 17:04
提個小建議
  1. <a href="javascript:;" class="flbc" style="float:right;margin:3px 6px 0 0;" onclick="close_tikz_window();">
Copy the Code
可簡化為
  1. <a href="javascript:close_tikz_window();" class="flbc" style="float:right;margin:3px 6px 0 0;">
Copy the Code

Comment

明白了😊  Posted 2024-1-31 17:17

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-2-19 02:04
您的第一张图像无法正确显示,我看到完整的SVG代码,但在它之前有一个<b>Warning</b>:  Undefined array key "format" in <b>/home/vol2_6/epizy.com/epiz_31707543/htdocs/asy/index.php</b> on line <b>4</b><br />

这个warning来自哪里? 来自 php 还是来自 Asymptote 服务器

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-2-19 02:43
hbghlyj 发表于 2024-2-19 02:04
您的第一张图像无法正确显示,我看到完整的SVG代码,但在它之前有一个

这个warning来自哪里? 来自 php  ...
我不懂……

看 11#、12#,当时应该是发现必须指定 format 才行,否则报错。
而 2# 的第一个图当时是直接用 [img] 然后贴连接的就没有指定 format ,如下:
  1. [img]https://kuing.cjhb.site/asy/?code=import%20graph%3Bdraw(graph(new%20real(real%20x)%7Breturn%20exp(-x%5E2%2F2)%2Fsqrt(2pi)%3B%7D%2C-5%2C5)%2Cheavyred%2B1)%3B%0Aunitsize(0.8cm%2C4cm)%3B%0Adraw((-5.2%2C-0.05)--(5.2%2C-0.05)--(5.2%2C0.45)--(-5.2%2C0.45)--cycle)%3B%0Afor(int%20i%3D0%3Bi%3C6%3Bi%2B%3D2)%7Blabel(%220.%22%2B(string)i%2C(-5.2%2C0.1i)%2Calign%3DW)%3B%7D%0Afor(int%20i%3D-5%3Bi%3C6%3B%2B%2Bi)%7Blabel((string)i%2C(i%2C-0.05)%2Calign%3DS)%3B%7D%0Alabel(%22%24x%24%22%2C(0%2C-0.15)%2Calign%3DS)%3B%0Alabel(%22%24%5Cmu%3D0%2C%5C%3B%5Csigma%5E2%3D1%24%22%2C(3%2C0.3))%3B[/img]
Copy the Code

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-2-19 02:49
也许可以追踪此警告是来自PHP脚本还是Asymptote服务器
在 php 中,只需将 @ 符号附加到函数前面,警告就会被抑制,例如: $contents = @file_get_contents('/path/to/file.html');

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-2-19 02:51
我怀疑警告不是来自Asymptote服务器
我怀疑 php 脚本中访问 空参数“format”的行触发警告
所以如果在这一行前面加上@符号,会抑制警告

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-2-19 02:55
用同样的方法利用quickchart.io/documentation/graphviz-api/可以使论坛支持GraphViz

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-2-19 03:00
hbghlyj 发表于 2024-2-19 02:51
我怀疑警告不是来自Asymptote服务器
我怀疑 php 脚本中访问 空参数“format”的行触发警告
所以如果在这一 ...
asy/index.php 前几行是:
  1. <?php
  2. if(empty($_GET['format'])){$f='svg';}
  3. //if(empty($_GET['format'])){$f='png';}
  4. if($_GET['format']=='svg'||$_GET['format']=='png'||$_GET['format']=='html') {$f=$_GET['format'];}
  5. $url = "http://asymptote.ualberta.ca:10007?f=".$f;
Copy the Code
我现在将第 4 行改成 elseif,即
  1. <?php
  2. if(empty($_GET['format'])){$f='svg';}
  3. //if(empty($_GET['format'])){$f='png';}
  4. elseif($_GET['format']=='svg'||$_GET['format']=='png'||$_GET['format']=='html') {$f=$_GET['format'];}
  5. $url = "http://asymptote.ualberta.ca:10007?f=".$f;
Copy the Code
现在 2# 图1 好像可以了?

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-2-19 04:34
hbghlyj 发表于 2024-2-18 18:55
用同样的方法利用https://quickchart.io/documentation/graphviz-api/可以使论坛支持GraphViz ...
graphviz论坛可以直接在您的帖子中由 DOT 源代码生成 DOT 图表

例如在帖子中写
[dot]digraph {a -> b}[/dot]
然后得到:
a a b b a->b

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-2-27 19:19
svg:
asy/?format=svg&code=import venn;
png:
asy/?format=png&code=import venn;
html:
asy/?format=html&code=import venn;

看起来还有 PNG 能用,但效果也太差鸟

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-2-27 20:39
看來錯出在上游,我們這邊没法做任何事
ERROR: invalid optimizer module

Comment

只能暂时改成 png 图了,画质差点总比没有强  Posted 2024-2-27 21:18

0

Threads

412

Posts

6093

Credits

Credits
6093
QQ

Show all posts

爪机专用 Posted 2024-2-27 20:46
hbghlyj 发表于 2024-2-27 20:39
看來錯出在上游,我們這邊没法做任何事
ERROR: invalid optimizer module
有没有替代方案?
I am majia of kuing

Mobile version|Discuz Math Forum

2025-6-4 17:19 GMT+8

Powered by Discuz!

× Quick Reply To Top Edit