Skip to content

Commit

Permalink
Add little script
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohn123 committed Jun 9, 2022
1 parent dd32d54 commit 38f628b
Show file tree
Hide file tree
Showing 28 changed files with 76 additions and 46 deletions.
29 changes: 29 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
files=$(find . -type f -name "*.st")

#Trailing whitespace
sed -i -e 's/[ \t]*$//' $files

#Point before parentheses
sed -i 's/\.)/)/g' $files
sed -i 's/\.]/]/g' $files
sed -i 's/\.}/}/g' $files

#Space before parentheses
sed -i 's/[ ]\+)/)/g' $files
sed -i 's/[ ]\+]/]/g' $files
sed -i 's/[ ]\+}/}/g' $files

#Space after parentheses
sed -i 's/\[[ ]\+/[/g' $files
sed -i 's/([ ]\+/(/g' $files
sed -i 's/{[ ]\+/{/g' $files

#Old syntax to new syntax
sed -i 's/_/:=/g' $files

#Spaces befor dots
sed -i 's/[ ]\+\./\./g' $files

#Dot after return consistency
sed -i '$s/\.$//' $files
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
helpers
readStylesOf: aMorph

aMorph style keysAndValuesDo: [ :key :value |
aMorph style keysAndValuesDo: [:key :value |
self at: key put: value asString]
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ updating
updateSVG

self svg ifNotNil:
[ self removeMorph: self svg ].
[self removeMorph: self svg].

self svg: (self model perform: self svgSelector).

self svg ifNotNil:
[ self addMorph: self svg
fullFrame: (LayoutFrame fractions: (0@0 corner: 1@1)) ]
[self addMorph: self svg
fullFrame: (LayoutFrame fractions: (0@0 corner: 1@1))]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ asBezier2Shape: pixelError
pts := PointArray new: curves * 3.
step := 1.0 / (curves * 2).
prev := self start.
1 to: curves do: [ :c |
1 to: curves do: [:c |
index := 3*c.
a := pts at: index-2 put: prev.
b := (self valueAt: (c*2-1)*step).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ renderPolygon: anSVGPolygon on: aCanvas
lineWidth := anSVGPolygon composedStyle at: 'stroke-width'.
lineColor := anSVGPolygon composedStyle at: 'stroke'.
aCanvas asBalloonCanvas preserveStateDuring: [:bc|
bc transformBy: (anSVGPolygon transformFrom: anSVGPolygon world ) during: [:balloonCanvas |
bc transformBy: (anSVGPolygon transformFrom: anSVGPolygon world) during: [:balloonCanvas |
balloonCanvas
aaLevel: anSVGPolygon antialiasingLevel;
drawPolygon: anSVGPolygon points asArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ transformFromSVGAttributeStream: str

| matrix type argStream args |
matrix := MatrixTransform2x3 identity.
type := str upToAny: { $(. Character space. Character tab. Character cr. Character lf}.
type := str upToAny: {$(. Character space. Character tab. Character cr. Character lf}.
str upTo: $(.
argStream := (str upTo: $)) readStream.
args := OrderedCollection new.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
serializer
applyStyleOf: aMorph on: anXMLElement

aMorph style keysAndValuesDo: [ :key :value |
aMorph style keysAndValuesDo: [:key :value |
|convertedValue|
convertedValue := value.
((key = 'stroke') or: [key = 'fill'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ applyTransformOf: aMorph on: anXMLElement
description := OrderedCollection new.
temp := transform compositeTranslation.
(temp closeTo: 0 @ 0)
ifFalse: [description add: ('translate({1},{2})' format: { self printNum: temp x. self printNum: temp y })].
ifFalse: [description add: ('translate({1},{2})' format: {self printNum: temp x. self printNum: temp y})].
temp := transform compositeRotation.
(temp closeTo: 0)
ifFalse: [description add: ('rotate({1})' format: { self printNum: temp })].
ifFalse: [description add: ('rotate({1})' format: {self printNum: temp})].
temp := transform compositeScale.
(temp closeTo: 1 @ 1)
ifFalse: [description add: ('scale({1},{2})' format: { self printNum: temp x. self printNum: temp y })].
ifFalse: [description add: ('scale({1},{2})' format: {self printNum: temp x. self printNum: temp y})].
temp := transform compositeSkew.
(temp closeTo: 0)
ifFalse: [description add: ('skewY({1})' format: { self printNum: temp })].
ifFalse: [description add: ('skewY({1})' format: {self printNum: temp})].

anXMLElement attributeAt: 'transform' put: (description joinSeparatedBy: ',')
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mappedToBounds: aRectangle
|o|
self mapsToObjectBounds
ifTrue: [^self copy
origin: (o := aRectangle origin + ( self origin * aRectangle extent));
origin: (o := aRectangle origin + (self origin * aRectangle extent));
direction: self direction + self origin * aRectangle extent - o;
normal: nil].
^self
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ as yet unclassified
fileReaderServicesForFile: fullName suffix: suffix
"registers the given class as providing services for reading files with Fileservices"

^({ 'svg'. 'svgz' } includes: suffix)
ifTrue: [ self services ]
ifFalse: [ #() ]
^({'svg'. 'svgz'} includes: suffix)
ifTrue: [self services]
ifFalse: [#()]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
testing
fetchClasses: aCollection

aCollection do: [ :aClass |
aCollection do: [:aClass |
aClass category ifNotNil: [
(self category: aClass category)
add: aClass name]]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test ing - single
testRotation

{0. 1. 30. 90 . 120. 179. 180. -1. -89. -90. -120 }
{0. 1. 30. 90. 120. 179. 180. -1. -89. -90. -120}
do: [:anAngle | self assert: anAngle closeTo: (MatrixTransform2x3 withAngle: anAngle) compositeRotation]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test ing - single
testScale

{ 1 @ 1. 1 @ 2. 2 @ 1. -2 @ 1 . 1000 @ 5000. 0 @ 1. 0.45 @ 0.867}
{1 @ 1. 1 @ 2. 2 @ 1. -2 @ 1. 1000 @ 5000. 0 @ 1. 0.45 @ 0.867}
do: [:aPoint | self assert: aPoint closeTo: (MatrixTransform2x3 withScale: aPoint) compositeScale]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test ing - single
testSkew

{0. 1. 30. 89 . -1. -30. -80 }
do: [:anAngle | self assert: anAngle closeTo: (MatrixTransform2x3 withSkew: anAngle @ 0 ) compositeSkew]
{0. 1. 30. 89. -1. -30. -80}
do: [:anAngle | self assert: anAngle closeTo: (MatrixTransform2x3 withSkew: anAngle @ 0) compositeSkew]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test ing - single
testTranslate

{ 1 @ 1. 1 @ 2. 2 @ 1. -2 @ 1 . 1000 @ 5000. 0 @ 1}
{1 @ 1. 1 @ 2. 2 @ 1. -2 @ 1. 1000 @ 5000. 0 @ 1}
do: [:aPoint | self assert: aPoint closeTo: (MatrixTransform2x3 withOffset: aPoint) compositeTranslation]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
testing - properties
submorphBoundsOf: aMorph

^ ((aMorph submorphs collect: [ :submorph | submorph bounds origin x]) asSortedArray first) @
((aMorph submorphs collect: [ :submorph | submorph bounds origin y]) asSortedArray first)
corner: ((aMorph submorphs collect: [ :submorph | submorph bounds corner x]) asSortedArray last) @
((aMorph submorphs collect: [ :submorph | submorph bounds corner y]) asSortedArray last)
^ ((aMorph submorphs collect: [:submorph | submorph bounds origin x]) asSortedArray first) @
((aMorph submorphs collect: [:submorph | submorph bounds origin y]) asSortedArray first)
corner: ((aMorph submorphs collect: [:submorph | submorph bounds corner x]) asSortedArray last) @
((aMorph submorphs collect: [:submorph | submorph bounds corner y]) asSortedArray last)
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ width, height, viewBox parsing
testBoundsNegativeViewBox
|sv|
sv := SVGMorph fromString: self negativeViewBoxSVG.
self assert: (Rectangle origin: ( -200 @ -50) extent: 100 @ 100) equals: sv bounds
self assert: (Rectangle origin: (-200 @ -50) extent: 100 @ 100) equals: sv bounds
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ testForBlackStroke

|blackStrokeObjects blackStrokeMorphs|
blackStrokeObjects := self blackStrokeObjects.
blackStrokeMorphs := blackStrokeObjects collect: [ :aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^blackStrokeMorphs do: [ :aSVGMorph| self testStrokeIn: aSVGMorph with: Color black]
blackStrokeMorphs := blackStrokeObjects collect: [:aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^blackStrokeMorphs do: [:aSVGMorph| self testStrokeIn: aSVGMorph with: Color black]
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ testForBlackStrokeWidth

|blackStrokeObjects blackStrokeMorphs|
blackStrokeObjects := self blackStrokeObjects.
blackStrokeMorphs := blackStrokeObjects collect: [ :aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^blackStrokeMorphs do: [ :aSVGMorph| self testStrokeWidth: aSVGMorph with: 5]
blackStrokeMorphs := blackStrokeObjects collect: [:aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^blackStrokeMorphs do: [:aSVGMorph| self testStrokeWidth: aSVGMorph with: 5]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ testForBlueFill

|blueFillObjects blueFillMorphs|
blueFillObjects := self blueFillObjects.
blueFillMorphs := blueFillObjects collect: [ :aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^blueFillMorphs do: [ :aSVGMorph| self testFillIn: aSVGMorph with: Color blue].
blueFillMorphs := blueFillObjects collect: [:aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^blueFillMorphs do: [:aSVGMorph| self testFillIn: aSVGMorph with: Color blue].

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ testForBrownStroke

|brownStrokeobjects brownStrokeMorphs|
brownStrokeobjects := self brownStrokeObjects.
brownStrokeMorphs := brownStrokeobjects collect: [ :aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^brownStrokeMorphs do: [ :aSVGMorph| self testStrokeIn: aSVGMorph with: (Color r: 0.647 g: 0.164 b: 0.164)]
brownStrokeMorphs := brownStrokeobjects collect: [:aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^brownStrokeMorphs do: [:aSVGMorph| self testStrokeIn: aSVGMorph with: (Color r: 0.647 g: 0.164 b: 0.164)]
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ testForBrownStrokeWidth

|brownStrokeObjects brownStrokeMorphs|
brownStrokeObjects := self brownStrokeObjects.
brownStrokeMorphs := brownStrokeObjects collect: [ :aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^brownStrokeMorphs do: [ :aSVGMorph| self testStrokeWidth: aSVGMorph with: 50]
brownStrokeMorphs := brownStrokeObjects collect: [:aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^brownStrokeMorphs do: [:aSVGMorph| self testStrokeWidth: aSVGMorph with: 50]
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ testForOrangeStroke

|orangeStrokeObjects orangeStrokeMorphs|
orangeStrokeObjects := self orangeStrokeObjects.
orangeStrokeMorphs := orangeStrokeObjects collect: [ :aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^orangeStrokeMorphs do: [ :aSVGMorph| self testStrokeIn: aSVGMorph with: (Color r: 1 g: 0.647 b: 0.0)]
orangeStrokeMorphs := orangeStrokeObjects collect: [:aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^orangeStrokeMorphs do: [:aSVGMorph| self testStrokeIn: aSVGMorph with: (Color r: 1 g: 0.647 b: 0.0)]
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ testForOrangeStrokeWidth

|orangeStrokeObjects orangeStrokeMorphs|
orangeStrokeObjects := self orangeStrokeObjects.
orangeStrokeMorphs := orangeStrokeObjects collect: [ :aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^orangeStrokeMorphs do: [ :aSVGMorph| self testStrokeWidth: aSVGMorph with: 10]
orangeStrokeMorphs := orangeStrokeObjects collect: [:aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^orangeStrokeMorphs do: [:aSVGMorph| self testStrokeWidth: aSVGMorph with: 10]
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ testForRedFill

|redFillObjects redFillMorphs|
redFillObjects := self redFillObjects.
redFillMorphs:= redFillObjects collect: [ :aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^redFillMorphs do: [ :aSVGMorph| self testFillIn: aSVGMorph with: Color red]
redFillMorphs:= redFillObjects collect: [:aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^redFillMorphs do: [:aSVGMorph| self testFillIn: aSVGMorph with: Color red]
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ testForTransparentFill

|transparentFillObjects transparentFillMorphs|
transparentFillObjects := self transparentFillObjects.
transparentFillMorphs := transparentFillObjects collect: [ :aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^transparentFillMorphs do: [ :aSVGMorph| self testFillIn: aSVGMorph with: Color transparent]
transparentFillMorphs := transparentFillObjects collect: [:aSVGMorph| (SVGMorph fromString: (self perform: aSVGMorph)) submorphs first].
^transparentFillMorphs do: [:aSVGMorph| self testFillIn: aSVGMorph with: Color transparent]
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ testDefaultFontInSVGText

svgTextMorph := SVGMorph fromString: self basicTextSVG.

self assert: self defaultFont equals: svgTextMorph submorphs first fontToUse ttcDescription familyName
self assert: self defaultFont equals: svgTextMorph submorphs first fontToUse ttcDescription familyName
1 change: 1 addition & 0 deletions testFile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello{ hi] {}) { test. hel { .

0 comments on commit 38f628b

Please sign in to comment.