Roassal3 icon indicating copy to clipboard operation
Roassal3 copied to clipboard

RSDSM should offer a way to easily customize the color of any cell

Open NicolasAnquetil opened this issue 2 years ago • 1 comments

For example a block [:x :y | ... color of cell at X/Y ]

NicolasAnquetil avatar May 24 '22 13:05 NicolasAnquetil

Hi, please consider

| dsm v keys palette |
v := Dictionary new 
	at: #A put: #(B C);
	at: #B put: #(A C);
	at: #C put: #(A);
	yourself.
keys := #(9 A B C D).
dsm := RSDSMStronglyConnected new.
dsm objects: keys.
dsm setShouldFeedY.
dsm dependency: [ :k  | v at: k ifAbsent: #() ].
dsm build.
palette := NSScale category10.
dsm shapes 
	reject: [ :shape | shape color = dsm selectedColor ]
	thenDo: [ :shape | | association |
	association := shape model.
	shape color: (palette scale: association key) translucent. ].
dsm canvas
image

DSM currently uses 2 colors. selectedColor is used when there is a dependency between x and y objects. unSelectedColor is used when there is no dependency between them.

Users can modify the colors after the building process.

Maybe you will need a new DSM class, like

| dsm bag keys palette |
map := Dictionary new 
	at: #A put: #(B C B) asBag;
	at: #B put: #(A C) asBag;
	at: #C put: #(A) asBag;
	yourself.
keys := #(9 A B C D).
dsm := RSScoredDSM new.
dsm objects: keys.
dsm setShouldFeedY.
dsm highScoreColor: Color red.
dsm lowScoreColor: Color veryVeryLightGray.
dsm score: [ :k :v | (map at: k) occurrencesOf: v ].
dsm

The idea is that you can change the change the default colors. And with the highest score is going the be red and 0 is going to be lowest score.

akevalion avatar May 24 '22 14:05 akevalion

done

akevalion avatar Oct 14 '22 00:10 akevalion