[squeak-dev] A (possible) way to play with a canvas from a workspace

Eduardo Ochs eduardoochs at gmail.com
Fri Mar 17 01:49:49 UTC 2023


Hi Karl!
Thanks! =)
I've added your last snippets to this:

  http://anggtwu.net/SQUEAK/Category-Edrx.st.html
  http://anggtwu.net/SQUEAK/Category-Edrx.st

As the urls to posts in the mailing list are very very long I'm
crediting you as the author of some snippets and classes by just
putting sentences like this one in the comments:

  Based on code that Karl Ramberg posted in 2023mar16.

If anyone wants to try, the instructions are: 1) fileIn the .st file
above, 2) treat the one-liners below as hyperlinks to places with more
code and/or more instructions, and Do The Right Thing:

  See edrxGuide: #drawOnAForm.
  See cm: (TestBezier >> #initialize).
  See cm: (TestDrawing >> #initialize).

Karl, your last snippets draw directly on the screen, and I just
realized that I should divide my doubts and questions in two parts: 1)
"how do I draw (on the screen)?" and 2) "how do I create a canvas that
behaves as a window or as a subwindow - i.e., that is surrounded by
thingies like TopLeftGrip, ..., BottomRightGrip, that implement
support for resizing and moving - and how do I draw inside that?"

Do you know anything about (2)?
  Cheers =),
    Eduardo Ochs
    http://anggtwu.net/eev-squeak.html


On Thu, 16 Mar 2023 at 16:52, karl ramberg <karlramberg at gmail.com> wrote:

> Hi,
> See two partly finished morphs in attachment that draw on canvas using
> different routines
>
> You can also draw to a form in a hackish way to make some generative art,
> see example below.
> Morphic is quite forgiving and will mostly work even if you break the
> rules slightly :-)
>
> brush := (Form extent: 1 at 1 depth: 32) fillBlack.
> form := (Form extent:500 at 500 depth:32) fillWhite.
> y := form extent y -60.
> x := form extent x -60.
> segments := 8 atRandom +3.
> points := OrderedCollection new.
> 1 to: segments do:[:r|
> points add: (x atRandom @ (y atRandom))+30].
> points add: (points first copy).
> 0 to: 1 by: 0.01 do:[:j|
> 1 to: segments do:[:i|
> form drawLine: brush
> from: (points at:i) to: (points at:i+1)
> clippingBox: form boundingBox
> rule: Form paint fillColor: nil].
> d := OrderedCollection new.
> 1 to: segments do:[:a|
>                  d add: (points at: a) +(j * ((points at: a+1)-(points at:
> a)))].
> d add: (d first copy).
>
> p := OrderedCollection new.
> 1 to: segments do:[:aa|
>
> p add: (d at: aa) +(j * ((d at: aa+1)-(d at: aa)))].
>
> p add: (p first copy).
> 1 to:segments do:[:b|
> form drawLine: brush
> from: (p at:b) to:  (p at:b+1)
> clippingBox: form boundingBox
> rule: Form paint fillColor: nil].
>
> form displayAt:10 at 60.
> (Delay forMilliseconds: 10) wait.
> ].
>
> Best,
> Karl
>
> On Wed, Mar 15, 2023 at 11:28 PM Eduardo Ochs <eduardoochs at gmail.com>
> wrote:
>
>> Hi list,
>> (or: hi Karl, but I decided to include other people too),
>>
>> Karl, can you try this when you have some spare time, and tell me if
>> this approach makes sense? "This" is this:
>>
>>   http://anggtwu.net/SQUEAK/Category-Edrx.st.html
>>   http://anggtwu.net/SQUEAK/Category-Edrx.st
>>
>> After fileIn-ing that you will get a "Category-Edrx" with seven
>> classes. The simplest way to explore them is by doing:
>>
>>   See see.
>>
>> I renamed the TestMorph class that you sent in this e-mail
>>
>>
>> http://lists.squeakfoundation.org/pipermail/squeak-dev/2023-February/223535.html
>>
>> to TestCanvas, and if you run this
>>
>>   See edrxGuide: #testCanvas.
>>
>> you will see some - still very bare and messy - notes on how to debug
>> this TestCanvas in a few different ways... I believe that it should be
>> possible to draw other things in that TestCanvas in the help topic
>> window using "tc" and "tc canvas", but I didn't have time to prepare
>> the examples yet...
>>
>>   Cheers,
>>     Eduardo Ochs
>>     http://anggtwu.net/eev-squeak.html
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230316/f97bd626/attachment.html>


More information about the Squeak-dev mailing list