Skip to content

Commit

Permalink
Enforce spaces around @
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohn123 committed Jun 9, 2022
1 parent 7a7964a commit 1581894
Show file tree
Hide file tree
Showing 33 changed files with 78 additions and 75 deletions.
3 changes: 3 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ sed -i 's/_/:=/g' $files
#Spaces befor dots
sed -i 's/[ ]\+\./\./g' $files

#Spaces around @
sed -i 's/[ ]*@[ ]*/ @ /g' $files

#Dot after return consistency
sed -i '$s/\.$//' $files
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updateSVG

self svg ifNotNil:
[self addMorph: self svg
fullFrame: (LayoutFrame fractions: (0@0 corner: 1@1))]
fullFrame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 1))]
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ boundsWithTransform: aTransform
tr := aTransform transformPoint: self topRight.
br := aTransform transformPoint: self bottomRight.
bl := aTransform transformPoint: self bottomLeft.
^(((tl x min: tr x) min: br x) min: bl x)@(((tl y min: tr y) min: br y) min: bl y)
corner: (((tl x max: tr x) max: br x) max: bl x)@(((tl y max: tr y) max: br y) max: bl y)
^(((tl x min: tr x) min: br x) min: bl x) @ (((tl y min: tr y) min: br y) min: bl y)
corner: (((tl x max: tr x) max: br x) max: bl x) @ (((tl y max: tr y) max: br y) max: bl y)
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ renderText: anSVGText on: aCanvas
fill := anSVGText composedFontFillStyle.
textFont := anSVGText fontToUse.
anchor := anSVGText composedStyle at: 'text-anchor'.
offset := 0@textFont ascent.
offset := 0 @ textFont ascent.
anchor = 'middle'
ifTrue: [offset := (textFont widthOfString: anSVGText text) // 2@textFont ascent].
ifTrue: [offset := (textFont widthOfString: anSVGText text) // 2 @ textFont ascent].
anchor = 'end'
ifTrue: [offset := (textFont widthOfString: anSVGText text)@textFont ascent].
ifTrue: [offset := (textFont widthOfString: anSVGText text) @ textFont ascent].
aCanvas asBalloonCanvas preserveStateDuring: [:bc|
bc copy
aaLevel: anSVGText antialiasingLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ createRectangleFromSVG: anElement
"Create the bounding rectangle from the svg circle."

self rectangle: (Rectangle
center: (anElement attributeAt: 'cx' ifAbsent: [0]) asSVGNumber@(anElement attributeAt: 'cy' ifAbsent: [0]) asSVGNumber
center: (anElement attributeAt: 'cx' ifAbsent: [0]) asSVGNumber @ (anElement attributeAt: 'cy' ifAbsent: [0]) asSVGNumber
extent: (anElement attributeAt: 'r' ifAbsent: [0]) asSVGNumber asPoint * 2)
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ createFillFromSVGLinearGradient: anElement
linkFill := self getFill: xlink allButFirst.
ramp isEmpty
ifTrue: [ramp :=linkFill colorRamp].
p1 := (anElement attributeAt: 'x1' ifAbsent: [linkFill origin x]) asSVGNumberOrPercentage@(anElement attributeAt: 'y1' ifAbsent: [linkFill origin y]) asSVGNumberOrPercentage.
p2 := (anElement attributeAt: 'x2' ifAbsent: [linkFill direction x]) asSVGNumberOrPercentage@(anElement attributeAt: 'y2' ifAbsent: [linkFill direction y]) asSVGNumberOrPercentage]
p1 := (anElement attributeAt: 'x1' ifAbsent: [linkFill origin x]) asSVGNumberOrPercentage @ (anElement attributeAt: 'y1' ifAbsent: [linkFill origin y]) asSVGNumberOrPercentage.
p2 := (anElement attributeAt: 'x2' ifAbsent: [linkFill direction x]) asSVGNumberOrPercentage @ (anElement attributeAt: 'y2' ifAbsent: [linkFill direction y]) asSVGNumberOrPercentage]
ifFalse: [
p1 := (anElement attributeAt: 'x1' ifAbsent: [0]) asSVGNumberOrPercentage@(anElement attributeAt: 'y1' ifAbsent: [0]) asSVGNumberOrPercentage.
p2 := (anElement attributeAt: 'x2' ifAbsent: [100]) asSVGNumberOrPercentage@(anElement attributeAt: 'y2' ifAbsent: [100]) asSVGNumberOrPercentage].
p1 := (anElement attributeAt: 'x1' ifAbsent: [0]) asSVGNumberOrPercentage @ (anElement attributeAt: 'y1' ifAbsent: [0]) asSVGNumberOrPercentage.
p2 := (anElement attributeAt: 'x2' ifAbsent: [100]) asSVGNumberOrPercentage @ (anElement attributeAt: 'y2' ifAbsent: [100]) asSVGNumberOrPercentage].
p1 := trans transformPoint: p1.
p2 := trans transformPoint: p2.
self setFill: idg to: ((SVGGradientFillStyle ramp: ramp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ createFillFromSVGRadialGradient: anElement
linkFill := self getFill: xlink copyWithoutFirst.
ramp isEmpty
ifTrue: [ramp :=linkFill colorRamp].
p1 := (anElement attributeAt: 'cx' ifAbsent: [linkFill origin x]) asSVGNumberOrPercentage@(anElement attributeAt: 'cy' ifAbsent: [linkFill origin y]) asSVGNumberOrPercentage.
p1 := (anElement attributeAt: 'cx' ifAbsent: [linkFill origin x]) asSVGNumberOrPercentage @ (anElement attributeAt: 'cy' ifAbsent: [linkFill origin y]) asSVGNumberOrPercentage.
p2 := (anElement attributeAt: 'r' ifAbsent: [linkFill direction x]) asSVGNumberOrPercentage asPoint]
ifFalse: [
p1 := (anElement attributeAt: 'cx' ifAbsent: [50]) asSVGNumberOrPercentage@(anElement attributeAt: 'cy' ifAbsent: [50]) asSVGNumberOrPercentage.
p1 := (anElement attributeAt: 'cx' ifAbsent: [50]) asSVGNumberOrPercentage @ (anElement attributeAt: 'cy' ifAbsent: [50]) asSVGNumberOrPercentage.
p2 := (anElement attributeAt: 'r' ifAbsent: [50]) asSVGNumberOrPercentage asPoint].
origin := trans transformPoint: p1.
direction := (trans transformPoint: p2 + p1) - origin.
self setFill: idg to: ((SVGGradientFillStyle ramp: ramp)
origin: origin;
direction: direction x@0;
normal: 0@direction y;
direction: direction x @ 0;
normal: 0 @ direction y;
radial: true;
units: (anElement attributeAt: 'gradientUnits' ifAbsent: [#userSpaceOnUse]) asSymbol;
spread: (anElement attributeAt: 'spreadMethod' ifAbsent: [#pad]) asSymbol)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ createRectangleFromSVG: anElement
"Create the bounding rectangle from the svg ellipse."

self rectangle: (Rectangle
center: (anElement attributeAt: 'cx' ifAbsent: [0]) asSVGNumber@(anElement attributeAt: 'cy' ifAbsent: [0]) asSVGNumber
extent: (anElement attributeAt: 'rx' ifAbsent: [0]) asSVGNumber@((anElement attributeAt: 'ry' ifAbsent: [0]) asSVGNumber) * 2)
center: (anElement attributeAt: 'cx' ifAbsent: [0]) asSVGNumber @ (anElement attributeAt: 'cy' ifAbsent: [0]) asSVGNumber
extent: (anElement attributeAt: 'rx' ifAbsent: [0]) asSVGNumber @ ((anElement attributeAt: 'ry' ifAbsent: [0]) asSVGNumber) * 2)
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ computeBounds
ifNil:[box := subBounds]
ifNotNil:[box := box quickMerge: subBounds].
].
box ifNil:[box := 0@0 corner: 20@20].
box ifNil:[box := 0 @ 0 corner: 20 @ 20].
fullBounds := bounds := box
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ createRectangleFromSVG: anElement
"Create the segments from the rect."

self
rectangle: ((anElement attributeAt: 'x1' ifAbsent: [0]) asSVGNumber@(anElement attributeAt: 'y1' ifAbsent: [0]) asSVGNumber
corner: (anElement attributeAt: 'x2' ifAbsent: [0]) asSVGNumber@(anElement attributeAt: 'y2' ifAbsent: [0]) asSVGNumber)
rectangle: ((anElement attributeAt: 'x1' ifAbsent: [0]) asSVGNumber @ (anElement attributeAt: 'y1' ifAbsent: [0]) asSVGNumber
corner: (anElement attributeAt: 'x2' ifAbsent: [0]) asSVGNumber @ (anElement attributeAt: 'y2' ifAbsent: [0]) asSVGNumber)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ example
w extent: svg extent.
w
addMorph: svg
frame: (0@0 corner: 1@1);
frame: (0 @ 0 corner: 1 @ 1);
clipSubmorphs: true;
openAsIs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ accessing
defaultViewBox
"Set the receiver's dimensions from the given svg element."

^0@0 extent: 300@150
^0 @ 0 extent: 300 @ 150
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ setDimensionsFromSVG: anElement
viewBox := str isNil
ifTrue: [self defaultViewBox]
ifFalse: [str := str readStream.
str nextNumber@str nextNumber extent: str nextNumber@str nextNumber].
str nextNumber @ str nextNumber extent: str nextNumber @ str nextNumber].
(w withBlanksTrimmed endsWith: '%')
ifTrue: [viewBox := viewBox withWidth: viewBox width * w asNumber // 100]
ifFalse: [(w withBlanksTrimmed endsWith: 'mm')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ createArcSegmentFrom: data at: aPoint
Evil apporximation required for compatability with Balloon - no arcs!"

|position radii angle sweep large sp cp pd num root s cd c theta1 dtheta nSegs delta t ps|
radii := (data first@data second) abs.
radii := (data first @ data second) abs.
angle := data third degreesToRadians.
large := data fourth = 1.
sweep := data fifth = 1.
position := data sixth@data seventh.
position := data sixth @ data seventh.
ps := aPoint.

position = aPoint
Expand All @@ -19,7 +19,7 @@ createArcSegmentFrom: data at: aPoint

sp := angle sin.
cp := angle cos.
pd := (cp * (ps x - position x) + (sp * (ps y - position y)) @
pd := (cp * (ps x - position x) + (sp * (ps y - position y)) @
(sp negated * (ps x - position x) + (cp * (ps y - position y)))) / 2.
num := radii x squared * radii y squared - (radii x squared * pd y squared) - (radii y squared * pd x squared).
num < 0
Expand All @@ -30,9 +30,9 @@ createArcSegmentFrom: data at: aPoint
(num / (radii x squared * pd y squared + (radii y squared * pd x squared))) sqrt].
cd := root * radii * pd transposed / radii transposed.
cd := cd x @ cd y negated.
c := cp * cd x - (sp * cd y) + (ps x + position x / 2) @
c := cp * cd x - (sp * cd y) + (ps x + position x / 2) @
(sp * cd x + (cp * cd y) + (ps y + position y / 2)).
theta1 := 1@0 angleWith: pd - cd / radii.
theta1 := 1 @ 0 angleWith: pd - cd / radii.
dtheta := pd - cd / radii angleWith: pd negated - cd / radii.
(sweep not and: [dtheta > 0])
ifTrue: [dtheta := dtheta - (2 * Float pi)]
Expand All @@ -47,11 +47,11 @@ createArcSegmentFrom: data at: aPoint
theta2 := theta1 + delta.
ct2 := theta2 cos.
st2 := theta2 sin.
pe := cp * radii x * ct2 - (sp * radii y * st2) + c x @
pe := cp * radii x * ct2 - (sp * radii y * st2) + c x @
(sp * radii x * ct2 + (cp * radii y * st2) + c y).
ds := t * ((cp negated * radii x * st1 - (sp * radii y * ct1)) @
ds := t * ((cp negated * radii x * st1 - (sp * radii y * ct1)) @
(sp negated * radii x * st1 + (cp * radii y*ct1))).
de := t * ((cp * radii x * st2 + (sp * radii y * ct2)) @
de := t * ((cp * radii x * st2 + (sp * radii y * ct2)) @
(sp * radii x * st2 - (cp * radii y*ct2))).
self
createCubicBezierSegmentFrom: ps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ createCubicBezierSegmentFrom: data at: aPoint
|position|
self
createCubicBezierSegmentFrom: aPoint
via: data first@data second
and: data third@data fourth
to: (position := data fifth@data sixth).
via: data first @ data second
and: data third @ data fourth
to: (position := data fifth @ data sixth).
^position
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ createLineSegmentFrom: data at: aPoint
"Create a line segment from the path data (stream) at the given position."

|position|
self createLineSegmentFrom: aPoint to: (position := data first@data second).
self createLineSegmentFrom: aPoint to: (position := data first @ data second).
^position
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ createQuadraticBezierSegmentFrom: data at: aPoint
|position|
self
createQuadraticBezierSegmentFrom: aPoint
via: data first@data second
to: (position := data third@data fourth).
via: data first @ data second
to: (position := data third @ data fourth).
^position
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ createSegmentsFromSVG: anElement
c := nil.
initialPosition := nil.
data := self pathDataFromSVG: anElement.
position := 0@0.
position := 0 @ 0.
data do: [:cmd |
((cmd = $S or: [cmd = $s]) and: ['CcSs' includes: c not])
ifTrue: [lastCubicControl := position].
Expand All @@ -15,14 +15,14 @@ createSegmentsFromSVG: anElement
c := cmd key.
d := cmd value.
c = $M
ifTrue: [position := d first@d second.
ifTrue: [position := d first @ d second.
initialPosition isNil
ifTrue: [initialPosition := position].
subpathStartPosition := position].
c = $m
ifTrue: [initialPosition isNil
ifTrue: [position := d first@d second. initialPosition := position]
ifFalse: [position := position + (d first@d second)].
ifTrue: [position := d first @ d second. initialPosition := position]
ifFalse: [position := position + (d first @ d second)].
subpathStartPosition := position].
c = $A
ifTrue: [position := self createArcSegmentFrom: d at: position].
Expand Down Expand Up @@ -53,54 +53,54 @@ createSegmentsFromSVG: anElement
d at: 2 put: (d second + position y).
position := self createLineSegmentFrom: d at: position].
c = $C
ifTrue: [lastCubicControl := d third@d fourth.
ifTrue: [lastCubicControl := d third @ d fourth.
position := self createCubicBezierSegmentFrom: d at: position].
c = $c
ifTrue: [d at: 1 put: (d first + position x).
d at: 2 put: (d second + position y).
d at: 3 put: (d third + position x).
d at: 4 put: (d fourth + position y).
lastCubicControl := d third@d fourth.
lastCubicControl := d third @ d fourth.
d at: 5 put: (d fifth + position x).
d at: 6 put: (d sixth + position y).
position := self createCubicBezierSegmentFrom: d at: position].
c = $S
ifTrue: [lastCubicControl := lastCubicControl reflectedAbout: position.
d addFirst: lastCubicControl y.
d addFirst: lastCubicControl x.
lastCubicControl := d third@d fourth.
lastCubicControl := d third @ d fourth.
position := self createCubicBezierSegmentFrom: d at: position].
c = $s
ifTrue: [lastCubicControl := lastCubicControl reflectedAbout: position.
d addFirst: lastCubicControl y.
d addFirst: lastCubicControl x.
d at: 3 put: (d third + position x).
d at: 4 put: (d fourth + position y).
lastCubicControl := d third@d fourth.
lastCubicControl := d third @ d fourth.
d at: 5 put: (d fifth + position x).
d at: 6 put: (d sixth + position y).
position := self createCubicBezierSegmentFrom: d at: position].
c = $Q
ifTrue: [lastQuadraticControl := d first@d second.
ifTrue: [lastQuadraticControl := d first @ d second.
position := self createQuadraticBezierSegmentFrom: d at: position].
c = $q
ifTrue: [d at: 1 put: (d first + position x).
d at: 2 put: (d second + position y).
lastQuadraticControl := d first@d second.
lastQuadraticControl := d first @ d second.
d at: 3 put: (d third + position x).
d at: 4 put: (d fourth + position y).
position := self createQuadraticBezierSegmentFrom: d at: position].
c = $T
ifTrue: [lastQuadraticControl := lastQuadraticControl reflectedAbout: position.
d addFirst: lastQuadraticControl y.
d addFirst: lastQuadraticControl x.
lastQuadraticControl := d first@d second.
lastQuadraticControl := d first @ d second.
position := self createQuadraticBezierSegmentFrom: d at: position].
c = $t
ifTrue: [lastQuadraticControl := lastQuadraticControl reflectedAbout: position.
d addFirst: lastQuadraticControl y.
d addFirst: lastQuadraticControl x.
lastQuadraticControl := d first@d second.
lastQuadraticControl := d first @ d second.
d at: 3 put: (d third + position x).
d at: 4 put: (d fourth + position y).
position := self createQuadraticBezierSegmentFrom: d at: position].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ createRectangleFromSVG: anElement
"Create the segments from the rect."

self
rectangle: ((anElement attributeAt: 'x' ifAbsent: [0]) asSVGNumber@(anElement attributeAt: 'y' ifAbsent: [0]) asSVGNumber
extent: (anElement attributeAt: 'width') asSVGNumber@(anElement attributeAt: 'height') asSVGNumber)
rectangle: ((anElement attributeAt: 'x' ifAbsent: [0]) asSVGNumber @ (anElement attributeAt: 'y' ifAbsent: [0]) asSVGNumber
extent: (anElement attributeAt: 'width') asSVGNumber @ (anElement attributeAt: 'height') asSVGNumber)
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ createTextFromSVG: anElement

super createTextFromSVG: anElement.
self location:
(anElement attributeAt: 'x' ifAbsent: [self owner location x]) asSVGNumber @
(anElement attributeAt: 'x' ifAbsent: [self owner location x]) asSVGNumber @
(anElement attributeAt: 'y' ifAbsent: [self owner location y]) asSVGNumber
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ computeBounds
|fontSize textFont anchor offset ptSize|
fontSize := (self composedStyle at: 'font-size').
textFont := self composedStyle at: 'font'.
ptSize := (fontSize@0) x rounded - 1 max: 1.
ptSize := (fontSize @ 0) x rounded - 1 max: 1.
textFont := TTCFontSet familyName: textFont familyName pointSize: ptSize.
anchor := self composedStyle at: 'text-anchor'.
offset := 0@textFont ascent.
offset := 0 @ textFont ascent.
anchor = 'middle'
ifTrue: [offset := (textFont widthOfString: self text) // 2@textFont ascent].
ifTrue: [offset := (textFont widthOfString: self text) // 2 @ textFont ascent].
anchor = 'end'
ifTrue: [offset := (textFont widthOfString: self text)@textFont ascent].
bounds := fullBounds := self transform localBoundsToGlobal: ((self location) - offset extent: (textFont widthOfString: self text)@textFont height)
ifTrue: [offset := (textFont widthOfString: self text) @ textFont ascent].
bounds := fullBounds := self transform localBoundsToGlobal: ((self location) - offset extent: (textFont widthOfString: self text) @ textFont height)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ createTextFromSVG: anElement
Doen't handle tspans yet!"

self text: anElement characterData.
self location: (anElement attributeAt: 'x' ifAbsent: [0]) asSVGNumber@(anElement attributeAt: 'y' ifAbsent: [0]) asSVGNumber
self location: (anElement attributeAt: 'x' ifAbsent: [0]) asSVGNumber @ (anElement attributeAt: 'y' ifAbsent: [0]) asSVGNumber
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fontToUse
trans := self transformFrom: self world.
fontSize := (self composedStyle at: 'font-size').
textFont := self composedStyle at: 'font'.
ptSize := (trans transformDirection: fontSize@0) x rounded max: 1.
ptSize := (trans transformDirection: fontSize @ 0) x rounded max: 1.
"textFont := TTCFontSet familyName: textFont familyName pointSize: ptSize."
textFont isTTCFont
ifTrue: [textFont := (TextStyle named: textFont familyName) addNewFontSize: ptSize]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ userSpaceBoundingBoxWithRespectTo: aComposite
trans := self transformFrom: aComposite.
fontSize := (self composedStyle at: 'font-size').
textFont := self composedStyle at: 'font'.
ptSize := (trans transformDirection: fontSize@0) x rounded - 1 max: 1.
ptSize := (trans transformDirection: fontSize @ 0) x rounded - 1 max: 1.
textFont := TTCFontSet familyName: textFont familyName pointSize: ptSize.
anchor := self composedStyle at: 'text-anchor'.
offset := 0@textFont ascent.
offset := 0 @ textFont ascent.
anchor = 'middle'
ifTrue: [offset := (textFont widthOfString: self text) // 2@textFont ascent].
ifTrue: [offset := (textFont widthOfString: self text) // 2 @ textFont ascent].
anchor = 'end'
ifTrue: [offset := (textFont widthOfString: self text)@textFont ascent].
^(trans transformPoint: self location) - offset extent: (textFont widthOfString: self text)@textFont height
ifTrue: [offset := (textFont widthOfString: self text) @ textFont ascent].
^(trans transformPoint: self location) - offset extent: (textFont widthOfString: self text) @ textFont height
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ testCircle

self
hasValue: 'Circle' atKey: 'Type' in: panelInfo;
hasValue: '30@40' atKey: 'Position' in: panelInfo;
hasValue: '30 @ 40' atKey: 'Position' in: panelInfo;
hasValue: '60' atKey: 'Radius' in: panelInfo
Loading

0 comments on commit 1581894

Please sign in to comment.