[squeak-dev] The Inbox: Morphic-ct.1768.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Apr 30 18:02:32 UTC 2021
A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1768.mcz
==================== Summary ====================
Name: Morphic-ct.1768
Author: ct
Time: 30 April 2021, 8:02:20.035293 pm
UUID: 2c143938-6557-0b42-973c-6453d49680cf
Ancestors: Morphic-mt.1767
Fixes a GrafPort bug when drawing round rectangle frames. In the past, the horizontal segments were too wide.
Original snippet to reproduce (provided by Marcel, mt):
morph := Morph new.
morph
extent: 500 at 500;
borderWidth: 50;
borderColor: Color red;
cornerStyle: #rounded;
cornerRadius: 20;
yourself.
morph openInHand.
=============== Diff against Morphic-mt.1767 ===============
Item was changed:
----- Method: GrafPort>>frameRoundRect:radius:borderWidth: (in category 'drawing support') -----
frameRoundRect: aRectangle radius: radius borderWidth: borderWidth
| nextY outer nextOuterX ovalDiameter rectExtent rectOffset rectX rectY rectWidth rectHeight ovalRadius ovalRect innerRadius innerDiameter innerRect inner nextInnerX wp |
aRectangle area <= 0 ifTrue: [^ self].
ovalDiameter := (radius * 2) asPoint min: aRectangle extent.
(ovalDiameter x <= 0 or:[ovalDiameter y <= 0]) ifTrue:[
^self fillRect: aRectangle offset: 0 at 0.
].
"force diameter to be even - this simplifies lots of stuff"
ovalRadius := (ovalDiameter x // 2) @ (ovalDiameter y // 2).
(ovalRadius x <= 0 or:[ovalRadius y <= 0]) ifTrue:[
^self fillRect: aRectangle offset: 0 at 0.
].
wp := borderWidth asPoint.
ovalDiameter := ovalRadius * 2.
innerRadius := ovalRadius - borderWidth max: 0 at 0.
innerDiameter := innerRadius * 2.
rectExtent := aRectangle extent - ovalDiameter.
rectWidth := rectExtent x.
rectHeight := rectExtent y.
rectOffset := aRectangle origin + ovalRadius.
rectX := rectOffset x.
rectY := rectOffset y.
ovalRect := 0 at 0 extent: ovalDiameter.
innerRect := 0 at 0 extent: innerDiameter.
height := 1.
outer := EllipseMidpointTracer new on: ovalRect.
inner := EllipseMidpointTracer new on: innerRect.
nextY := ovalRadius y.
1 to: (wp y min: nextY) do:[:i|
nextOuterX := outer stepInY.
width := nextOuterX * 2 + rectWidth.
destX := rectX - nextOuterX.
destY := rectY - nextY.
self copyBits.
destY := rectY + nextY + rectHeight - 1.
self copyBits.
nextY := nextY - 1.
].
[nextY > 0] whileTrue:[
nextOuterX := outer stepInY.
nextInnerX := inner stepInY.
destX := rectX - nextOuterX.
destY := rectY - nextY.
width := nextOuterX - nextInnerX.
self copyBits.
destX := rectX + nextInnerX + rectWidth.
self copyBits.
destX := rectX - nextOuterX.
destY := rectY + nextY + rectHeight-1.
self copyBits.
destX := rectX + nextInnerX + rectWidth.
self copyBits.
nextY := nextY - 1.
].
destX := aRectangle left.
destY := rectOffset y.
height := rectHeight.
width := wp x.
self copyBits.
destX := aRectangle right - width.
self copyBits.
innerRadius y = 0 ifTrue:[
destX := aRectangle left + wp x.
destY := rectY.
+ width := aRectangle width - (wp x * 2).
- width := rectWidth.
height := wp y - ovalRadius y.
self copyBits.
destY := aRectangle bottom - wp y.
self copyBits.
].!
More information about the Squeak-dev
mailing list
|