How do I dismiss a DrGeoCanvas object?

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

How do I dismiss a DrGeoCanvas object?

HJH
Hello

I have the following simple script in a "Playground" (workspace). In the end I want to create a sequence of sketches and take screen shots of them.

    | c |
    c := DrGeoCanvas new.
    c view extent: 500@500.
    c point: 2 @ 2.
    c point: 2 @ 4.
    c point: 4 @ 4.
    c segment:  2@2 to: 4@4.

    c view area imageForm inspect.   "use later for PNG export"
    c view area presenter exportToBitmap.
    c inspect.

How do I dismiss the DrGeoCanvas object c?

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

Re: How do I dismiss a DrGeoCanvas object?

Hilaire Fernandes
Administrator
Le 10/09/2018 à 17:17, HJH [via Dr. Geo Forum] a écrit :
Hello

I have the following simple script in a "Playground" (workspace). In the end I want to create a sequence of sketches and take screen shots of them.

    | c |
    c := DrGeoCanvas new.
    c view extent: 500@500.
    c point: 2 @ 2.
    c point: 2 @ 4.
    c point: 4 @ 4.
    c segment:  2@2 to: 4@4.

    c view area imageForm inspect.   "use later for PNG export"
    c view area presenter exportToBitmap.
    c inspect.

How do I dismiss the DrGeoCanvas object c?

What do you mean by dismiss? Garbage collected, remove from World?

For a complete remove and collection, try :

|c |
c := DrGeoCanvas new.
c point: 0@0.
c view app saved: true.
c view delete.
c := nil.

Was this message helpful?
Tell us!
HJH
Reply | Threaded
Open this post in threaded view
|

Re: How do I dismiss a DrGeoCanvas object?

HJH
Yes, with 'dismiss' I mean to remove the window from the world (desktop).

     c delete

did not work. Interesting that I need to delete the view only.

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

Re: How do I dismiss a DrGeoCanvas object?

Hilaire Fernandes
Administrator
Le 10/09/2018 à 19:24, HJH [via Dr. Geo Forum] a écrit :
> Yes, with 'dismiss' I mean to remove the window from the world (desktop).
>
>      c delete

One can write this method with the code I wrote in my previous email.

>
> did not work. Interesting that I need to delete the view only.

Yes, because this is from where is activated in the UI.
Now you should look at what does delete, it does a lot, not only
removing the view from the World.

Hilaire

Was this message helpful?
Tell us!
HJH
Reply | Threaded
Open this post in threaded view
|

Re: How do I dismiss a DrGeoCanvas object?

HJH
I am now going for the following code to construct a sketch with code only.


    | c imageForm aDrGeoWindow outputStream |
    c := DrGeoCanvas new.
    c view extent: 500@500.
    c point: 2 @ 2.
    c point: 2 @ 4.
    c point: 4 @ 4.
    c segment:  2@2 to: 4@4.
   
    aDrGeoWindow := c view.
    imageForm :=  aDrGeoWindow area imageForm.
    outputStream := (DrGeoSystem myExportsPath / ('result.png')) ensureDelete binaryWriteStream.

    PNGReadWriter putForm: imageForm copy onStream: outputStream.

    aDrGeoWindow deleteWithoutConfirmation .


This script creates one sketch, writes a PNG file of it and then dismisses the sketch. It will be the start for creating a series of sketches.

Suggestions for enhancing the script are welcome.

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

Re: How do I dismiss a DrGeoCanvas object?

HJH
In the most recent developer version this is now simply


    | c |
    c := DrGeoCanvas new.
    c view extent: 500@500.
    c point: 2 @ 2.
    c point: 2 @ 4.
    c point: 4 @ 4.
    c segment:  2@2 to: 4@4.
    c exportToBitmap: '/home/user8/sketch1.png'.
    c delete.

or another example

    | c pointA pointB |
    c := DrGeoCanvas minimal.
    c axesOn.
    c gridOn.
    pointA := c point: 1@0.
    pointB := c point: 5@0.
    c ray: pointA to: pointB.
    c exportToBitmap: '/home/user8/sketch2.png'.
    c delete.


Note: It is implemented as

    initializeViewMinimal
        super initialize.
        drgeo := DrGeo service.
        "We do want it to be on the front"
        self view setProperty: #morphicLayerNumber toValue: 100.
        self view openInWorld.
        self view extent: 400@300.
Reply | Threaded
Open this post in threaded view
|

Re: How do I dismiss a DrGeoCanvas object?

Hilaire Fernandes
Administrator
Le 01/10/2018 à 20:40, HJH [via Dr. Geo Forum] a écrit :

    | c |
    c := DrGeoCanvas new.
    c view extent: 500@500.
    c point: 2 @ 2.
    c point: 2 @ 4.
    c point: 4 @ 4.
    c segment:  2@2 to: 4@4.
    c exportToBitmap: '/home/user8/sketch1.png'.
    c delete.


Are you ware, this script could be shorten as:

  | c |
    c := DrGeoCanvas new.
    c view extent: 500@500.
    c segment:  2@2 to: 4@4.
    c exportToBitmap: '/home/user8/sketch1.png'.
    c delete.

Hilaire

Was this message helpful?
Tell us!