Search code examples
smalltalkpharosqueakmorphic

Adjusting points in Pharo Smalltalk


I'm new to Smalltalk, so please bear with me. I'm simply trying to make a simple drawing using Morphs.

Now I can create Circles and Lines, but I'm having issues adjusting the start and end point in my workspace.

If you can offer any advice I'd greatly appreciate it!

man := Morph new.
head := CircleMorph new color: Color blue.
body := LineMorph new.
man addMorph: head.
man addMorph:  body.
man openInWindow.

Solution

  • verticesAt:put: allows you to directly change the points in a LineMorph:

    line := LineMorph new.
    line verticesAt: 1 put: 0@0.
    line verticesAt: 2 put: 100@50.
    

    or use the #vertices:color:borderWidth:borderColor: class-side method:

    LineMorph 
        vertices: (Array with: 0@0 with: 100@50)
        color: Color transparent
        borderWidth: 1
        borderColor: Color black