• Asymptote 学习记录(5) 模块roundedpath的用法


    看这个代码:

     1 import settings;
     2 settings.tex = "pdflatex";
     3 pdfviewer="/usr/bin/okular";
     4 outformat="pdf";
     5 texpreamble("\usepackage{CJKutf8}\AtBeginDocument{\begin{CJK}{UTF8}{gbsn}}\AtEndDocument{\clearpage\end{CJK}}");
     6 // example file for 'roundedpath.asy'
     7 // written by stefan knorr
     8 // import needed packages
     9 import roundedpath;
    10 // define open and closed path
    11 path A = (0,0)--(10,10)--(30,10)--(20,0)--(30,-10)--(10,-10);
    12 path B = A--cycle;
    13 draw(shift(-60,0)*A, green);
    14 draw(shift(-30,0)*roundedpath(A,1), red);
    15 // draw open path and some modifications
    16 
    17 for (int i = 1; i < 20; ++i)
    18   draw(roundedpath(A,i/4), rgb(1 - i*0.049, 0, i*0.049) + linewidth(0.5));
    19 
    20 draw(shift(-60,-30)*B, green);
    21 draw(shift(-30,-30)*roundedpath(B,1), red);
    22 
    23 //draw closed path and some modifications
    24 
    25 for (int i = 1; i < 20; ++i)                          // only round edges
    26   draw(shift(0,-30)*roundedpath(B,i/4), rgb(0.5, i*0.049,0) + linewidth(0.5));
    27 
    28 for (int i = 1; i < 20; ++i)                          // round edged and scale 
    29   draw(shift(0,-60)*roundedpath(B,i/4,1-i/50), rgb(1, 1 - i*0.049,i*0.049) + linewidth(0.5));
    30 
    31 for (int i = 1; i < 50; ++i)                          // shift (round edged und scaled shifted version)
    32   draw(shift(-30,-60)*shift(10,0)*roundedpath(shift(-10,0)*B,i/10,1-i/80), rgb( i*0.024, 1 - i*0.024,0) + linewidth(0.5));
    33 
    34 for (int i = 1; i < 20; ++i)                          // shift (round edged und scaled shifted version)
    35   draw(shift(-60,-60)*shift(10,0)*roundedpath(shift(-10,0)*B,i/4,1-i/50), gray(i/40));

    编译之后产生的图像为

  • 相关阅读:
    【1】BIO与NIO、AIO的区别
    BIO | NIO | AIO (Java版)
    Java NIO 机制分析(一) Java IO的演进
    AbstractQueuedSynchronizer同步队列与Condition等待队列协同机制
    【1】【JUC】Condition和生产者消费者模型
    【JUC】JDK1.8源码分析之CyclicBarrier
    常用排序,查找,树算法集锦
    AFNetworking
    ios推送服务,php服务端
    如何使用subversion管理iOS源代码
  • 原文地址:https://www.cnblogs.com/yeluqing/p/3827747.html
Copyright © 2020-2023  润新知