Generating subMorphs with relative coordinates

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

Generating subMorphs with relative coordinates

Christian Kellermann
Dear List,

I would like to generate Morphs inside another parent Morph.
In this case a bunch of CircleMorphs inside a RectangleMorph.

ATM I am generating them first and then adding them as a whole with
a OrderedCollection and addAllMorphs:

Now during creating of the circles I am adding the world offset of
the Rectangle morph to their bounds:

Is there a way to use relative coordinates for everything and have
the system place the Morphs accordingly?

So far I have found addMorphFrontFromWorldPosition: but that seems
a bit awkward to use in this case.

How do you deal with this situation usually?

Thanks and kind regards,

Christian


--
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Generating subMorphs with relative coordinates

Nicola Mingotti

Hi Christian,

Try this snippet, I think it is self explanatory.

-----------
tr := TransformMorph new.
tr openInWorld.
tr bounds: (100@100 corner: 300@300).

c1 := CircleMorph new.
tr addMorph: c1.
c1 position." 0@0"
c1 center: 0@0.
-----------

bye
Nicola




> On Oct 31, 2019, at 7:31 AM, Christian Kellermann <[hidden email]> wrote:
>
> Dear List,
>
> I would like to generate Morphs inside another parent Morph.
> In this case a bunch of CircleMorphs inside a RectangleMorph.
>
> ATM I am generating them first and then adding them as a whole with
> a OrderedCollection and addAllMorphs:
>
> Now during creating of the circles I am adding the world offset of
> the Rectangle morph to their bounds:
>
> Is there a way to use relative coordinates for everything and have
> the system place the Morphs accordingly?
>
> So far I have found addMorphFrontFromWorldPosition: but that seems
> a bit awkward to use in this case.
>
> How do you deal with this situation usually?
>
> Thanks and kind regards,
>
> Christian
>
>
> --
> May you be peaceful, may you live in safety, may you be free from
> suffering, and may you live with ease.
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Generating subMorphs with relative coordinates

Christian Kellermann
* Nicola Mingotti <[hidden email]> [191031 21:53]:

>
> Hi Christian,
>
> Try this snippet, I think it is self explanatory.
>
> -----------
> tr := TransformMorph new.
> tr openInWorld.
> tr bounds: (100@100 corner: 300@300).
>
> c1 := CircleMorph new.
> tr addMorph: c1.
> c1 position." 0@0"
> c1 center: 0@0.
> -----------
>

Excellent, that's exactly what I need!

Grazie mille!

--
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Generating subMorphs with relative coordinates

Nicola Mingotti
Grazie mille!

prego;)


On Oct 31, 2019, at 2:04 PM, Christian Kellermann <[hidden email]> wrote:

* Nicola Mingotti <[hidden email]> [191031 21:53]:

Hi Christian,

Try this snippet, I think it is self explanatory.

-----------
tr := TransformMorph new.
tr openInWorld.
tr bounds: (100@100 corner: 300@300).

c1 := CircleMorph new.
tr addMorph: c1.
c1 position." 0@0"
c1 center: 0@0.
-----------


Excellent, that's exactly what I need!

Grazie mille!

-- 
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners