Skip to content

Commit

Permalink
Simplify morph creation from Athens surface
Browse files Browse the repository at this point in the history
A new method named #asMorph has been created in the AthensSurface class,
returning the Morph representation of the surface.

This new method have been used in the Athens examples.

Fixes: pharo-project#4517
  • Loading branch information
leonardoce committed Oct 7, 2019
1 parent a9c11aa commit dd4d473
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
6 changes: 6 additions & 0 deletions src/Athens-Core/AthensSurface.class.st
Expand Up @@ -37,6 +37,12 @@ AthensSurface >> asForm [
self subclassResponsibility
]

{ #category : #converting }
AthensSurface >> asMorph [
"Answer a Morph, given this Athens surface"
^ self asForm asMorph
]

{ #category : #caching }
AthensSurface >> cacheAt: anObject ifAbsentPut: aBlock [
"Answer an object from surface's cache identified by anObject,
Expand Down
4 changes: 2 additions & 2 deletions src/Athens-Examples/AthensCairoSurfaceExamples.class.st
Expand Up @@ -47,7 +47,7 @@ AthensCairoSurfaceExamples class >> exampleDrawTextPath [
f unlock.
].

surf asForm asMorph openInWindow
surf asMorph openInWindow

]

Expand Down Expand Up @@ -77,7 +77,7 @@ A cairo image surface bits are exposed to bitblt operations via surface plugin.
2 timesRepeat: [ can draw. can setPaint: (Color green alpha:0.5)]
].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #utilities }
Expand Down
36 changes: 18 additions & 18 deletions src/Athens-Examples/AthensSurfaceExamples.class.st
Expand Up @@ -45,7 +45,7 @@ AthensSurfaceExamples class >> draw2Strings [
can pathTransform translateBy: advance.
can drawString: 'in mind.'].

surf asForm asMorph openInWindow.
surf asMorph openInWindow.
]

{ #category : #examples }
Expand Down Expand Up @@ -189,7 +189,7 @@ AthensSurfaceExamples class >> example10 [
can setStrokePaint: Color red.
can draw ].

surf asForm asMorph openInWindow.
surf asMorph openInWindow.

]

Expand Down Expand Up @@ -243,7 +243,7 @@ AthensSurfaceExamples class >> example3 [
]
].

surf asForm asMorph openInWindow.
surf asMorph openInWindow.

]

Expand Down Expand Up @@ -277,7 +277,7 @@ AthensSurfaceExamples class >> example3stroke [
]
].

surf asForm asMorph openInWindow.
surf asMorph openInWindow.

]

Expand All @@ -304,7 +304,7 @@ AthensSurfaceExamples class >> example4 [
can drawShape: path.
].

surf asForm asMorph openInWindow.
surf asMorph openInWindow.

]

Expand Down Expand Up @@ -338,7 +338,7 @@ AthensSurfaceExamples class >> example5 [
])
].

surf asForm asMorph openInWindow.
surf asMorph openInWindow.
]

{ #category : #examples }
Expand Down Expand Up @@ -366,7 +366,7 @@ AthensSurfaceExamples class >> example6 [
can pathTransform translateX: 50 Y: 50; rotateByDegrees: 30.
can drawShape: (0@0 corner: 50@50) ].

surf asForm asMorph openInWindow
surf asMorph openInWindow

]

Expand All @@ -392,7 +392,7 @@ AthensSurfaceExamples class >> example6point1 [

can drawShape: (0@0 corner: 50@50) ].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #examples }
Expand Down Expand Up @@ -420,7 +420,7 @@ AthensSurfaceExamples class >> example6stroke [
can pathTransform translateX: 50 Y: 50.
can drawShape: (0@0 corner: 50@50) ].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #examples }
Expand Down Expand Up @@ -455,7 +455,7 @@ AthensSurfaceExamples class >> example7 [

].
].
surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #examples }
Expand All @@ -477,7 +477,7 @@ AthensSurfaceExamples class >> example8 [

can drawShape: (0@0 corner: 200@200)].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #examples }
Expand All @@ -499,7 +499,7 @@ AthensSurfaceExamples class >> example9 [
setPaint: paint;
drawShape: (0@0 corner: 100@200)].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #examples }
Expand All @@ -522,7 +522,7 @@ AthensSurfaceExamples class >> exampleClip [
]
].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #examples }
Expand Down Expand Up @@ -551,7 +551,7 @@ AthensSurfaceExamples class >> exampleDrawForm [
can pathTransform translateX: 30 Y: 30.
can draw ].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #examples }
Expand All @@ -573,7 +573,7 @@ AthensSurfaceExamples class >> exampleDrawForm2 [
can paintTransform scaleBy: 3; rotateByDegrees: 30.
can draw ].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #examples }
Expand All @@ -597,7 +597,7 @@ AthensSurfaceExamples class >> exampleDrawText [
can pathTransform translateX: 0 Y: (font getPreciseAscent).
can drawString: 'Hello Athens!' ].

surf asForm asMorph openInWindow
surf asMorph openInWindow

]

Expand All @@ -620,7 +620,7 @@ AthensSurfaceExamples class >> exampleStrokeRect [
]
].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #examples }
Expand All @@ -633,7 +633,7 @@ AthensSurfaceExamples class >> exampleUseForm [
form getCanvas fillRectangle: (20@20 corner: 50@50) color: (Color blue).

surf := AthensCairoSurface fromForm: form.
surf asForm asMorph openInWindow
surf asMorph openInWindow

]

Expand Down
10 changes: 5 additions & 5 deletions src/Athens-Examples/AthensTextRenderManualTests.class.st
Expand Up @@ -65,7 +65,7 @@ AthensTextRenderManualTests class >> test2 [
c renderOn: canvas
].

surf asForm asMorph openInWindow
surf asMorph openInWindow
]

{ #category : #tests }
Expand All @@ -90,7 +90,7 @@ AthensTextRenderManualTests class >> test3 [
canvas pathTransform translateBy: 0 @11.
].
].
surf asForm asMorph openInWindow
surf asMorph openInWindow


]
Expand All @@ -114,7 +114,7 @@ AthensTextRenderManualTests class >> test4 [
canvas pathTransform translateBy: 0.1@10.
]
].
surf asForm asMorph openInWindow
surf asMorph openInWindow


]
Expand All @@ -137,7 +137,7 @@ AthensTextRenderManualTests class >> test5 [
canvas pathTransform translateBy: 10@0.1.
]
].
surf asForm asMorph openInWindow
surf asMorph openInWindow


]
Expand Down Expand Up @@ -237,7 +237,7 @@ AthensTextRenderManualTests class >> testWindowRender [
canvas fullDrawMorph: win.
].

surf asForm asMorph openInWindow
surf asMorph openInWindow


]

0 comments on commit dd4d473

Please sign in to comment.