I'm trying to go back to beginnings with my own ManelBrot morph because
I can quite grok how the one I have works. Mostly because I still dont grok morphs. Example: I'm trying to plot points on a morph using the drawOn message below: drawOn: aCanvas "Draws the receiver on the given canvas" super drawOn: aCanvas. aCanvas form colorAt: 30@30 put: Color black. BUT, with or without the evocation of super drawOn, I can't get the point to stay around. It only draws during a drag. What is the pattern for this. I've looked at much code and many tutorials but they all seem to gloss over this little detail, or at least my eye skips it every time I look at all the examples I can find. Lawson _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 29.04.2010, at 13:15, Lawson English wrote:
> > I'm trying to go back to beginnings with my own ManelBrot morph because I can quite grok how the one I have works. > > Mostly because I still dont grok morphs. > > Example: I'm trying to plot points on a morph using the drawOn message below: Paint into a Form. Draw the form in #drawOn:. - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Bert Freudenberg wrote:
> On 29.04.2010, at 13:15, Lawson English wrote: > >> I'm trying to go back to beginnings with my own ManelBrot morph because I can quite grok how the one I have works. >> >> Mostly because I still dont grok morphs. >> >> Example: I'm trying to plot points on a morph using the drawOn message below: >> > > Paint into a Form. Draw the form in #drawOn:. > > > I'm sorry, I don't understand. Isn't this "painting" into a Form? aCanvas form colorAt: 30@30 put: Color black. My problem is that the pixel doesn't stay set. Lawson _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 29.04.2010, at 14:44, Lawson English wrote:
> > Bert Freudenberg wrote: >> On 29.04.2010, at 13:15, Lawson English wrote: >> >>> I'm trying to go back to beginnings with my own ManelBrot morph because I can quite grok how the one I have works. >>> >>> Mostly because I still dont grok morphs. >>> >>> Example: I'm trying to plot points on a morph using the drawOn message below: >>> >> >> Paint into a Form. Draw the form in #drawOn:. >> >> >> > > I'm sorry, I don't understand. > > Isn't this "painting" into a Form? > > aCanvas form colorAt: 30@30 put: Color black. No, that's painting directly onto the Display (a.k.a. the canvas's form), which is considered bad style in Morphic. > My problem is that the pixel doesn't stay set. 30@30 would be in the upper-left corner of the Display. Unless your morph covers that, you won't see it. You might try "self topLeft + (30@30)" but again, that's bad style. In any case, I thought your question was about displaying the Mandelbrot set. It would be wise to paint that into a form, preferably in a background process. Then just update the display (by drawing the form) once a second until it's finished. - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Bert Freudenberg wrote:
> On 29.04.2010, at 14:44, Lawson English wrote: > >> Bert Freudenberg wrote: >> >>> On 29.04.2010, at 13:15, Lawson English wrote: >>> >>> >>>> I'm trying to go back to beginnings with my own ManelBrot morph because I can quite grok how the one I have works. >>>> >>>> Mostly because I still dont grok morphs. >>>> >>>> Example: I'm trying to plot points on a morph using the drawOn message below: >>>> >>>> >>> Paint into a Form. Draw the form in #drawOn:. >>> >>> >>> >>> >> I'm sorry, I don't understand. >> >> Isn't this "painting" into a Form? >> >> aCanvas form colorAt: 30@30 put: Color black. >> > > No, that's painting directly onto the Display (a.k.a. the canvas's form), which is considered bad style in Morphic. > > >> My problem is that the pixel doesn't stay set. >> > > 30@30 would be in the upper-left corner of the Display. Unless your morph covers that, you won't see it. > when I release, it doesn't draw in the upper-left corner of the display. > You might try "self topLeft + (30@30)" but again, that's bad style. > > In any case, I thought your question was about displaying the Mandelbrot set. It would be wise to paint that into a form, preferably in a background process. Then just update the display (by drawing the form) once a second until it's finished. > > - Bert - > > My point is, how do I "paint it" into a form and then display it? If somehow I'm misinterpreting what I'm seeing: that it DOES draw within the bounds of the morph, then I'm quite happy to use aCanvas form colarAt: (self topLeft + (30@30) ) put: Color black. my question concerns getting what I've poked into the form to stay on the screen after I've released the mouse. Obviously I'm not caching the results as I thought I was. Lawson _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 29.04.2010, at 15:31, Lawson English wrote:
> > My point is, how do I "paint it" into a form colorAt:put: is okay for that (though slow). > and then display it? See the Canvas protocol "drawing-images". > my question concerns getting what I've poked into the form to stay on the screen after I've released the mouse. Whenever #drawOn: is called, you need to draw it again. > Obviously I'm not caching the results as I thought I was. No, your just not drawing where you think you are. Again: you should not draw into the Canvas's form directly. Use the canvas protocol. What's happening is that when you drag the morph in the hand, the canvas has a different transform than when it is resting in the world. Drawing directly into the canvas's form will ignore this transform. So it works sometimes but not always. - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Bert Freudenberg wrote:
> On 29.04.2010, at 15:31, Lawson English wrote: > >> My point is, how do I "paint it" into a form >> > > colorAt:put: is okay for that (though slow). > > >> and then display it? >> > > See the Canvas protocol "drawing-images". > > >> my question concerns getting what I've poked into the form to stay on the screen after I've released the mouse. >> > > Whenever #drawOn: is called, you need to draw it again. > > >> Obviously I'm not caching the results as I thought I was. >> > > No, your just not drawing where you think you are. Again: you should not draw into the Canvas's form directly. Use the canvas protocol. > > What's happening is that when you drag the morph in the hand, the canvas has a different transform than when it is resting in the world. Drawing directly into the canvas's form will ignore this transform. So it works sometimes but not always. > > super drawOn: aCanvas. aCanvas form colorAt: "self topLeft +"(30@30) put: Color black. Does NOT draw the dot at the upper left corner of the squeak window, but when I drag the morph around, the dot is offset as I would expect. When I release the mouse, the dot disappears. However: drawOn: aCanvas super drawOn: aCanvas. aCanvas form colorAt: self topLeft +(30@30) put: Color black. Draws the dot where I expected though it doesn't draw it during the mouse down. Also, why would the From>>colorAt:put: be slower than the Canvas drawing methods which are a good bit more indirect? Lawson _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 29.04.2010, at 15:58, Lawson English wrote:
> > Bert Freudenberg wrote: >> On 29.04.2010, at 15:31, Lawson English wrote: >> >>> My point is, how do I "paint it" into a form >>> >> >> colorAt:put: is okay for that (though slow). >> >> >>> and then display it? >>> >> >> See the Canvas protocol "drawing-images". >> >> >>> my question concerns getting what I've poked into the form to stay on the screen after I've released the mouse. >>> >> >> Whenever #drawOn: is called, you need to draw it again. >> >> >>> Obviously I'm not caching the results as I thought I was. >>> >> >> No, your just not drawing where you think you are. Again: you should not draw into the Canvas's form directly. Use the canvas protocol. >> What's happening is that when you drag the morph in the hand, the canvas has a different transform than when it is resting in the world. Drawing directly into the canvas's form will ignore this transform. So it works sometimes but not always. >> >> > drawOn: aCanvas > super drawOn: aCanvas. > aCanvas form colorAt: "self topLeft +"(30@30) put: Color black. > > > Does NOT draw the dot at the upper left corner of the squeak window, but when I drag the morph around, the dot is offset as I would expect. When I release the mouse, the dot disappears. > > However: > > drawOn: aCanvas > super drawOn: aCanvas. > aCanvas form colorAt: self topLeft +(30@30) put: Color black. > > Draws the dot where I expected though it doesn't draw it during the mouse down. Please read again what I wrote: "What's happening is that when you drag the morph in the hand, the canvas has a different transform than when it is resting in the world. Drawing directly into the canvas's form will ignore this transform. So it works sometimes but not always." > Also, why would the From>>colorAt:put: be slower than the Canvas drawing methods which are a good bit more indirect? I did not compare it to canvas. Please, try to assume I meant it just as written ;) - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by LawsonEnglish
Hi Lawson,
If you want to draw on a canvas, first you need to own the canvas. So in a workspace, play with this: ======= lawson := ImageMorph new image: Form fromUser . "I suggest you pick 1 line of text as your form" lawson openInHand . lawson image bitEdit . "because at this point you get the whole thing blown up. "When you are done drawing on the enlarged form use its red menu to press accept. Then you also need to delete the enlarged form." lawson changed . "This last part marks your imageMorph as in need of updating. If you forget this then the changes won't show until you pick up your morph." ======= This is not exactly what you want but its the best I could come up with in a few minutes play. hth, Yours in curiosity and service, --Jerome Peace --- On Thu, 4/29/10, Lawson English <[hidden email]> wrote: > From: Lawson English <[hidden email]> > Subject: Re: [Newbies] How to draw a single pixel with permanence? > To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]> > Date: Thursday, April 29, 2010, 8:44 AM > Bert Freudenberg wrote: > > On 29.04.2010, at 13:15, Lawson English wrote: > > > >> I'm trying to go back to beginnings with my own > ManelBrot morph because I can quite grok how the one I have > works. > >> > >> Mostly because I still dont grok morphs. > >> > >> Example: I'm trying to plot points on a morph > using the drawOn message below: > >> > > > > Paint into a Form. Draw the form in #drawOn:. > > > > > > > > I'm sorry, I don't understand. > > Isn't this "painting" into a Form? > > aCanvas form colorAt: 30@30 put: Color black. > > > > My problem is that the pixel doesn't stay set. > > > Lawson > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |