[futurebasic] Re: One for the thinkers...(pseudocode)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 1998 : Group Archive : Group : All Groups

From: Robert Covington <t88@...>
Date: Sun, 4 Oct 1998 21:57:43 -0700 (MST)
>I'd like to be able to display a SINGLE letter in a window, and then
>somehow trace the outside of that letter and find all the X/Y points that
>make up the path around the outside of the letter. Block letters would be
>easy, those curvy script fonts would be tough.
>
>The letters would be a standard Mac font character ranging in size from
>50-500 points.
>
>Any ideas on A. if this could be done, and B. where to start. For tracing,
>I am better with a pen and paper...;-)
>
>Mel Patrick

Referencing my earlier message:
From a couple of lines above where the letter starts, go pixel by pixel
calling GETCPIXEL, and compare the values you get to black and white,
whereever you get a "hit" for a black color, the starting point XY gets
stored. When you get a white again, store that one, next black, store that
one, all on across that row of pixels.

Depending on the resolution you want, skip every other line on down, or do
every 4th line.

You can always do fewer lines, then interpolate later to get more points.
This will give you a rough to fine trace of your letter depending on how
many rows you sample. You still may wish to sample all the points even if
you don't store them to grab special case x/y's like the apex of the split
in a "Y" for example, or a sharp V's bottom

Pseudocode ' so pseu me, this won't work as written

'say a 200x200 pixel pict, every line checked

DIM RGB.6
DIM x   'need an array I imagine, I am not good at those
DIM y   'arrays of Titans  <g>
_black=0
END GLOBALS

CLEAR LOCAL
LOCAL FN WhatBeDaColor,Man(j,k)
LONG IF RGB=_black
j=x.j
k=y.k
END IF
END FN

CLEAR LOCAL
LOCAL FN GetDemPoints
FOR k=0 to 199 ' first row down, then the next
FOR j=0 to 199 ' first row across, then the next

CALL GETCPIXEL(j,k,RGB) 'maybe the other way around
FN WhatBeDaColor,Man(j,k)
next j  ' next pixel across
next k  ' next row down

END FN

'==Main

FN GetDemPoints


Robert Covington