Also, does anyone know how to produce glowing text with GdiDrawText?
As in this sample (but with GdiDrawText):
// ==PREPROCESSOR==
// @name "Glow Text Sample"
// @author "T.P Wang"
// ==/PREPROCESSOR==
function RGB(r, g, b) {
return (0xff000000 | (r << 16) | (g << 8) | (b));
}
function RGBA(r, g, b, a) {
return ((a << 24) | (r << 16) | (g << 8) | (b));
}
var g_font = gdi.Font("Segoe UI", 22, 1);
var g_drag = false;
var g_textrender = gdi.CreateStyleTextRender();
var g_bkclr = RGB(0, 0, 0);
function on_paint(gr) {
gr.SetTextRenderingHint(5);
gr.SetSmoothingMode(4);
gr.SetInterpolationMode(7);
var ww = window.Width;
var wh = window.Height;
// Draw background first
gr.FillSolidRect(0, 0, ww, wh, g_bkclr);
g_textrender.GlowText(RGB(0, 0, 64), RGBA(255, 255, 0, 30), 12);
// Clear previous shadow setting
g_textrender.EnableShadow(true);
g_textrender.ResetShadow();
g_textrender.RenderStringRect(gr, "Glow Text Sample", g_font, 0, 0, ww, wh, 0x11005000);
}
My current poor-man's version is to draw multiple copies of the text in the glow colour underneath the actual text:
// ==PREPROCESSOR==
// @name "Poor-man's glowing Gdi text"
// @author "rawny"
// ==/PREPROCESSOR==
function RGB(r, g, b) {
return (0xff000000 | (r << 16) | (g << 8) | (b));
}
function RGBA(r, g, b, a) {
return ((a << 24) | (r << 16) | (g << 8) | (b));
}
var text = "foobar2000";
var textFont = gdi.Font("Tahoma", 50, 1);
var textX = 100;
var textY = 100;
var glowSpacing = 4;
var rightGlowTextX = textX+glowSpacing;
var rightGlowTextY = textY+glowSpacing;
var actualTextX = textX+(glowSpacing/2);
var actualTextY = textY+(glowSpacing/2);
var bgColour = RGB(0,0,0);
var glowColour = RGBA(0, 0, 255, 222);
var textColour = RGBA(255, 255, 255, 222);
function on_size() {
ww = window.Width;
wh = window.Height;
}
function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, bgColour);
gr.GdiDrawText(text, textFont, glowColour, textX, textY, ww, wh);
gr.GdiDrawText(text, textFont, glowColour, textX, rightGlowTextY, ww, wh);
gr.GdiDrawText(text, textFont, glowColour, rightGlowTextX, textY, ww, wh);
gr.GdiDrawText(text, textFont, glowColour, rightGlowTextX, rightGlowTextY, ww, wh);
gr.GdiDrawText(text, textFont, textColour, actualTextX, actualTextY, ww, wh);
}
I'm fairly happy with this effect, but I was wondering if there was a way to do it properly?