Nick Gammon said:
I don't really understand the question. What is option A and what is option B?
Option A: (what I thought you were suggesting) separate miniwindows for each rotated string.
Option B: using a single miniwindow to generate and copy images of each rotated string (clearing the contents after each time)
Anyways, here's what I have so far. I haven't coded in the cache mechanism yet. The only problem I'm having is with transparency.
[EDIT]Figured out the transparency. Edited the code.
--------------------------------------------------------------------------------
-- VERTICAL FONT
--------------------------------------------------------------------------------
function load_vertical_font(font, size, colour)
rotated = {}
WindowCreate(win.."upright", 0, 0, 0, 0, miniwin.pos_center_all, 0, ColourNameToRGB("black"))
WindowCreate(win.."rotated", 0, 0, 0, 0, miniwin.pos_center_all, 0, ColourNameToRGB("black"))
WindowFont(win.."upright", "vf", font, size, false, false, false, false)
local alphabet = "-!?.'abcdefghijklmnopqrstucwxyz "
alphabet:gsub(".", function(l)
local w, h = WindowTextWidth(win.."upright", "vf", l), WindowFontInfo(win.."upright", "vf", 1)
WindowResize(win.."upright", w, h, ColourNameToRGB("purple"))
WindowRectOp(win.."upright", 2, 0, 0, w, h, ColourNameToRGB("purple"))
WindowResize(win.."rotated", h, w, ColourNameToRGB("purple"))
WindowText(win.."upright", "vf", l, 0, 0, w, h, colour, false)
for x = 1, w do
for y = 1, h do
local pixel = WindowGetPixel(win.."upright", x, h - y)
WindowSetPixel(win.."rotated", y, x, pixel)
WindowImageFromWindow(win.."main", l, win.."rotated")
rotated[l] = {x = h, y = w}
end
end
end)
end
function print_vertical_text(text, x1, y1)
text = string.lower(text)
text:gsub("[-!?.'a-z ]", function(l)
WindowDrawImage(win.."main", l, x1, y1, 0, 0, miniwin.image_transparent_copy)
y1 = y1 + rotated[l].y
end)
WindowShow(win.."main", true)
end
--------------------------------------------------------------------------------
-- START EXECUTION HERE
--------------------------------------------------------------------------------
win = "win_"
WIN_X, WIN_Y = 300, 300
WindowCreate(win.."main", 0, 0, WIN_X, WIN_Y, miniwin.pos_center_all, 0, ColourNameToRGB("black"))
load_vertical_font("Dina", 14, ColourNameToRGB("white"))
print_vertical_text("Hello World!", 0, 0)
|