[Q] Form>>extent:fromArray:offset:
Bob Arning
arning at charm.net
Tue Dec 3 21:12:33 UTC 2002
Chris,
On Tue, 03 Dec 2002 21:54:08 +0100 Chris Burkert <christian.burkert at s2000.tu-chemnitz.de> wrote:
>It's about the expected array. I tried:
>Cursor extent: 16 at 16 fromArray: #(2r1111111111111111) offset: 0 at 0.
>Everything was painted black.
>After that I tried:
>Form extent: 16 at 16 fromArray: #(2r1111111111111111) offset: 0 at 0.
>Nothing was painted.
Compare the comments for the two implementors of #extent:fromArray:offset:
Form -
"Answer an instance of me of depth 1 with bitmap initialized from anArray."
Cursor -
"Answer a new instance of me with width and height specified by
extentPoint, offset by offsetPoint, and bits from anArray.
NOTE: This has been kluged to take an array of 16-bit constants,
and shift them over so they are left-justified in a 32-bit bitmap"
So, in the Cursor, your 1111... got shifted into the part of the word that mattered for a 16-bit wide 1-bit deep form producing the black you were looking for. In the Form, your data ended in the unused lower 16 bits and was white.
>What I simply want, is a Form that is build like the Cursor, but
>variable in size. In this case it should only be black and white, but
>what if I want it colored ?
Well, #extent:fromArray:offset: does something like this...
^ (self extent: extentPoint depth: 1)
offset: offsetPoint;
initFromArray: anArray
so
(Form extent: 16 at 16 depth: 32)
offset: 0 at 0;
initFromArray: #(255 65280);
display
generates something with alternating blue and treen stripes.
Cheers,
Bob
More information about the Squeak-dev
mailing list
|