Skip to content

Instantly share code, notes, and snippets.

View bergel's full-sized avatar
👨‍🔬

Alexandre Bergel bergel

👨‍🔬
View GitHub Profile
@bergel
bergel / gist:7b40726f0fef2bb58365c26521f85bff
Created May 6, 2021 10:19
Script of the day: Giving a color to a number
"Script of the day: Giving a color to a number
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
canvas := RSCanvas new.
scale := NSScale category20c.
r := Random seed: 42.
81 timesRepeat: [
@bergel
bergel / gist:19e338c072c1d0941512583fb36f5286
Created May 5, 2021 11:33
Script of the day: Connecting charts
"Script of the day: Connecting charts
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
g1 := RSChart new.
p1 := RSLinePlot new.
p1 y: #(5 10 3 -4 -5 15).
g1 addPlot: p1.
g1 addDecoration: (RSXLabelDecoration new title: 'Time'; offset: 0 @ 10).
@bergel
bergel / gist:1c799c2c4f3abbd7f25156eefebd7a78
Created April 28, 2021 07:53
Script of the day: Building and Visualizing graphs
"Script of the day: Building and Visualizing graphs
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
numberOfNodes := 25.
numberOfLines := 90.
r := Random seed: 42.
graph := Dictionary new.
"Script of the day: Normalizing over multiple values
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
values := 0 to: 1 count: 20.
scale := NSScale linear
range: { Color blue . Color gray . Color red };
domain: { 0 . 0.5 . 1 }.
canvas := RSCanvas new.
"Script of the day: Normalizing size and color
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
values := #(3 6 10 2).
canvas := RSCanvas new.
shapes := RSCircle models: values.
canvas addAll: shapes.
@bergel
bergel / gist:081ef405f82a79c8aeb3315c577606d4
Created April 12, 2021 10:09
Script of the day: Nesting lines
"Script of the day: Nesting lines
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
canvas := RSCanvas new.
1 to: 100 by: 10 do: [ :i |
g := RSCircle models: (1 to: i) forEach: [ :s :nb | s color: Color random translucent ].
@bergel
bergel / gist:0934254789ee0616e37acb5e44366266
Created April 9, 2021 12:57
Script of the day: dynamically computed control points of a bezier line
"Script of the day: dynamically computed control points of a bezier line
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
canvas := RSCanvas new.
box1 := RSBox new color: Color blue.
box2 := RSBox new color: Color red.
box2 translateTo: 100 @ -200.
"Script of the day: Chimistry time
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
c := RSCanvas new.
svgPaths :=
#('M17.46,22H6.54a4.55,4.55,0,0,1-3.42-7.54L9,7.75V4a1,1,0,0,1,2,0V8.12a1,1,0,0,1-.25.66l-6.12,7A2.54,2.54,0,0,0,6.54,20H17.46a2.54,2.54,0,0,0,1.91-4.22l-6.12-7A1,1,0,0,1,13,8.12V6.5a1,1,0,0,1,2,0V7.75l5.88,6.71A4.55,4.55,0,0,1,17.46,22Z'
'M15,4.12H9a1,1,0,0,1,0-2h6a1,1,0,0,1,0,2Z'
'M19,15H10a1,1,0,0,1,0-2h9a1,1,0,0,1,0,2Z'
"Script of the day: Playing with the fonts
By Milton Mamani
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
text := 'La donna è mobile
Qual piuma al vento
Muta d''accento
E di pensiero
"Script of the day: Normalizing color using a category scale
https://github.com/ObjectProfile/Roassal3
https://twitter.com/Roassal1
"
c := RSCanvas new.
shapes := (1 to: 150) collect: [ :n | RSEllipse new size: 20; model: (n % 5) ] as: RSGroup.
c addAll: shapes.
RSGridLayout on: shapes.