Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not all shapes support borderColor/borderWidth #1097

Closed
seandenigris opened this issue Aug 3, 2015 · 9 comments
Closed

Not all shapes support borderColor/borderWidth #1097

seandenigris opened this issue Aug 3, 2015 · 9 comments

Comments

@seandenigris
Copy link
Contributor

Originally reported on Google Code with ID 1097

Some shapes are using the default stroke and/or the default stroke width, even if the
user sets a borderColor/borderWidth

|v ver circle box poly es |
v := RTView new.
ver := (1 to:5)collect:[:i | Point r:100 degrees:(360/5*i)].
circle := RTEllipse new size: 200; color: Color red; borderWidth:5;borderColor: Color
green.
box  := RTBox new size: 200; color: Color red; borderWidth:5;borderColor: Color green.
poly  := RTPolygon new size: 200; vertices:ver; color: Color red; borderWidth:5;borderColor:
Color green.
es := circle elementOn:'hello'. 
v add: es.
es := box elementOn:'hello'. 
v add: es.
es := poly elementOn:'hello'. 
v add: es.
v @ RTDraggableView .
RTGridLayout on: v elements.
v 

"all shapes should use the provided borderWidth (5) and borderColor (Green)"

moose build 3147

* Type-Defect
* Component-Roassal2

Reported by nicolaihess on 2014-11-13 11:40:38


- _Attachment: shapes.png
![shapes.png](https://storage.googleapis.com/google-code-attachments/moose-technology/issue-1097/comment-0/shapes.png)_
@seandenigris
Copy link
Contributor Author

Version 602 of Roassal.mcz and Trachel-AlexandreBergel.239 addresses the bug with RTPolygon.
For RTEllipse, I am not sure how to fix that...

Reported by alexandre.bergel on 2014-11-13 18:42:51

@seandenigris
Copy link
Contributor Author

It is possible to draw an ellipse with a uniform scaled stroke (with cairo).
Athens just don't expose this api. (there was a lenghtly discussion with no result
http://forum.world.st/Athens-and-ellipse-drawing-tt4754256.html#a4765659)
Here is an example for an ellipse with uniform stroke.

    | view |
    view := AthensSceneView new.
    view
        scene: [ :canvas | 
            | stroke ellipse |
            canvas surface clear: Color black.
            canvas pathTransform
                restoreAfter: [ 
                    canvas pathTransform scaleBy: 1 @ 2.
                    ellipse := canvas
                        createPath: [ :builder | 
                            builder
                                absolute;
                                moveTo: 10 @ 75;
                                ccwArcTo: 75 @ 140 angle: 90 degreesToRadians;
                                ccwArcTo: 140 @ 75 angle: 90 degreesToRadians;
                                ccwArcTo: 75 @ 10 angle: 90 degreesToRadians;
                                ccwArcTo: 10 @ 75 angle: 90 degreesToRadians ].
                    canvas setPaint: Color blue.
                    canvas setShape: ellipse.
                    canvas draw.
                    stroke := canvas setStrokePaint: Color red.
                    stroke width: 8.
                    "---------------- all the following uses athens-cairos PRIVATE api --------------"
                    "load the path with the current active (scaled) matrix"
                    canvas newPath.
                    canvas loadPath: ellipse ].
            "explicit set the (restored/identity) pathMatrix"
            canvas setPathMatrix.   
            "dont call draw it would again load the path with the now active pathtransform" 
            "just load the color and render the stroke"
            stroke prepareForDrawingOn: canvas.
            canvas stroke ].
    view openInWindow.

Reported by nicolaihess on 2014-11-15 00:08:39

@seandenigris
Copy link
Contributor Author

borderWidth/borderColor works for polygon shapes, but RTPolygon does not initializes
the stroke property therefore, methos like examplePolygons throws a MNU:
MessageNotUnderstood: receiver of ""asAthensPaintOn:"" is nil

Reported by nicolaihess on 2014-11-15 12:23:27

@seandenigris
Copy link
Contributor Author

Is this still an issue?

Reported by tudor@tudorgirba.com on 2014-11-25 11:20:24

@seandenigris
Copy link
Contributor Author

yes, RTPolygon can not be used without explicitly setting the border color.
(can I get right access to the roassal repository)

For drawing ellipse with a uniform border width we need a change in athens drawing
api.
(we should discuss this on pharo-dev)

Reported by nicolaihess on 2014-11-25 12:35:58

@seandenigris
Copy link
Contributor Author

As per the linked thread, you can do it with the athens drawing API already..

ellipsisOfExtent := [:builder :anExtent | | halfX halfY | 
            halfX := anExtent x / 2. 
                halfY := anExtent y / 2. 
                "We expect relative builder, and start the ellipsis at anExtent x /
2 @ 0" 
                builder 
                        curveVia: 0@(halfY negated * 0.55) and: (0.45 * halfX)@halfY
negated to: halfX@ halfY negated; 
                        curveVia: halfX* 0.55 @ 0 and: halfX@ (0.45 * halfY) to: halfX
@ halfY; 
                        curveVia: 0 @ (halfY * 0.55 ) and: (0.45 * halfX negated @
halfY) to: halfX negated @ halfY; 
                        curveVia: (halfX negated * 0.55) @ 0 and: halfX negated @ (halfY
negated * 0.45) to: halfX negated @ halfY negated; 
                        close]. 

AthensSceneView new 
        scene: [ :can | 
                | path | 

        path := can 
                                createPath: [ :builder | 
                                        builder moveTo: 10@60. 
                                        ellipsisOfExtent value: builder value: 200@100
]. 
        (can setPaint: Color blue;
            drawShape: path;
                setStrokePaint: Color red) 
                width: 8 asFloat. 
        can drawShape:  path ] ; 
        openInWindow 

Reported by rydier on 2014-12-03 11:46:30

@seandenigris
Copy link
Contributor Author

What is indeed impossible in Athens, is drawing unscaled strokes on a scaled path, since
path scaling only occurs as part of drawing, not creation.

The above avoids that by using no scaling to draw the ellipse.

Reported by rydier on 2014-12-03 11:57:22

@seandenigris
Copy link
Contributor Author


Ah thank you,
I thought this kind of "ellipsis" wouldn't be like a real ellipse and would look different,
but it looks quite similar (can not see any a difference).
We should take this solution.

I attached a changeset with the above mentioned ellipse drawing.
And Polygonshapes with no border are working again.

I moved the strokeWidth, and accessors and the method drawStrokeIfNecessaryOn:
up to the TRShape class


Reported by nicolaihess on 2014-12-03 21:21:50


- _Attachment: [issue_1097_border_for_all_shapes.cs](https://storage.googleapis.com/google-code-attachments/moose-technology/issue-1097/comment-9/issue_1097_border_for_all_shapes.cs)_

@girba
Copy link
Member

girba commented Jun 9, 2017

This is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants