Page 1 of 1
Changing color in Ruby.
Posted: Wed Oct 10, 2018 9:29 pm
by lalalandsynth
I am trying to get more into Ruby , but man, not sure where to begin.
I am trying to change the color of the text in this piece of code. I can change it to black but I need Gray.
Where can I find a reference to learn about what Brushes are and what colors are available or preferably how to change this line so it can accept color input. I got quickly overwhelmed trying to google my way forward.
# Text
text_brush = Brush.new white
@font = Font.new "Segoe UI", 1.5, "bold"
sf = StringFormat.new
sf.setAlignment "center"
sf.setLineAlignment "center"
view.setTextRenderingHint "ClearTypeGridFit"
Re: Changing color in Ruby.
Posted: Wed Oct 10, 2018 9:34 pm
by lalalandsynth
No way ! I figured it out ! woohoo

The colors were defined earlier in the code so I added gray !
dgrey = Color.new 125, 126, 126
black = Color.new 0, 11, 16
white = Color.new 240
selec_col = @col
Re: Changing color in Ruby.
Posted: Thu Oct 11, 2018 6:59 am
by nix
nice one mate,
I know that feeling.
Maybe there is alpha too-
a fourth delimit?
Re: Changing color in Ruby.
Posted: Thu Oct 11, 2018 9:00 am
by RJHollins
nix wrote:nice one mate,
I know that feeling.
Maybe there is alpha too-
a fourth delimit?
From the Manual:
Color
You can't get anywhere without a Color so let's start here. Color objects are defined by three primary
colour components (red, green and blue) plus an optional transparency which is called Alpha. Each
component is an integer value in thsete range 0-255.
To create a Color object:
myColor = Color.new a,r,g,b
Where a is the alpha, r is the red component, g is the green component and b is the blue component.
Re: Changing color in Ruby.
Posted: Fri Oct 12, 2018 5:52 am
by tulamide
lalalandsynth wrote:Where can I find a reference to learn about what Brushes are and what colors are available or preferably how to change this line so it can accept color input.
I'm not sure if I mention it once a day or twice per minute, but all about Ruby in Flowstone can be found (and
must be read) in
User Manual, Chapter 8
Re: Changing color in Ruby.
Posted: Fri Oct 12, 2018 8:02 am
by lalalandsynth
Thanks , reading it.
Re: Changing color in Ruby.
Posted: Fri Oct 12, 2018 8:15 am
by Spogg
You might find my own experience and literature collection useful:
viewtopic.php?f=2&t=12169&p=42199&hilit=spogg+is+learning#p42194Cheers
Spogg
Re: Changing color in Ruby.
Posted: Fri Oct 12, 2018 2:44 pm
by lalalandsynth
Thanks , having a look.
So I am trying to reverse an array and so far I can do this and it works.
output 0, @in.lines.reverse.join("\n")
But , now I only want to reverse every other number in the array.
So I might have an array like this.
1
34
2
35
3
36
4
47
But I want to reverse it in this manner.
1
47
2
36
3
35
4
34
Rather then.
34
4
35
3
36
2
47
1
Any tops on sorting the list and choosing what to reverse?
I might even want to randomize the value of every other number. Or reverse every third value.
I have done this before with great pains on green , but should be simple with Ruby.