How do I label a point I created with a script?

classic Classic list List threaded Threaded
5 messages Options
HJH
Reply | Threaded
Open this post in threaded view
|

How do I label a point I created with a script?

HJH
Hello Hilaire

I have

    | c vertexA |
    c := DrGeoCanvas new.
    vertexA := c point: 1@0.

I would like to give a label to vertexA. The label should be 'vertex'. How do I do that?

--Hannes
HJH
Reply | Threaded
Open this post in threaded view
|

Re: How do I label a point I created with a script?

HJH
I was looking for a method called 'label: aText'

in the method index  http://forum.drgeo.eu/Method-index-td4025402.html

but it is

      aDrGeoItem name: aText

https://www.gnu.org/software/dr-geo/doc/en/Smalltalk-sketch.html#index-name_003a-on-DrGWrappedItem
HJH
Reply | Threaded
Open this post in threaded view
|

Re: How do I label a point I created with a script?

HJH
Example:

    | c pointA pointB lineSegment |
    c := DrGeoCanvas new.
    c view extent: 500@500.
    "c axesOn."
    c gridOn.
    pointA := c point: 0 @ 0.
    pointA name: 'A'.
    pointB := c point: 5 @ 0.
    pointB name: 'B'.
    lineSegment := c segment:  pointA  to: pointB.
    lineSegment name: '[AB]'.

Named line segment
HJH
Reply | Threaded
Open this post in threaded view
|

Re: How do I label a point I created with a script?

HJH
Another example

    | c pointA pointB pointC lineSegment lineSegment2 lineSegment3|
   
    c := DrGeoCanvas new.
    c view extent: 500@500.
    "c axesOn."
    c gridOn.
    pointA := c point: 0 @ 0.
    pointA name: 'A'.
    pointB := c point: 4 @ 0.
    pointB name: 'B'.
    pointC := c point: 0 @ 3.
    pointC name: 'C'.
   
    lineSegment := c segment:  pointA  to: pointB.
    lineSegment name: '[AB]'.

    lineSegment2 := c segment:  pointA  to: pointC.
    lineSegment2 name: '[AC]'.

    lineSegment3 := c segment:  pointB  to: pointC.
    lineSegment3 name: '[BC]'.
Reply | Threaded
Open this post in threaded view
|

Re: How do I label a point I created with a script?

Hliaire Fernandes
Administrator
In reply to this post by HJH
Hi,

You send the message #name: to the object.

a := canvas point: 1@2.
a name: 'Toto'


or

(canvas point: 1@2) name: 'Toto'.

I took a look at the Conceptual index of the documentation, and it was not exactly helpful.

There is an entry about the object attributes, though:

        Smalltalk sketch, object attributes: Smalltalk sketch

and it points to a paragraph explaining how to name an object in a Smalltalk sketch.

Hilaire