pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.22k stars 357 forks source link

Athens does not have a way to set and get the fill rule #2782

Closed akevalion closed 5 years ago

akevalion commented 5 years ago

Steps to reproduce the issue 1 First read this https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-set-fill-rule. 2 Download pharo7 with PharoLauncher 3 execute the next piece of code that creates a donut in athens

| surface |
surface := AthensCairoSurface extent: 300@300.
surface drawDuring: [ :canvas | | path |
    canvas pathTransform
        translateBy: 50@50.
    "donut"
    "canvas setFillRuleEvenOdd."
    path := canvas createPath: [ :builder |  
        builder
            absolute;
            moveTo: 100 @0;
            arcCenterX: 0
                centerY: 0
                radius: 50
                startAngle: 0 
                endAngle: Float pi * 2;
            moveTo: 75@0;
            arcCenterX: 0
                centerY: 0
                radius: 30
                startAngle: 0
                endAngle: Float pi * 2.
             ].
    canvas setPaint: Color blue.
    canvas drawShape: path.
     ].
surface asForm asMorph openInWindow.

4 The result is:

Expected Result:

Athens needs new methods and variables for the following classes 1.

AthensCairoPathBuilder >> setFillRuleEvenOdd
    context setFillRuleEvenOdd

2.

AtthensCairoCanvas >> setFillRuleEvenOdd
    self setFillRule: CAIRO_FILL_RULE_EVEN_ODD

3.

AtthensCairoCanvas >> setFillRule: aCairoFillRule
    ^ self ffiCall: #( void cairo_set_fill_rule ( self, cairo_fill_rule_t aCairoFillRule ) )

4.

AthensCairoDefinitions class >> initialize_cairo_fill_rule_t
    CAIRO_FILL_RULE_WINDING := 0.
    CAIRO_FILL_RULE_EVEN_ODD := 1.

5.

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 := cairo_fill_rule_t := #int.

    cairo_pattern_t := #AthensCairoPatternPaint.

    cairo_t := #AthensCairoCanvas.

    cairo_surface_t := #AthensCairoSurface .
    cairo_text_extents_t := #CairoTextExtents.

And maybe the methods and test to check this behavior

Ducasse commented 5 years ago

Hi milton

Send a PR. Now you should consider that Athens will be deprecated and that we plan to use Sparta and a Sparta adaptation to expose the same API than Athens to user so that they can migrate when they want. I told to alex that it would be super cool if you could check the status of the SpartaAthensBridge and use Sparta for Roassal 3.