Is it possible to develop a color parameter in the scripting celestia:print() and/or :flash() method, so it will be possible to give the printed text on the screen a specific colour?
Normally, white will be OK, when seen against the darkness of space.
There are situations however, especially when zoomed in on brigth stars or planets like Mercury, that white text cannot be read at all.
I think it will be an improvement when a script writer can give his/her text a colour at such moments.
Marco
Scripting: Print colored text
-
Topic authorMarco Klunder
- Posts: 181
- Joined: 20.02.2008
- Age: 62
- With us: 16 years 9 months
- Location: The Netherlands
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: Scripting: Print colored text
Marco,
This is not possible, yet.
A request to print scripting text in color has been already added to the Sourceforge tracker.
I'll take care of this ASAP.
This is not possible, yet.
A request to print scripting text in color has been already added to the Sourceforge tracker.
I'll take care of this ASAP.
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: Scripting: Print colored text
I've been thinking about the best way to set the text color from a script...
The first option would be to add the color as the seventh argument of the celestia:print method.
This option has a disadvantage, though: script writers would have to specify all the seven arguments,
i.e., the following code would return an error: celestia:print(text, color)
One should write, instead: celestia:print(text, duration, horig, vorig, hoffset, voffset, color),
which would be both confusing and inconvenient.
A second option would be to add a new celestia:settextcolor method,
so that one could write: settextcolor(red, green, blue)
This option is both simplier and handier: the color set during a script will remain even after the
script is terminated, which gives the possibility to customize the color of the Celestia messages.
Also, it is more relevant with the syntax of the setlinecolor and setlabelcolor methods.
I should have a patch ready quite soon which uses the latter.
The first option would be to add the color as the seventh argument of the celestia:print method.
This option has a disadvantage, though: script writers would have to specify all the seven arguments,
i.e., the following code would return an error: celestia:print(text, color)
One should write, instead: celestia:print(text, duration, horig, vorig, hoffset, voffset, color),
which would be both confusing and inconvenient.
A second option would be to add a new celestia:settextcolor method,
so that one could write: settextcolor(red, green, blue)
This option is both simplier and handier: the color set during a script will remain even after the
script is terminated, which gives the possibility to customize the color of the Celestia messages.
Also, it is more relevant with the syntax of the setlinecolor and setlabelcolor methods.
I should have a patch ready quite soon which uses the latter.
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Re: Scripting: Print colored text
Vincent,
would it be possible to use different colors in the same message ? This is important to highlight some words in the same sentence.
would it be possible to use different colors in the same message ? This is important to highlight some words in the same sentence.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: Scripting: Print colored text
Unfortunately, this won't be possible.Cham wrote:would it be possible to use different colors in the same message ? This is important to highlight some words in the same sentence.
For this, you'll need to use the Lua Tools.
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: Scripting: Print colored text
Here's a patch built against the SVN ver1_6_1 branch version:
http://vincent.giangiulio.perso.sfr.fr/ ... olor.patch
Here's a pre-compiled Windows .exe file:
http://vincent.giangiulio.perso.sfr.fr/ ... a_test.zip
And here's a little celx script for testing:
http://vincent.giangiulio.perso.sfr.fr/ ... olor.patch
Here's a pre-compiled Windows .exe file:
http://vincent.giangiulio.perso.sfr.fr/ ... a_test.zip
And here's a little celx script for testing:
Code: Select all
for n = 0, 100 do
r = math.random()
g = math.random()
b = math.random()
celestia:settextcolor(r, g, b)
celestia:print(" Welcome to Celestia!")
wait(0.05)
end
celestia:settextcolor(1.0, 1.0, 1.0)
celestia:print(" Welcome to Celestia!")
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
-
Topic authorMarco Klunder
- Posts: 181
- Joined: 20.02.2008
- Age: 62
- With us: 16 years 9 months
- Location: The Netherlands
Re: Scripting: Print colored text
He Vincent,
This was really quick and the solution works fine, as far as I look at it, GREAT work.
During testing, it became directly clear to me, that we absolutely also need a celestia:gettextcolor() method.
(probably you already programmed it ...).
During testing, I pressed the [Esc] key and after that all my text was printed in Blue...
So using the celestia:gettextcolor() and celestia:settextcolor(r,g,b) in the celestia_cleanup_callback() definitions must be possible to reset the color to white again.
Marco
This was really quick and the solution works fine, as far as I look at it, GREAT work.
During testing, it became directly clear to me, that we absolutely also need a celestia:gettextcolor() method.
(probably you already programmed it ...).
During testing, I pressed the [Esc] key and after that all my text was printed in Blue...
So using the celestia:gettextcolor() and celestia:settextcolor(r,g,b) in the celestia_cleanup_callback() definitions must be possible to reset the color to white again.
Marco
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: Scripting: Print colored text
Marco,Marco Klunder wrote:He Vincent,
This was really quick and the solution works fine, as far as I look at it, GREAT work.
During testing, it became directly clear to me, that we absolutely also need a celestia:gettextcolor() method.
(probably you already programmed it ...).
During testing, I pressed the [Esc] key and after that all my text was printed in Blue...
So using the celestia:gettextcolor() and celestia:settextcolor(r,g,b) in the celestia_cleanup_callback() definitions must be possible to reset the color to white again.
Marco
Indeed, I've added the celestia:gettextcolor() method as well, so you can already use it.
This function returns a triple which corresponds to the red, green, blue components of the text color:
Code: Select all
r, g, b = celestia:gettextcolor()
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: Scripting: Print colored text
I've committed the patch to both the trunk and 1.6.1 branch.
This change adds the celestia:settextcolor and celestia:gettextcolor commands to CELX scripting.
I've updated the Celx scripting Wiki page accordingly
The patch also adds the settextcolor command to CEL scripting.
I would be a good thing to update the CEL documentation as well with all these new commands...
Example:
Here's a Windows executable for testing:
http://vincent.giangiulio.perso.sfr.fr/ ... 61_SVN.zip
This change adds the celestia:settextcolor and celestia:gettextcolor commands to CELX scripting.
I've updated the Celx scripting Wiki page accordingly
The patch also adds the settextcolor command to CEL scripting.
I would be a good thing to update the CEL documentation as well with all these new commands...
Example:
Code: Select all
{
# Set text color to green
settextcolor { color [0.0 1.0 0.0] }
print { origin "topleft" row 27 column 1 duration 2 text "Welcome to Celestia!" }
wait { duration 2 }
# Set text color back to white
settextcolor { color [1.0 1.0 1.0] }
print { origin "topleft" row 27 column 1 duration 2 text "Welcome to Celestia!" }
wait { duration 2 }
}
Here's a Windows executable for testing:
http://vincent.giangiulio.perso.sfr.fr/ ... 61_SVN.zip
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3