xelf.maple.lua for mdiapp 1.00i

作例

用法

 32bitレイヤー(空きでよい)をアクティブにして実行しましょう。

機能

 紅葉らしきもので画面をちりばめます。
 領域選択をしておけば範囲を絞り込むことができます。

コメント

 星空(xelf.startlit.lua)の派生スクリプトです。

-- 紅葉 for mdiapp 1.00i
-- xelf.maple.lua (C)2006-09-18 XELF

local w1, h1 = mdi_width(), mdi_height();
local rs,gs,bs,as = 192, 64, 16,255;
local re,ge,be,ae = 255,255, 64,255;
local ngon = 40;
local radius = math.sqrt(w1 * h1) / 32;
local pi2 = math.pi * 2;
local rot = pi2 / ngon;
local scaling = 1 / 255;
local rnd, sin, cos, mod= math.random, math.sin, math.cos, math.mod;
mdi_undo_all();
local i0 = mdi_img_layer(mdi_layer_active());
local table = { 1, 1.6, 1.7, 2, 2.5, 2, 1.8, 1.6, };
for i=0,2000 do
	mdi_vertex_clear();
	local cx,cy = rnd() * w1, rnd() * h1;
	local rot0 = rnd() * pi2;
	local rad = rnd() * radius;
	for j=0,ngon do
		local rotation = rot * j + rot0;
		local rad2 = rad * table[1 + mod(j, 8)];
		local dx = sin(rotation) * rad2;
		local dy = cos(rotation) * rad2;
		mdi_vertex_add(cx + dx, cy + dy);
	end
	local r1,g1,b1,a1 = rnd(rs, re), rnd(gs, ge), rnd(bs, be), rnd(as, ae);
	local s1 = mdi_select_pixelget(cx, cy);
	mdi_img32_polygon(i0, r1,g1,b1,a1 * s1 * scaling);
end