简体   繁体   中英

Add imagemorph to rectangle

I have a rectangle in smalltalk like this

cell := RectangleMorph new
extent: 70@70;
position: (500 + (aPositionWidth))@(100 + (aPositionHeight));
color: lastCellColor.

I'm trying to add an image to each rectangle like this:

  queen := ImageReadWriter formFromFileNamed: '9813.gif'.
    cell addMorph: queen.
    queen position: cell position.

It's not working how can I add an image?

Thank you in advanced

ImageReadWriter class>>formFromFileNamed: returns a Form object. A form doesn't understand #position: . You need to convert it first to a morph. Try:

queen := (ImageReadWriter formFromFileNamed: 'queen.jpg') asMorph.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM