Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
massimo-nocentini committed Nov 6, 2023
1 parent 29538e2 commit 2626cd1
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 167 deletions.
4 changes: 2 additions & 2 deletions src/Roassal3-Examples/RSdeCasteljauExamples.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Class {
}

{ #category : 'lines' }
RSdeCasteljauExamples >> example01deCasteljauLine [
RSdeCasteljauExamples >> example44deCasteljauLine [

<script: 'self new example01deCasteljauLine open'>
<script: 'self new example44deCasteljauLine open'>
| points |
points := {
(1 @ 0).
Expand Down
81 changes: 81 additions & 0 deletions src/Roassal3-Layouts/RSParametricLine.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Extension { #name : 'RSParametricLine' }

{ #category : '*Roassal3-Layouts' }
RSParametricLine >> asGroupWithControlNet: aBlock [

| circles polyline labels location |
polyline := RSPolyline new
controlPoints: points;
dotted;
yourself.

circles := Array new: pointsSize.
labels := Array new: pointsSize.

location := RSLocation new
above;
yourself.

points withIndexCollect: [ :each :index |
| circle label |
circle := RSCircle new
model: each;
color: Color transparent;
radius: polyline border width * Float goldenPlatinumRatio;
draggable;
withBorder;
position: each;
yourself.

label := RSLabel new
useDefaultCodeFont;
text: (circle position asFloatPointRound: 3);
yourself.

location stick: label on: circle.

circle
when: RSPositionChangedEvent
do: [ :ev |
circle model: ev newPosition.
label text: (ev newPosition asFloatPointRound: 3).

points at: index put: ev newPosition.
polyline controlPoints: points.

self controlPoints: points ]
for: self.


circles at: index put: circle.
labels at: index put: label ].

polyline color: polyline color translucent.
self color: self color translucent.

aBlock
value: self
value: circles
value: labels
value: polyline.

^ RSGroup new
addAll: circles , labels , {
polyline.
self };
yourself
]

{ #category : '*Roassal3-Layouts' }
RSParametricLine >> asGroupWithControlNetColoured: aColor [

^ self asGroupWithControlNet: [ :bspline :circles :labels :line |
| translucentColor |
translucentColor := aColor translucent.

bspline color: aColor.
line color: translucentColor.
circles with: labels do: [ :circle :label |
circle border color: translucentColor.
label color: translucentColor ] ]
]
72 changes: 72 additions & 0 deletions src/Roassal3-Layouts/RSShape.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Extension { #name : 'RSShape' }

{ #category : '*Roassal3-Layouts' }
RSShape >> boxedWithPad: aPadding [

^ self padded: aPadding withBoxDo: [ :box |
box
color: Color white;
borderDo: [ :aBorder | aBorder color: aBorder color translucent ] ]
]

{ #category : '*Roassal3-Layouts' }
RSShape >> notedWithPad: aPadding [

^ self padded: aPadding withNoteDo: [ :box |
box
color: Color white;
borderDo: [ :aBorder | aBorder color: aBorder color translucent ] ]
]

{ #category : '*Roassal3-Layouts' }
RSShape >> padded: aPadding shape: boxShape do: aBlock [

| box |
box := boxShape
extent: self extent + (aPadding * 2);
cornerRadius: aPadding;
yourself.

aBlock cull: box cull: self.

RSLocation new
center;
stick: box on: self.

^ RSComposite new
shapes: {
box.
self };
yourself
]

{ #category : '*Roassal3-Layouts' }
RSShape >> padded: aPadding withBoxDo: aBlock [

^ self padded: aPadding shape: RSBox new do: aBlock
]

{ #category : '*Roassal3-Layouts' }
RSShape >> padded: aPadding withNoteDo: aBlock [

^ self padded: aPadding shape: RSNote new do: aBlock
]

{ #category : '*Roassal3-Layouts' }
RSShape >> padded: aPadding withSimplerNoteDo: aBlock [

^ self padded: aPadding shape: RSSimplerNote new do: aBlock
]

{ #category : '*Roassal3-Layouts' }
RSShape >> paddedWithGoldenRatio [

| pad |
pad := self extent * Float silverRatio / 2 in: [ :extent |
extent x max: extent y ].

^ RSComposite new
shapes: { self };
padding: pad;
yourself
]
9 changes: 5 additions & 4 deletions src/Roassal3-Shapes-Tests/RSPLinesTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ Class {

{ #category : 'building suites' }
RSPLinesTest class >> testParameters [

| m classesToConsider |
m := ParametrizedTestMatrix new.
classesToConsider := RSAbstractLine allSubclasses select: [ :c | c isAbstract not ].
classesToConsider do: [ :cls |
m addCase: { (#shapeClass -> cls) }
].
classesToConsider := RSAbstractLine allSubclasses select: [ :c |
(c isAbstract or: [ c = RSSegmentedPolyline ])
not ].
classesToConsider do: [ :cls | m addCase: { (#shapeClass -> cls) } ].
^ m
]

Expand Down
86 changes: 6 additions & 80 deletions src/Roassal3-Shapes/RSParametricLine.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Class {
#tag : 'Lines'
}

{ #category : 'testing' }
RSParametricLine class >> isAbstract [

^ true
]

{ #category : 'accessing' }
RSParametricLine >> arcLengthParameterization [

Expand All @@ -25,86 +31,6 @@ RSParametricLine >> asGroupWithControlNet [
^ self asGroupWithControlNetColoured: Color gray
]

{ #category : 'converting' }
RSParametricLine >> asGroupWithControlNet: aBlock [

| circles polyline labels location |
polyline := RSPolyline new
controlPoints: points;
dotted;
yourself.

circles := Array new: pointsSize.
labels := Array new: pointsSize.

location := RSLocation new
above;
yourself.

points withIndexCollect: [ :each :index |
| circle label |
circle := RSCircle new
model: each;
color: Color transparent;
radius: polyline border width * Float goldenPlatinumRatio;
draggable;
withBorder;
position: each;
yourself.

label := RSLabel new
useDefaultCodeFont;
text: (circle position asFloatPointRound: 3);
yourself.

location stick: label on: circle.

circle
when: RSPositionChangedEvent
do: [ :ev |
circle model: ev newPosition.
label text: (ev newPosition asFloatPointRound: 3).

points at: index put: ev newPosition.
polyline controlPoints: points.

self controlPoints: points ]
for: self.


circles at: index put: circle.
labels at: index put: label ].

polyline color: polyline color translucent.
self color: self color translucent.

aBlock
value: self
value: circles
value: labels
value: polyline.

^ RSGroup new
addAll: circles , labels , {
polyline.
self };
yourself
]

{ #category : 'converting' }
RSParametricLine >> asGroupWithControlNetColoured: aColor [

^ self asGroupWithControlNet: [ :bspline :circles :labels :line |
| translucentColor |
translucentColor := aColor translucent.

bspline color: aColor.
line color: translucentColor.
circles with: labels do: [ :circle :label |
circle border color: translucentColor.
label color: translucentColor ] ]
]

{ #category : 'accessing' }
RSParametricLine >> controlPoints: aSequenceableOfPoints [

Expand Down
62 changes: 0 additions & 62 deletions src/Roassal3/RSShape.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -505,68 +505,6 @@ RSShape >> noPaint [
paint := nil
]

{ #category : 'padding' }
RSShape >> notedWithPad: aPadding [

^ self padded: aPadding withNoteDo: [ :box |
box
color: Color white;
borderDo: [ :aBorder | aBorder color: aBorder color translucent ] ]
]

{ #category : 'padding' }
RSShape >> padded: aPadding shape: boxShape do: aBlock [

| box |
box := boxShape
extent: self extent + (aPadding * 2);
cornerRadius: aPadding;
yourself.

aBlock cull: box cull: self.

RSLocation new
center;
stick: box on: self.

^ RSComposite new
shapes: {
box.
self };
yourself
]

{ #category : 'padding' }
RSShape >> padded: aPadding withBoxDo: aBlock [

^ self padded: aPadding shape: RSBox new do: aBlock
]

{ #category : 'padding' }
RSShape >> padded: aPadding withNoteDo: aBlock [

^ self padded: aPadding shape: RSNote new do: aBlock
]

{ #category : 'padding' }
RSShape >> padded: aPadding withSimplerNoteDo: aBlock [

^ self padded: aPadding shape: RSSimplerNote new do: aBlock
]

{ #category : 'padding' }
RSShape >> paddedWithGoldenRatio [

| pad |
pad := self extent * Float silverRatio / 2 in: [ :extent |
extent x max: extent y ].

^ RSComposite new
shapes: { self };
padding: pad;
yourself
]

{ #category : 'accessing' }
RSShape >> paint [
^ paint
Expand Down
19 changes: 0 additions & 19 deletions src/Roassal3/RandomBoxMullerBivariateGaussian.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,6 @@ Class {
#tag : 'Random'
}

{ #category : 'converting' }
RandomBoxMullerBivariateGaussian >> asShapeScatter [

| gen points |
gen := self copy.
points := ((1 to: 500) collect: [ :each1 | gen next ]) sorted.

^ RSComposite new shapes: (RSChart new
addPlot: (RSScatterPlot new
x: (points collect: [ :each | each x ])
y: (points collect: [ :each | each y ]);
color: Color gray translucent;
yourself);
addDecoration: RSHorizontalTick new;
addDecoration: RSVerticalTick new;
build;
shapes)
]

{ #category : 'accessing' }
RandomBoxMullerBivariateGaussian >> density: x [

Expand Down

0 comments on commit 2626cd1

Please sign in to comment.