Menu
Home
Create new Paste
Log in
Code
Theme: cobalt
Theme: eclipse
Theme: elegant
Theme: monokai
Theme: neat
Theme: night
Theme: rubyblue
import std.stdio; static if (!is(typeof(writeln))) alias writefln writeln; struct Color { public: static const Color Black; static const Color White; static const Color Red; static const Color Green; static const Color Blue; static const Color Yellow; static const Color Magenta; static const Color Gray; static this() { Black = Color(0, 0, 0); White = Color(255, 255, 255); Red = Color(255, 0, 0); Green = Color(0, 255, 0); Blue = Color(0, 0, 255); Yellow = Color(0, 255, 255); Magenta = Color(255, 0, 255); Gray = Color(0.7, 0.7, 0.7); } public: ubyte red, green, blue, alpha; this(ubyte red, ubyte green, ubyte blue, ubyte alpha = 0) { this.red = red; this.green = green; this.blue = blue; this.alpha = alpha; } this(float red, float green, float blue, float alpha = 0.0) { this.red = cast(ubyte)(ubyte.max * red); this.green = cast(ubyte)(ubyte.max * green); this.blue = cast(ubyte)(ubyte.max * blue); this.alpha = cast(ubyte)(ubyte.max * alpha); } /* ~this() { writeln("DTor"); } */ bool opEquals(ref const Color col) const pure nothrow { return this.red == col.red && this.green == col.green && this.blue == col.blue && this.alpha == col.alpha; } // TODO: opHash? float[4] convertGL() const pure nothrow { return [this.red / 255.0, this.green / 255.0, this.blue / 255.0, this.alpha / 255.0]; } } void main() { writeln("Hello world!"); }
Result:
Success
/
Return code: 0
/
Compilation time:
0.286
seconds
/
Run time:
0.001
seconds
Disassembly
Application output:
Hello world!
Username
Message
Add comment
Paste info
Author:
Namespace
Views:
112
Private:
no
Expires:
Never
Uploaded:
08.12.12 12:06
Parent:
#05c44fd5
Votes
:
0
Tweet
Compilation
Compiler:
DMD 2.x Gi
Pointer size:
m64
Actions
Download
Fork
Raw
×
Confirm
Are you sure you want to delete this paste?
There's no way back!
×
Confirm
Reason