diff --git a/share/grafx2/scripts/ani_db_ellipse.lua b/share/grafx2/scripts/ani_db_ellipse.lua new file mode 100644 index 00000000..fe8da2f2 --- /dev/null +++ b/share/grafx2/scripts/ani_db_ellipse.lua @@ -0,0 +1,79 @@ +--PICTURE scene: Ellipse update-demo (anim) +--Demonstrates 'interactive' features. +--by Richard Fhager + +-- Copyright 2011 Richard Fhager +-- +-- This program is free software; you can redistribute it and/or +-- modify it under the terms of the GNU General Public License +-- as published by the Free Software Foundation; version 2 +-- of the License. See + + +-- +-- rot: Rotation in degrees +-- stp: Step is # of line segments (more is "better") +-- a & b are axis-radius +function ellipse2(x,y,a,b,stp,rot,col) + local n,m=math,rad,al,sa,ca,sb,cb,ox,oy,x1,y1,ast + m = math; rad = m.pi/180; ast = rad * 360/stp; + sb = m.sin(-rot * rad); cb = m.cos(-rot * rad) + for n = 0, stp, 1 do + ox = x1; oy = y1; + sa = m.sin(ast*n) * b; ca = m.cos(ast*n) * a + x1 = x + ca * cb - sa * sb + y1 = y + ca * sb + sa * cb + if (n > 0) then line(ox,oy,x1,y1,col); end + end +end +-- + +-- +function line(x1,y1,x2,y2,c) + local n,st,m; m = math + st = m.max(1,m.abs(x2-x1),m.abs(y2-y1)); + for n = 0, st, 1 do + putpicturepixel(m.floor(x1+n*(x2-x1)/st), m.floor(y1+n*(y2-y1)/st), +c ); + end +end +-- + +setpicturesize(300,300) +setcolor(0,96,96,96) +setcolor(1,255,255,128) + +r1 = 100 +r2 = 50 +rt = 0 + +frames = 100 + + +while (1 < 2) do + + r1t = 10 + math.random() * 140 + r2t = 10 + math.random() * 140 + rtt = math.random() * 360 + +for n = 0, frames-1, 1 do + clearpicture(0) + + f2 = n / frames + f1 = 1 - f2 + + r1a = r1*f1 + r1t*f2 + r2a = r2*f1 + r2t*f2 + rta = rt*f1 + rtt*f2 + + -- x, y, r1, r2, stp, rot, col + ellipse2(150, 150, r1a, r2a, 50, rta, 1) + + statusmessage('press ESC to stop') + updatescreen();if (waitbreak(0)==1) then return end + +end + + r1,r2,rt = r1a,r2a,rta + +end diff --git a/src/factory.c b/src/factory.c index 20dd5447..2f30e7f6 100644 --- a/src/factory.c +++ b/src/factory.c @@ -1021,6 +1021,19 @@ int L_UpdateScreen(lua_State* L) return 0; } + +int L_StatusMessage(lua_State* L) +{ + const char* msg; + int nb_args = lua_gettop(L); + LUA_ARG_LIMIT(1,"statusmessage"); + + LUA_ARG_STRING(1, "statusmessage", msg); + Print_in_menu(msg,0); + return 0; +} + + int L_FinalizePicture(lua_State* L) { int nb_args=lua_gettop(L); @@ -1246,6 +1259,7 @@ void Run_script(const char *script_subdirectory, const char *script_filename) lua_register(L,"getbrushtransparentcolor",L_GetBrushTransparentColor); lua_register(L,"inputbox",L_InputBox); lua_register(L,"messagebox",L_MessageBox); + lua_register(L,"statusmessage",L_StatusMessage); lua_register(L,"selectbox",L_SelectBox); lua_register(L,"getforecolor",L_GetForeColor); lua_register(L,"getbackcolor",L_GetBackColor);