Skip to content

Commit

Permalink
Some extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
massimo-nocentini committed Nov 3, 2023
1 parent eccdb0d commit 4bb8937
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Roassal3-Shapes/RSLabel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ Class {
#tag : 'Bounding'
}

{ #category : 'public' }
RSLabel class >> defaultCodeFont [

^ StandardFonts codeFont
]

{ #category : 'public' }
RSLabel class >> defaultFont [
^ StandardFonts defaultFont
Expand Down Expand Up @@ -238,6 +244,12 @@ c @ RSCanvasController
self resetFont
]

{ #category : 'managing font' }
RSLabel >> fontSizeSilverRatio [

self fontSize: self fontSize * Float silverRatio
]

{ #category : 'testing' }
RSLabel >> hasText [
^ text notNil and: [ text isNotEmpty ]
Expand Down Expand Up @@ -447,3 +459,9 @@ c open
"
self emphasisAdd: TextEmphasis underlined
]

{ #category : 'managing font' }
RSLabel >> useDefaultCodeFont [

self font: self class defaultCodeFont
]
57 changes: 57 additions & 0 deletions src/Roassal3/Point.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Extension { #name : 'Point' }

{ #category : '*Roassal3' }
Point >> asFloatPointRound: numberOfWishedDecimal [

| aPoint |
aPoint := self asFloatPoint.

^ (aPoint x round: numberOfWishedDecimal)
@ (aPoint y round: numberOfWishedDecimal)
]

{ #category : '*Roassal3' }
Point >> distanceToOrigin [

^ self distanceTo: 0 @ 0
]

{ #category : '*Roassal3' }
Point >> unitAffine: aPoint at: aParam [

| t |
t := aParam min: 1 max: 0.

^ self * t + (1 - t * aPoint)
]

{ #category : '*Roassal3' }
Point >> unitAffine: aPoint at: aParam and: anotherPoint at: anotherParam [

| t s |
t := aParam min: 1 max: 0.
s := anotherParam min: 1 max: 0.


^ self * t + (aPoint * s) + (1 - t - s * anotherPoint)
]

{ #category : '*Roassal3' }
Point >> xMinusY [

^ self x - self y
]

{ #category : '*Roassal3' }
Point >> yMinusX [

^ self y - self x
]

{ #category : '*Roassal3' }
Point >> π [

^ (self angle / Float π) asFraction
ifNegative: [ :radians | radians + 2 ]
ifNotNegative: [ :radians | radians ]
]

0 comments on commit 4bb8937

Please sign in to comment.