If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Changing color in Ruby.
8 posts
• Page 1 of 1
Changing color in Ruby.
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"
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"
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
Re: Changing color in Ruby.
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
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
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
Re: Changing color in Ruby.
nice one mate,
I know that feeling.
Maybe there is alpha too-
a fourth delimit?
I know that feeling.
Maybe there is alpha too-
a fourth delimit?
-
nix - Posts: 817
- Joined: Tue Jul 13, 2010 10:51 am
Re: Changing color in Ruby.
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.
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: Changing color in Ruby.
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
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Changing color in Ruby.
Thanks , reading it.
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
Re: Changing color in Ruby.
You might find my own experience and literature collection useful:
viewtopic.php?f=2&t=12169&p=42199&hilit=spogg+is+learning#p42194
Cheers
Spogg
viewtopic.php?f=2&t=12169&p=42199&hilit=spogg+is+learning#p42194
Cheers
Spogg
-
Spogg - Posts: 3358
- Joined: Thu Nov 20, 2014 4:24 pm
- Location: Birmingham, England
Re: Changing color in Ruby.
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.
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.
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 133 guests