Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
DrGeo use case: constructing a sketch
Last updated at 9:14 pm UTC on 4 October 2018
DrGeo:

What happens if I execute

 DrGeoCanvas new 

?

 a DrGeoCanvas

1. Method #initialize


initialize
	super initialize.
	self halt.
	drgeo := DrGeo applicationToolbarless.
	"We do want it to be on the front"
	self view setProperty: #morphicLayerNumber toValue: 100.
	self view openInWorld.
	self view extent: 400@300.


The object 'a DrGeoCanvas' holds in instance variable drgeo a DrGeo object.
What is a DrGeo object?

Answer: It is the application model. More see DrGeo class comment



What is the view object?

Answer: The answer to 'self view' is a DrGeoWindow



By code, then PNG export


| 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 .



Most recent developer version

| canvas |
canvas := DrGeoCanvas minimal.
canvas point: 0@0.
canvas axesOn.
canvas exportToBitmap: '/tmp/Toto.png'.
canvas delete