Skip to content

Commit

Permalink
added logarithmic visuals + logarithmic slider
Browse files Browse the repository at this point in the history
  • Loading branch information
Enzo-Demeulenaere committed Jun 26, 2024
1 parent b93375f commit 2bc149e
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 3 deletions.
22 changes: 22 additions & 0 deletions CoypuIDE/ICLogarithmicSlider.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Class {
#name : #ICLogarithmicSlider,
#superclass : #ICSlider,
#category : #'CoypuIDE-slider'
}

{ #category : #'api - transformations' }
ICLogarithmicSlider >> valueAtX: aPoint [

| value minP maxP minV maxV scale position |
minP := 0.
maxP := self barLength.
minV := self minValue ln.
maxV := self maxValue ln.

scale := maxV - minV / (maxP - minP).
position := (aPoint - bar position) x.
value := (position - minP * scale + minV) exp.
value := self nearestValue: value.

^ value asFloat rounded
]
64 changes: 61 additions & 3 deletions CoypuIDE/ICMasterCutoff.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,64 @@ Class {
#category : #'CoypuIDE-cutoff'
}

{ #category : #'as yet unclassified' }
ICMasterCutoff class >> exampleLinearSlider [

| master slider container textElt |
master := self new.

slider := ICSlider new.

container := BlElement new layout: BlLinearLayout vertical;constraintsDo: [ :c |
c horizontal fitContent.
c vertical fitContent ].

container addChild: master.
container addChild: slider.

slider minValue: master minValue.
slider maxValue: master maxValue.

textElt := BlTextElement new text: slider minValue asRopedText.
container addChild: textElt.

slider callBack: [ :value |
master setValue: value.
textElt text: value asRopedText ].

container openInSpace
]

{ #category : #'as yet unclassified' }
ICMasterCutoff class >> exampleLogarithmicSlider [

| master slider container textElt |
master := self new.

slider := ICLogarithmicSlider new.

container := BlElement new
layout: BlLinearLayout vertical;
constraintsDo: [ :c |
c horizontal fitContent.
c vertical fitContent ].

container addChild: master.
container addChild: slider.

slider minValue: master minValue.
slider maxValue: master maxValue.

textElt := BlTextElement new text: slider minValue asRopedText.
container addChild: textElt.

slider callBack: [ :value |
master setValue: value.
textElt text: value asRopedText ].

container openInSpace
]

{ #category : #'as yet unclassified' }
ICMasterCutoff >> defaultLine [

Expand Down Expand Up @@ -130,12 +188,12 @@ ICMasterCutoff >> valueToPosition: aNumber [
| minP maxP minV maxV scale result |
minP := 0.
maxP := self width - 40.
minV := self minValue log.
maxV := self maxValue log.
minV := self minValue ln.
maxV := self maxValue ln.

scale := maxV - minV / (maxP - minP).

result := aNumber log - minV / scale + minP.
result := aNumber ln - minV / scale + minP.

^ result
]

0 comments on commit 2bc149e

Please sign in to comment.