dr-geo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dr. Geo] Re : Re: Include bitmaps in sketches


From: H. Fernandes
Subject: [Dr. Geo] Re : Re: Include bitmaps in sketches
Date: Wed, 3 Nov 2021 09:59:20 +0100 (CET)

Hi Rafael, 

Wow, I am impressed! Do you have prior experience with Smalltalk?

To control the z-order, you send the message #comeToFront to the morph you want 
to be on the front.
In your script add something like below after creating the item: 

(self app costumeOf: item) morph comeToFront

Best

Dr. Geo -- http://drgeo.eu

----- Rafael Luque <rafael.luque.leiva@gmail.com> a écrit :
> I've managed to open an sketch with an astrophoto with the following code
> in a Playground:
> 
> | sketch imageMorph bitmapItem |
> sketch := DrGeoSketch new.
> imageMorph := (Form fromFileNamed: 'sun5.jpg') asMorph.
> bitmapItem := (DrGBitmapItem newWith: {(Point x: 0 y: 0)})
>     data: (DrGSurfacePaintResource
>         forSurfaceProvider: sketch view area
>         withData: imageMorph);
>     insertAtScale: 1.
> sketch domain createFromMathItem: bitmapItem.
> 
> To give some context, my intention is to locate the Sun's center given 3
> points in the limb (the edge of the Sun's disk) interactively placed by the
> user and apply a Smalltalk script to show an Earth image appropriately
> scaled.
> 
> For the script showing as result a bitmap I'm using the following "compute"
> method:
> 
> compute
> | item width result |
> width := self arg1 valueItem * 2.
> self app costumes
>     detect: [ :aCostume | aCostume mathItem name = 'ScaledEarth' ]
>     ifFound: [ :aCostume | self app domain deleteMathItem: aCostume
> mathItem. ].
> item :=
>     (DrGBitmapItem newWith: { self arg1 position + (80@7) })
>         data: (DrGSurfacePaintResource
>             forSurfaceProvider: self costume drawable
>             withData: (self earthForm scaledToSize: width@width));
>         insertAtScale: 1;
>         name: 'ScaledEarth'.
> self app domain createFromMathItem: item.
> ^ 'Scaled Earth (', width asString, ' px)'
> 
> I'm getting an acceptable result like the attached image.
> 
> One pending issue is that I'd like to move the Earth image over the Sun's
> one, however it is hidden below it. I don't know how to control a kind of
> z-order for the DrGBitmapItem objects.
> 
> Thank you.
> 
> 
> 
> 
> 
> El vie, 29 oct 2021 a las 18:48, Hilaire Fernandes (<hilaire@drgeo.eu>)
> escribió:
> >
> > Rafael,
> >
> > Beware I am porting DrGeo to Cuis Smalltalk and I will abandon Pharo.
> >
> > So Cuis-Smalltalk is where new work is done. If you want to jump in, I
> will tell you more details.
> >
> > Of course, it is perfectly ok to work on the Pharo version to add the
> feature you want. But I will very likely not work anymore on the Pharo
> version. you just need to know it.
> >
> > Best
> >
> > Le 29/10/2021 à 12:19, Rafael Luque a écrit :
> >
> > Thank you, Hilaire.
> >
> > I'm going to read the code to try to include the bitmap element
> programmatically.
> >
> > Thank you for your help.
> >
> > --
> > GNU Dr. Geo
> > http://drgeo.eu
> > http://blog.drgeo.eu
> 
> >




reply via email to

[Prev in Thread] Current Thread [Next in Thread]