|

The Swiss Flag
Gruezi!
This LUA script is simple & generic enough
that it should work with other gluas-compatible
programs such as Artweaver, Pixarra Twistedbrush
or the GIMP.
The script first fills the whole image buffer with
red.
It then fills a white horizontal band.
It finally fills a white vertical band
Enjoy!
Download the file from here: FlagOfSwitzerland.lua
Save it in the LuaScripts subfolder of your
Dogwaffle installation so that it will become
available from the plugins panel. Or, paste it
into a new document created with the DogLuaEditor.
You
can easily create your own flag in many cases
(unless they contain
complex shapes or 'pictures' such as stars, crowns
or dragons). Here's a script for the French
flag.
|
|
-- Flag of Switzerland
-- This works best for image buffers
-- that are squares. If you use it
-- on a rectangular image, it will appear
-- stretched sideways (or compressed, if
-- it's a vertical rectangle)
--
-- If you want it to go faster, hide the
-- 'progress' lines in each loop
--
local r, g, b
local x, y
for y = 0, height - 1 do
for x = 0, width - 1 do
set_rgb(x, y, 1,0,0)
end
progress(y / height)
end
for y = 0.4*height, 0.6*height do
for x = 0.2*width, 0.8*width do
set_rgb(x, y, 1,1,1)
end
progress(y / height)
end
for y = 0.2*height, 0.8*height do
for x = 0.4*width, 0.6*width do
set_rgb(x, y, 1,1,1)
end
progress(y / height)
end
|
Another example: French Flag
-- Flag of France
local r, g, b
local x, y
-- outer loop from top to bottom,
-- and let's draw each row (scanline)
for y = 0, height - 1 do
-- optional progress bar
progress(y / height)
-- bleu: left-most third is blue
for x = 0, (width - 1) / 3 do
set_rgb(x, y,
0,0,1)
end
-- blanc: middle third is white.
-- Could also just skip this *if* we
-- trust that the background is white
for x = (width-1)/3, 2*(width-1)/3
do
set_rgb(x, y,
1,1,1)
end
-- rouge: right-side third is red
for x = 2*(width-1)/3, (width-1) do
set_rgb(x, y,
1,0,0)
end
end
|
|