repeat 4 [fd 2 rt 90]
What should be drawn?
It seems like a simple answer but it's not. Lets show the grid
of pixels and the different solutions. The Turtle is in lower left
(LL) corner pointing towards the uppler left (UL) corner.
Solution #1
[ ][ ][ ]
[X][X][ ]
[X][X][ ]
This solution is 2x2 pixels
It's center is 0x0 pixels
It's confusing, but has some merit.
Solution #2
[X][X][X]
[X][ ][X]
[X][X][X]
This is 3x3 pixels
It's center is 1x1 pixels.
It's looks better but it's actually bigger than what you asked for.
Neither is correct.
The way MswLogo thinks of the drawing surface is an imaginary
line going down the center of each pixel. If you think of it like
this it's exactly right. Because the distance from the center of
the LL pixel to the center of the UL pixel is exactly 2 pixels.
Solution #2 is what is used but there are 2 choices
of how you end up with solution #2. Why is this? It's best shown
by example one line segment at a time.
Solution A
[X][ ][ ]
[X][ ][ ]
[X][ ][ ]
[X][X][X]
[ ][ ][ ]
[ ][ ][ ]
[ ][ ][X]
[ ][ ][X]
[ ][ ][X]
[ ][ ][ ]
[ ][ ][ ]
[X][X][X]
Solution B
[X][ ][ ]
[X][ ][ ]
[ ][ ][ ]
[ ][X][X]
[ ][ ][ ]
[ ][ ][ ]
[ ][ ][ ]
[ ][ ][X]
[ ][ ][X]
[ ][ ][ ]
[ ][ ][ ]
[X][X][ ]
If your drawing something only 2 pixels "long" why should you light 3
pixels?
When MswLogo draws a 2x2 square it lights 2*4 = 8 pixels.
When other Logo's draw a 2x2 square it lights 3*4 = 12 pixels (it draws
the
4 corners twice).
MswLogo tries to be little smarter by drawing only 2 pixels yet still
end up
with the desired result. Does it really matter? Yes. It matters more
when you
Change the pen to reverse. If you draw the 4 corners twice, then they
will be
drawn and then erased again and you will not end up with a square
reversed
square. If you draw a straight line in reverse mode it will have have
gaps
at each point you stop because it draws that point Twice (it shouldn't).
So when you issue FD n MSWLogo draws the first point exclusive and the
last point inclusive. Actually it's windows that does this and it is
absolutely a good approach. When windows draws rectangles The Top/Left
is inclusive and the Bottom/Right is exclusive. If it didn't life would
be very difficult. But what does BK n do? It does it in reverse. The
place
the turtle is at is inclusive and the desination is exclusive.
So the benifits are:
When you move 2 you get 2 pixels lit.
When you draw a 2x2 square you get a hollow.
When you draw a 2x2 square in reverse you get a square.
When you draw fd 2 fd 2 in reverse you get a solid line.
When you bk 2 bk 2 in reverse it will still properly erase.
When you draw a 2x2 square you get 8 pixels hit not 12.
When you draw fd 0 you get nothing as you should.
So the answer to your real question how do I draw a Dot.
to dot
bk 1
fd 1
end
However there is a catch. When the penwidth is greater than 1
it still is only inclusive and exclusive by 1 pixel. Which is
why fd 0 drew something (it was drawing the penwidth - 1).
Note these same issues that confuse some folks in thinking MSWLogo
has a "of by 1" bug when cutting and pasting bitmaps.
If you draw a 2x2 square (which is 3x3) pixels you can't copy
it as a bitmap of size 2x2 because it's 3x3 and does the inclusive
exclusive tricks, which is needed if you want to do real animation.
Olga Tuzova wrote:
>
> George,
>
> Recently I've faced a problem in MSWLogo, which I'd like to clarify.
> Would you please help me.
>
> I wanted to put a dot on the screen and for that purpose I used FD 1
> BK 1. Sure, it wasn't actually a dot, but a little stroke. Following
> Yehuda's suggestion, I changed these instructions with FD 0. After
> that the turtle wouldn't leave any trace until I have enlarged the
> pensize. That is, with the pensize [2 2] FD 0 works and with the pensize [1
> 1] it doesn't work.
>
> What follow are the full set of codes (improved by Yehuda Katz in
> compare with my initial solution) where this problem occurred. I
> think it (I mean the set, but may be the problem also) would be of interest to logo fans. The procedures draw a
> family of curves known in Mathematics as "roses".
> ----------------------------
> to roses :a :k :coord
> setpensize [2 2]
> setpencolor [0 0 255]
> ht
> roses.draw 0
> end
>
> to roses.draw :fi
> pu
> setpos :coord
> seth :fi fd roses.ro pd FD 0
> ; FD 0 HERE DOESN'T LEAVE A DOT WHEN PENSIZE [1 1]
> test and (pos=se first :coord (last :coord)+:a)(:fi>0)
> iff [roses.draw :fi+.5]
> end
>
> to roses.ro
> op :a*(cos :k*:fi)
> end
> ---------------------------------------------
> roses is the main procedure. It's inputs:
> :a - 'radius' of the rose;
> :coord - the list of the coordinates of the centre of the rose, it
> allows to draw several different roses on the same
> screen;
> :k - parameter, which regulates the number and the shape of the rose's
> leaves;
> it's interesting to investigate the cases:
> :k - odd,
> :k - even,
> :k - rational,
> :k - irrational.
>
> So, one may try
> roses 100 sqrt 2 [0 0]
> or roses 50 2/5 [100 100]
> or roses 100 6 [-100 -100] and so on.
-- =============================================================== George Mills email: mills@softronix.com http://www.softronix.com The www page contains some very powerful educational software. Our single most important investment is our kids.--------------------------------------------------------------- Please post messages to the Logo forum to logo-l@gsn.org. Mail questions about the list administration to logofdn@gsn.org. To unsubscribe send unsubscribe logo-l to majordomo@gsn.org.