了解Postscript中的递归Koch Snowflake函数 [英] Understanding recursive Koch Snowflake function in Postscript

查看:163
本文介绍了了解Postscript中的递归Koch Snowflake函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PostScript中有跟进程序,对此我很难理解。

I have followiong program in PostScript which I am having difficutly in understanding.

/kochR
 {
   2 copy ge {dup 0 rlineto}
     {
       3 div
       2 copy kochR
       60 rotate
       2 copy kochR
       -120 rotate
       2 copy kochR
       60 rotate
       2  copy kochR
      } ifelse
     pop pop
  } def

0 0 moveto
27 81 kochR
0 27 moveto
9 81 kochR
0 54 moveto
3 81 kochR
0 81 moveto
1 81 kochR
stroke

我对上述程序的疑问是:

My questions on above program are:


  1. 2个副本ge {dup 0 rlineto} 是什么意思?

  2. ifelse 在这里工作,条件是什么?

  3. 3 div 在这里做什么?

  4. 2个副本KochR 语句在这里执行什么操作?

  1. What does 2 copy ge { dup 0 rlineto } mean here?
  2. How does ifelse work here and what is the condition?
  3. What does 3 div do here?
  4. What does the 2 copy KochR statement perform here?


推荐答案

您似乎要在相当基本的PostScript概念和操作上遇到问题,您是否有《 PostScript语言参考手册》的副本?

You seem to be having some problems with quite basic PostScript concepts and operations, do you have a copy of the PostScript Language Reference Manual ?


  1. copy在操作数堆栈上复制一个条目,前面的参数告诉解释器要在堆栈上复制多少个操作数。 ge测试是否大于或等于,然后是一个可执行数组。

  1. copy copies an entry on the operand stack, the preceding argument tells the interpreter how many operands on the stack to copy. ge tests for greater than or equal and that is then followed by an executable array.

ifelse以您期望的方式工作,如果条件为真,则

ifelse works in the way you would expect, if the condition is true then the first executable array is executed, else the second executable array is executed.

3 div将堆栈上的操作数除以3,然后将结果放在操作数上

3 div divides the operand on the stack by 3 and places the result on the operand stack.

2副本与第1点相同, KochR是一个命名对象,在这种情况下,它是一个可执行数组。它必须事先已定义,否则将发生未定义错误。

2 copy does the same as in point 1, 'KochR' is a named object, in this case it is an executable array. It must have been previously defined or an 'undefined'' error will occur.

这篇关于了解Postscript中的递归Koch Snowflake函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆