digitalmars.D.learn - help me learn to read documentation
- Robin (25/25) Oct 01 2015 Hi. I like to learn programming by examples but I need help
- Adam D. Ruppe (13/18) Oct 01 2015 Those describe simple class members, so you can set them through
- Robin (4/18) Oct 01 2015 Wow, thank you so much. I have never seen code like that before
Hi. I like to learn programming by examples but I need help
learning how to read documentation. I have some idea of how it
works in some aspects but in others i get completely stuck
because there are no examples or code snippets.
I am using dgame (dgame-dev.de) and im reading the documentation
for changing the background text of my font in my program.
I have the basic code for font creation but i need to make
changes to the colors.
import std.stdio;
import std.system;
import Dgame.System;
import Dgame.Window;
import Dgame.Graphic;
import Dgame.Audio;
import Dgame.Math;
void main()
{
Font dejavu = Font("resources/dejavu.ttf", 12);
Text CurrentFps = new Text(dejavu);
..window loop
}
The documentation here
(http://dgame-dev.de/index.php?controller=learn&mode=package&package=graphic&module=Text&version=0.6)...
gives me the Text() class but i dont know how to use "foreground,
background, and Font mode" or at least turn it into usable syntax.
Oct 01 2015
On Thursday, 1 October 2015 at 19:15:39 UTC, Robin wrote:The documentation here (http://dgame-dev.de/index.php?controller=learn&mode=package&package=graphic&module=Text&version=0.6)... gives me the Text() class but i dont know how to use "foreground, background, and Font mode" or at least turn it into usable syntax.Those describe simple class members, so you can set them through assignment: Text CurrentFps = new Text(dejavu); // change to white on black CurrentFps.foreground = Color4b.White; CurrentFps.background = Color4b.Black; // change mode CurrentFps.mode = Font.Mode.Shaded; I haven't actually used this library, but since the doc describes it with variable syntax (`Color4b foreground;`) that means you should be able to just assign to them like ordinary object member variables.
Oct 01 2015
On Friday, 2 October 2015 at 01:20:50 UTC, Adam D. Ruppe wrote:On Thursday, 1 October 2015 at 19:15:39 UTC, Robin wrote:Wow, thank you so much. I have never seen code like that before but the documentation there made me scratch my head. Thank you.[...]Those describe simple class members, so you can set them through assignment: Text CurrentFps = new Text(dejavu); // change to white on black CurrentFps.foreground = Color4b.White; CurrentFps.background = Color4b.Black; // change mode CurrentFps.mode = Font.Mode.Shaded; I haven't actually used this library, but since the doc describes it with variable syntax (`Color4b foreground;`) that means you should be able to just assign to them like ordinary object member variables.
Oct 01 2015








Robin <robindahoods gmail.com>