ENC: How to draw a 2D line

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ENC: How to draw a 2D line

LBerendsen

Hi All,

 

I am trying to draw a simples 2D Line in months.

I can’t understand what to do.

 

Could someone help me with this?

I have C, Pascal, VBA background, but none of these knowledge is helping me…

 

Regards,

Lorenzo.



Reply | Threaded
Open this post in threaded view
|

Re: ENC: How to draw a 2D line

Jakob Reschke
Hi Lorenzo,

Are you familiar with browsing existing code in Squeak already? If
not, I advise you have a look at the Squeak by Example book:
https://hal.inria.fr/inria-00441576/file/SBE.pdf
It also contains a chapter on drawing your own morphs.

Otherwise you probably want to have a look at the classes Canvas and
Form. A Form contains pixels and a Canvas can be used to draw things
like points, lines, and other images to a graphical medium. A
FormCanvas (a subclass of Canvas) can be used to draw on a Form. To
display a Form in the world you can use an ImageMorph.

The following creates a 32-Bit Form of 200x200 pixels, draws two lines
on it and attaches the image to the mouse cursor (hand).

form := Form extent: 200@200 depth: 32.
canvas := FormCanvas on: form.
canvas line: 0@0 to: 200@200 color: Color red.
canvas line: 200@0 to: 0@200 color: Color blue.
morph := ImageMorph new.
morph image: form.
morph openInHand.

You can then draw further stuff with the canvas and the morph will be
updated accordingly.

Does this help you?

Best regards,
Jakob

2017-06-23 22:43 GMT+02:00 Lorenzo Berendsen <[hidden email]>:

> Hi All,
>
>
>
> I am trying to draw a simples 2D Line in months.
>
> I can’t understand what to do.
>
>
>
> Could someone help me with this?
>
> I have C, Pascal, VBA background, but none of these knowledge is helping me…
>
>
>
> Regards,
>
> Lorenzo.

Reply | Threaded
Open this post in threaded view
|

Re: ENC: How to draw a 2D line

Kjell Godo

is there a way to draw lines over top of all the open windows?
like a line from inside of one window to inside of another window?
like arrows from a help window to graphical elements in some other windows?

On Sat, Jun 24, 2017 at 06:00 Jakob Reschke <[hidden email]> wrote:
Hi Lorenzo,

Are you familiar with browsing existing code in Squeak already? If
not, I advise you have a look at the Squeak by Example book:
https://hal.inria.fr/inria-00441576/file/SBE.pdf
It also contains a chapter on drawing your own morphs.

Otherwise you probably want to have a look at the classes Canvas and
Form. A Form contains pixels and a Canvas can be used to draw things
like points, lines, and other images to a graphical medium. A
FormCanvas (a subclass of Canvas) can be used to draw on a Form. To
display a Form in the world you can use an ImageMorph.

The following creates a 32-Bit Form of 200x200 pixels, draws two lines
on it and attaches the image to the mouse cursor (hand).

form := Form extent: 200@200 depth: 32.
canvas := FormCanvas on: form.
canvas line: 0@0 to: 200@200 color: Color red.
canvas line: 200@0 to: 0@200 color: Color blue.
morph := ImageMorph new.
morph image: form.
morph openInHand.

You can then draw further stuff with the canvas and the morph will be
updated accordingly.

Does this help you?

Best regards,
Jakob

2017-06-23 22:43 GMT+02:00 Lorenzo Berendsen <[hidden email]>:
> Hi All,
>
>
>
> I am trying to draw a simples 2D Line in months.
>
> I can’t understand what to do.
>
>
>
> Could someone help me with this?
>
> I have C, Pascal, VBA background, but none of these knowledge is helping me…
>
>
>
> Regards,
>
> Lorenzo.



Reply | Threaded
Open this post in threaded view
|

Re: ENC: How to draw a 2D line

Jakob Reschke
In reply to this post by Jakob Reschke
All morphs are freely positionable in the world and can be stacked
like the windows themselves (which are morphs, too). So you could
create/draw a morph with the necessary dimensions and place it such
that it overlaps with the windows as desired.

    (LineMorph from: 100@100 to: 200@300 color: Color yellow width: 5)
openInWorld

    window1 := ToolBuilder open: Browser new.
    window2 := ToolBuilder open: Workspace new.
    line := LineMorph
        from: (window1 findDeeplyA: SystemWindowButton) center
        to: (window2 findDeeplyA: TextMorph) positionInWorld
        color: Color red
        width: 3.
    line openInWorld.

2017-06-26 21:28 GMT+02:00 Kjell Godo <[hidden email]>:

>
> is there a way to draw lines over top of all the open windows?
> like a line from inside of one window to inside of another window?
> like arrows from a help window to graphical elements in some other windows?
>
> On Sat, Jun 24, 2017 at 06:00 Jakob Reschke <[hidden email]>
> wrote:
>>
>> Hi Lorenzo,
>>
>> Are you familiar with browsing existing code in Squeak already? If
>> not, I advise you have a look at the Squeak by Example book:
>> https://hal.inria.fr/inria-00441576/file/SBE.pdf
>> It also contains a chapter on drawing your own morphs.
>>
>> Otherwise you probably want to have a look at the classes Canvas and
>> Form. A Form contains pixels and a Canvas can be used to draw things
>> like points, lines, and other images to a graphical medium. A
>> FormCanvas (a subclass of Canvas) can be used to draw on a Form. To
>> display a Form in the world you can use an ImageMorph.
>>
>> The following creates a 32-Bit Form of 200x200 pixels, draws two lines
>> on it and attaches the image to the mouse cursor (hand).
>>
>> form := Form extent: 200@200 depth: 32.
>> canvas := FormCanvas on: form.
>> canvas line: 0@0 to: 200@200 color: Color red.
>> canvas line: 200@0 to: 0@200 color: Color blue.
>> morph := ImageMorph new.
>> morph image: form.
>> morph openInHand.
>>
>> You can then draw further stuff with the canvas and the morph will be
>> updated accordingly.
>>
>> Does this help you?
>>
>> Best regards,
>> Jakob
>>
>> 2017-06-23 22:43 GMT+02:00 Lorenzo Berendsen
>> <[hidden email]>:
>> > Hi All,
>> >
>> >
>> >
>> > I am trying to draw a simples 2D Line in months.
>> >
>> > I can’t understand what to do.
>> >
>> >
>> >
>> > Could someone help me with this?
>> >
>> > I have C, Pascal, VBA background, but none of these knowledge is helping
>> > me…
>> >
>> >
>> >
>> > Regards,
>> >
>> > Lorenzo.
>>
>