2 * Pixel Graphics Library
3 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
4 * Understanding is not required. Only obedience.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, version 3 of the License ONLY.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 void main (string
[] args
) {
26 { import core
.runtime
: Runtime
; Runtime
.traceHandlerAllowTrace
= true; }
32 auto chr
= new BgiChr("chrfonts/v1/thin.chr");
33 writeln("baseline: ", chr
.baseline
, "; ascent: ", chr
.ascent
, "; descent: ", chr
.descent
, "; height: ", chr
.height
);
38 auto gb
= GfxBuf(92, 48);
39 gb
.clear(VColor
.green
);
40 gb
.region
.punch(0, 0);
41 gb
.region
.punch(gb
.width
-1, 0);
42 gb
.region
.punch(0, gb
.height
-1);
43 gb
.region
.punch(gb
.width
-1, gb
.height
-1);
45 sdpyCloseQueryCB
= delegate () {
46 sdpyPostQuitMessage();
49 sdpyClearVScrCB
= delegate () {
50 auto vlOvl
= GfxBuf
.vlVScrBuf
;
51 vlOvl
.clear(VColor
.black
);
54 sdpyPreDrawCB
= delegate () {
55 import std
.string
: format
;
57 auto vlOvl
= GfxBuf
.vlVScrBuf
;
59 vlOvl
.drawText(10, 10, "Text!", VColor
.rgb(255, 0, 0));
61 auto s
= "%03s,%03s".format(sdpyMouseX
, sdpyMouseY
);
62 vlOvl
.drawText(10, 20, s
, VColor
.rgb(255, 0, 0));
66 if (sdpyMouseButts
&SdpyButtonDownLeft
) buf
[0] = 'L';
67 if (sdpyMouseButts
&SdpyButtonDownMiddle
) buf
[1] = 'M';
68 if (sdpyMouseButts
&SdpyButtonDownRight
) buf
[2] = 'R';
69 vlOvl
.drawText(10, 30, buf
, VColor
.rgb(255, 0, 0));
74 if (sdpyKeyMods
&SdpyKeyCtrlDown
) buf
[0] = 'C';
75 if (sdpyKeyMods
&SdpyKeyAltDown
) buf
[1] = 'A';
76 if (sdpyKeyMods
&SdpyKeyShiftDown
) buf
[2] = 'S';
77 if (sdpyKeyMods
&SdpyKeyMetaDown
) buf
[3] = 'M';
78 vlOvl
.drawText(10, 40, buf
, VColor
.rgb(255, 0, 0));
82 chr
.drawText(vlOvl
, 10, cy
, "Hello from BGI!", VColor
.rgb(255, 255, 0));
83 vlOvl
.hline(0, cy
, 400, VColor
.rgb(255, 0, 0));
84 vlOvl
.hline(0, cy
-chr
.height
, 400, VColor
.rgb(255, 127, 0));
85 vlOvl
.hline(0, cy
-chr
.baseline
, 400, VColor
.rgb(0, 255, 0));
86 vlOvl
.hline(0, cy
-chr
.ascent
, 400, VColor
.rgb(0, 127, 0));
87 vlOvl
.hline(0, cy
-chr
.descent
, 400, VColor
.rgb(127, 127, 0));
89 foreach (int dy
; 0..16) {
90 foreach (int dx
; 0..16) {
93 chr
.drawChar(vlOvl
, x
, y
, cast(char)(dy
*16+dx
), VColor
.white
, 1);
97 //vlOvl.drawTextProp(10, 10, "Text", VColor.rgb(255, 127, 0));
100 sdpyPostDrawCB
= delegate () {
101 if (gbvis
) gb
.blitToVScr(gbx
, gby
);
104 sdpyFrameCB
= delegate () {
107 sdpyOnKeyCB
= delegate (KeyEvent evt
, bool active
) {
109 if (evt
.key
== Key
.Escape
) { sdpyPostQuitMessage(); return; }
110 if (!evt
.pressed
) return;
112 switch (evt
.key
) with (Key
) {
113 case Left
: gbx
-= 1; break;
114 case Right
: gbx
+= 1; break;
115 case Up
: gby
-= 1; break;
116 case Down
: gby
+= 1; break;
121 sdpyOnMouseCB
= delegate (MouseEvent evt
, bool active
) {
124 sdpyOnCharCB
= delegate (dchar ch
, bool active
) {
125 if (ch
== ' ') gbvis
= !gbvis
;