Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1554

I like some feedback on my tetrafoil function

From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.postscript
Subject I like some feedback on my tetrafoil function
Organization Decebal Computing
Date 2013-08-01 15:15 +0200
Message-ID <87haf98sc1.fsf@Aspire.decebal.nl> (permalink)

Show all headers | View raw


At closer inspection I saw that two figures where the ‘same’:
tetrafoil and “clover” I was asking about in a previous post.

I now made a function to draw both:
    % centerX centerY width [[[outerBox] innerCircle] innerCross]  drawClover  -
    /drawTetrafoil {
        10 dict begin
            dup type /booleantype eq {
                /innerCross exch def
                dup type /booleantype eq {
                    /innerCircle exch def
                    dup type /booleantype eq {
                        /outerBox exch def
                    } {
                        /outerBox false def
                    } ifelse
                } {
                    /innerCircle false def
                    /outerBox    false def
                } ifelse
            } {
                /innerCross  false def
                /innerCircle false def
                /outerBox    false def
            } ifelse
    
            /width    exch def
            /centerY  exch def
            /centerX  exch def
    
            /circleRadius width 4 div def
    
            gsave
                newpath
                centerX  centerY  translate
                4 {
                    innerCross {
                        0  0  moveto
                        0  circleRadius  rlineto
                    } if
                    circleRadius neg  circleRadius  circleRadius  0  270  arc
                    90 rotate
                } repeat
                stroke
                innerCircle {
                    0  0  circleRadius  0  360  arc
                    stroke
                } if
                outerBox {
                    width -.5 mul dup
                    width dup
                    rectstroke
                } if
            grestore
        end
    } def

I have a few questions about this.

Is the manner I work with optional parameters the way to do it, or are
there better ways? (I think it the most likely I want to draw the
inner cross, and the least likely I want to draw the outer box.)

Something is wrong in my function. If I call it with:
    235 100 100 true true false drawTetrafoil

The inner circle is correct at North, but in West, South and East the
inner ‘arms’ of the tetrafoil go through the inner circle. What is
going wrong?

I want to rotate the tetrafoil, but in such a way that it stays in the
outer box. What is the best way to get this done?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Back to comp.lang.postscript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

I like some feedback on my tetrafoil function Cecil Westerhof <Cecil@decebal.nl> - 2013-08-01 15:15 +0200
  Re: I like some feedback on my tetrafoil function luser- -droog <mijoryx@yahoo.com> - 2013-08-01 20:40 -0700
    Re: I like some feedback on my tetrafoil function Cecil Westerhof <Cecil@decebal.nl> - 2013-08-02 11:06 +0200
      Re: I like some feedback on my tetrafoil function luser- -droog <mijoryx@yahoo.com> - 2013-10-29 02:30 -0700

csiph-web