Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added to athens: set fill rule and new example
  • Loading branch information
akevalion committed Mar 19, 2019
1 parent 1e24b80 commit 8d97776
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 3 deletions.
22 changes: 21 additions & 1 deletion src/Athens-Cairo/AthensCairoCanvas.class.st
Expand Up @@ -96,6 +96,21 @@ AthensCairoCanvas >> fill [

]

{ #category : #accessing }
AthensCairoCanvas >> fillRule [
^ self ffiCall: #( cairo_fill_rule_t cairo_get_fill_rule ( self ) )
]

{ #category : #accessing }
AthensCairoCanvas >> fillRuleEvenOdd [
self setFillRule: CAIRO_FILL_RULE_EVEN_ODD
]

{ #category : #accessing }
AthensCairoCanvas >> fillRuleWinding [
self setFillRule: CAIRO_FILL_RULE_WINDING
]

{ #category : #private }
AthensCairoCanvas >> getCurrentPoint [

Expand All @@ -120,7 +135,7 @@ AthensCairoCanvas >> handle [
^ handle value
]

{ #category : #initialization }
{ #category : #'initialize-release' }
AthensCairoCanvas >> initializeWithSurface: anAthensSurface [
super initializeWithSurface: anAthensSurface.
self paintMode default.
Expand Down Expand Up @@ -272,6 +287,11 @@ AthensCairoCanvas >> setClipRect: aRectOrNil [
]
]

{ #category : #initialization }
AthensCairoCanvas >> setFillRule: aCairoFillRule [
^ self ffiCall: #( void cairo_set_fill_rule ( self, cairo_fill_rule_t aCairoFillRule ) )
]

{ #category : #private }
AthensCairoCanvas >> setFontMatrix: aMatrix [
"
Expand Down
18 changes: 16 additions & 2 deletions src/Athens-Cairo/AthensCairoDefinitions.class.st
Expand Up @@ -16,6 +16,8 @@ Class {
'CAIRO_EXTEND_PAD',
'CAIRO_EXTEND_REFLECT',
'CAIRO_EXTEND_REPEAT',
'CAIRO_FILL_RULE_EVEN_ODD',
'CAIRO_FILL_RULE_WINDING',
'CAIRO_FONT_SLANT_ITALIC',
'CAIRO_FONT_SLANT_NORMAL',
'CAIRO_FONT_SLANT_OBLIQUE',
Expand Down Expand Up @@ -117,6 +119,7 @@ Class {
'CAIRO_SUBPIXEL_ORDER_RGB',
'CAIRO_SUBPIXEL_ORDER_VBGR',
'CAIRO_SUBPIXEL_ORDER_VRGB',
'cairo_fill_rule_t',
'cairo_font_slant_t',
'cairo_font_type_t',
'cairo_font_weight_t',
Expand Down Expand Up @@ -166,7 +169,8 @@ AthensCairoDefinitions class >> initialize [
initialize_cairo_hint_style_t;
initialize_cairo_antialias_t;
init_cairo_subpixel_order_t;
initialize_cairo_hint_metrics_t.
initialize_cairo_hint_metrics_t;
initialize_cairo_fill_rule_t.


]
Expand Down Expand Up @@ -199,6 +203,16 @@ AthensCairoDefinitions class >> initialize_cairo_extend_t [
CAIRO_EXTEND_PAD := 3.
"} cairo_extend_t"

]

{ #category : #initialization }
AthensCairoDefinitions class >> initialize_cairo_fill_rule_t [
" typedef enum _cairo_status {"
CAIRO_FILL_RULE_WINDING := 0.
CAIRO_FILL_RULE_EVEN_ODD := 1.



]

{ #category : #'as yet unclassified' }
Expand Down Expand Up @@ -373,7 +387,7 @@ AthensCairoDefinitions class >> initialize_cairo_status_t [
{ #category : #'as yet unclassified' }
AthensCairoDefinitions class >> initialize_types [

cairo_status_t := cairo_font_type_t := cairo_line_join_t := cairo_line_cap_t := cairo_status_t := cairo_font_slant_t := cairo_font_weight_t := cairo_operator_t := #int.
cairo_status_t := cairo_font_type_t := cairo_line_join_t := cairo_line_cap_t := cairo_status_t := cairo_font_slant_t := cairo_font_weight_t := cairo_operator_t := cairo_fill_rule_t := #int.

cairo_pattern_t := #AthensCairoPatternPaint.

Expand Down
44 changes: 44 additions & 0 deletions src/Athens-Examples/AthensSurfaceExamples.class.st
Expand Up @@ -95,6 +95,50 @@ AthensSurfaceExamples class >> drawFontMetrics [

]

{ #category : #examples }
AthensSurfaceExamples class >> drawSetFillRule [
<example>
self openViewOn: [ :canvas |
| path |
canvas pathTransform
translateBy: 100 asPoint.
"donut"
canvas fillRuleEvenOdd.
path := canvas createPath: [ :builder |
builder
absolute;
moveTo: 50@0;
arcCenterX: 0
centerY: 0
radius: 50
startAngle: 0
endAngle: Float pi * 2;
moveTo: 30@0;
arcCenterX: 0
centerY: 0
radius: 30
startAngle: 0
endAngle: Float pi * 2;
close.
].
"CAIRO_FILL_RULE_WINDING := 0.
CAIRO_FILL_RULE_EVEN_ODD := 1.
self assert: canvas fillRule = 1"
canvas setPaint: Color blue.
canvas drawShape: path.
canvas setStrokePaint: Color red.
canvas drawShape: path.
canvas pathTransform
translateBy: 100 asPoint.
canvas fillRuleWinding.
canvas setPaint: Color red.
canvas drawShape: path.
canvas setStrokePaint: Color blue.
canvas drawShape: path.
]

]

{ #category : #examples }
AthensSurfaceExamples class >> example1 [

Expand Down

0 comments on commit 8d97776

Please sign in to comment.