zoukankan      html  css  js  c++  java
  • 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));

    编译之后产生的图像为

  • 相关阅读:
    javascript设计模式(一)职责链模式China of responsibility
    javascript设计模式(一)策略模式Strategy
    angularjs提示消息弹出框
    Javascript设计模式(一)States
    Javascript设计模式(一)Facade
    NOIP2020
    RMQ & ST表
    NOI Linux
    初赛解析
    贪心大解析
  • 原文地址:https://www.cnblogs.com/yeluqing/p/3827461.html
Copyright © 2011-2022 走看看