Skip to content

Commit

Permalink
Alexandrie-Athens: Support createFormPaint: with extend repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed Dec 9, 2023
1 parent 3a76839 commit 517b2f5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Alexandrie-Athens-Tests/AthensAeCairoRenderTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,29 @@ AthensAeCairoRenderTest >> surfaceWith07RadialGradient [

^ surface
]

{ #category : #tests }
AthensAeCairoRenderTest >> surfaceWith08FormPaint [

| surface stroke form formPaint |
surface := AthensAeCairoSurface extent: 100 @ 100.

form := Form extent: 8@6 depth: 32.
form getCanvas fillRectangle: (0@0 corner: 4@3) color: Color red.
form getCanvas fillRectangle: (4@3 corner: 8@6) color: Color green.
formPaint := surface createFormPaint: form.
formPaint repeat.

surface drawDuring: [ :canvas |
canvas setPaint: formPaint.
canvas drawShape: (0@0 corner: 50@50).

canvas pathTransform
translateX: 50 Y: 50;
rotateByDegrees: 45.
stroke := canvas setStrokePaint: formPaint.
stroke width: 20.
canvas drawShape: (0@0 corner: 30@30) ].

^ surface
]
7 changes: 7 additions & 0 deletions src/Alexandrie-Athens/AeCairoImageSurface.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #AeCairoImageSurface }

{ #category : #'*Alexandrie-Athens' }
AeCairoImageSurface >> asAthensPaintOn: aCanvas [

^ AeCairoSurfacePattern surface: self
]
6 changes: 6 additions & 0 deletions src/Alexandrie-Athens/AeCairoPattern.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ AeCairoPattern >> loadOnCairoCanvas: aCanvas [
ifTrue:[ aCanvas cairoContext source: self ]
ifFalse:[ aCanvas setSourceR: 1.0 g: 0.0 b: 0.0 a: 1.0 ]
]

{ #category : #'*Alexandrie-Athens' }
AeCairoPattern >> repeat [

self extend: AeCairoExtendMode repeat
]
9 changes: 9 additions & 0 deletions src/Alexandrie-Athens/AthensAeCairoSurface.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ AthensAeCairoSurface >> clear: clearPaint [
drawShape: (0@0 extent: self extent) ] ]
]

{ #category : #paints }
AthensAeCairoSurface >> createFormPaint: aForm [

| newSurface |
newSurface := AeCairoImageSurface fromForm: (aForm asFormOfDepth: 32).

^ newSurface asAthensPaintOn: canvas
]

{ #category : #paints }
AthensAeCairoSurface >> createLinearGradient: aColorRamp start: aStartPoint stop: aStopPoint [

Expand Down

0 comments on commit 517b2f5

Please sign in to comment.