Upgrate Lua sample scripts to DawnBringer's 1.3 toolbox
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@2013 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									effde4aee2
								
							
						
					
					
						commit
						5165312bff
					
				@ -11,7 +11,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
run("../libs/dawnbringer_lib.lua")
 | 
					run("../libs/dawnbringer_lib.lua")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
OK,tin,clz,fade,amt,brikeep,falloff,nobg,briweight   = inputbox("Apply PenColor 2 Brush",
 | 
					OK,tin,clz,fade,amt,brikeep,falloff,nobg,nopen,briweight   = inputbox("Apply PenColor 2 Brush",
 | 
				
			||||||
                        
 | 
					                        
 | 
				
			||||||
                           "1. Tint",               1,  0,1,-1,
 | 
					                           "1. Tint",               1,  0,1,-1,
 | 
				
			||||||
                           "2. Colorize",           0,  0,1,-1,
 | 
					                           "2. Colorize",           0,  0,1,-1,
 | 
				
			||||||
@ -20,6 +20,7 @@ OK,tin,clz,fade,amt,brikeep,falloff,nobg,briweight   = inputbox("Apply PenColor
 | 
				
			|||||||
                           "Preserve Brightness", 1,  0,1,0,
 | 
					                           "Preserve Brightness", 1,  0,1,0,
 | 
				
			||||||
                           "Bri/Dark FallOff", 1,  0,1,0,
 | 
					                           "Bri/Dark FallOff", 1,  0,1,0,
 | 
				
			||||||
                           "Exclude Background",     1,0,1,0,
 | 
					                           "Exclude Background",     1,0,1,0,
 | 
				
			||||||
 | 
					                           "Exclude PenColor",       0,0,1,0,
 | 
				
			||||||
                           "ColMatch Bri-Weight %", 25,  0,100,0                                                     
 | 
					                           "ColMatch Bri-Weight %", 25,  0,100,0                                                     
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -40,6 +41,10 @@ if OK == true then
 | 
				
			|||||||
 if nobg == 1 then
 | 
					 if nobg == 1 then
 | 
				
			||||||
  pal = db.stripIndexFromPalList(pal,bg) -- Remove background color from pallist
 | 
					  pal = db.stripIndexFromPalList(pal,bg) -- Remove background color from pallist
 | 
				
			||||||
 end
 | 
					 end
 | 
				
			||||||
 | 
					 if nopen == 1 then
 | 
				
			||||||
 | 
					  pal = db.stripIndexFromPalList(pal,fg) -- Remove  Pencolor from pallist
 | 
				
			||||||
 | 
					 end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 amtA = amt / 100
 | 
					 amtA = amt / 100
 | 
				
			||||||
 amtR = 1 - amtA
 | 
					 amtR = 1 - amtA
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
--3D-Palette viwer V0.7 (HSL-models added, 3D-World added, Pen-color only cycles thru unique colors, InputBox)
 | 
					--3D-Palette viewer V0.72 (HSL-models added, 3D-World added, Pen-color only cycles thru unique colors, InputBox)
 | 
				
			||||||
--by Richard 'Dawnbringer' Fhager
 | 
					--by Richard 'Dawnbringer' Fhager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Mouse:	Rotate Cube (Stops animation)
 | 
					-- Mouse:	Rotate Cube (Stops animation)
 | 
				
			||||||
@ -15,6 +15,8 @@
 | 
				
			|||||||
-- "-" (Num):   Zoom Out
 | 
					-- "-" (Num):   Zoom Out
 | 
				
			||||||
-- Esc:		Exit script
 | 
					-- Esc:		Exit script
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Drawing updated, rectangle missing, Sep11
 | 
				
			||||||
 | 
					
 | 
				
			||||||
run("../libs/dawnbringer_lib.lua")
 | 
					run("../libs/dawnbringer_lib.lua")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -25,7 +27,7 @@ BOX_BRI      = 112   -- Brightest color used for box (0-255)
 | 
				
			|||||||
COLSIZE_BASE = 26    -- Colors base size (value to adjusted by palette-size, with 2 cols maxsize is v / 1.23)
 | 
					COLSIZE_BASE = 26    -- Colors base size (value to adjusted by palette-size, with 2 cols maxsize is v / 1.23)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
--
 | 
					--
 | 
				
			||||||
OK,RGB,HSL,HSLC,BOX_BRI,COLSIZE_BASE,SET800x600 = inputbox("3D-Palette Viever Settings",
 | 
					OK,RGB,HSL,HSLC,BOX_BRI,COLSIZE_BASE,SET800x600 = inputbox("3D-Palette Viewer Settings",
 | 
				
			||||||
                        
 | 
					                        
 | 
				
			||||||
                           "1. RGB space [F9]",       1,  0,1,-1,
 | 
					                           "1. RGB space [F9]",       1,  0,1,-1,
 | 
				
			||||||
                           "2. HSL space [F10]",      0,  0,1,-1,
 | 
					                           "2. HSL space [F10]",      0,  0,1,-1,
 | 
				
			||||||
@ -125,7 +127,7 @@ CX,CY = w/2, h/2
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function initAndReset()
 | 
					function initAndReset()
 | 
				
			||||||
 XANG, YANG, ZANG, ZOOM, COLSIZE_ADJ, XD, YD, WORLD_X, WORLD_Y = 0,0,0,0,0,0,0,0,0
 | 
					 XANG, YANG, ZANG, ZOOM, COLSIZE_ADJ, XD, YD, WORLD_X, WORLD_Y, ZSELECT = 0,0,0,0,0,0,0,0,0,0
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
initAndReset()
 | 
					initAndReset()
 | 
				
			||||||
@ -210,6 +212,7 @@ function draw3Dline(x1,y1,z1,x2,y2,z2,div,mult,depthlist)
 | 
				
			|||||||
    yt = y1 + yd*s -- + math.random()*8
 | 
					    yt = y1 + yd*s -- + math.random()*8
 | 
				
			||||||
    c = depthlist[depth]
 | 
					    c = depthlist[depth]
 | 
				
			||||||
    if c == null then c = 1; end -- Something isn't perfect, error is super rare but this controls it
 | 
					    if c == null then c = 1; end -- Something isn't perfect, error is super rare but this controls it
 | 
				
			||||||
 | 
					    --db.line(xf,yf,xt,yt,c)
 | 
				
			||||||
    drawline(xf,yf,xt,yt,c)
 | 
					    drawline(xf,yf,xt,yt,c)
 | 
				
			||||||
    xf = xt
 | 
					    xf = xt
 | 
				
			||||||
    yf = yt
 | 
					    yf = yt
 | 
				
			||||||
@ -226,9 +229,9 @@ end
 | 
				
			|||||||
 totz = minz * 2
 | 
					 totz = minz * 2
 | 
				
			||||||
 maxrad = CMAXSIZE - CMINSIZE
 | 
					 maxrad = CMAXSIZE - CMINSIZE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
q = 0
 | 
					--q = 0
 | 
				
			||||||
delay = 4
 | 
					--delay = 4
 | 
				
			||||||
move = 0.03
 | 
					--move = 0.03
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while 1 < 2 do
 | 
					while 1 < 2 do
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -305,6 +308,16 @@ while 1 < 2 do
 | 
				
			|||||||
 -- draw3Dline(x1,y1,z1,x2,y2,z2,BOX_LINE_DIV,BOX_DIV_MULT,box_div)
 | 
					 -- draw3Dline(x1,y1,z1,x2,y2,z2,BOX_LINE_DIV,BOX_DIV_MULT,box_div)
 | 
				
			||||||
 --end
 | 
					 --end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  --c1 = math.min(FG,BG)
 | 
				
			||||||
 | 
					  --c2 = math.max(FG,BG)
 | 
				
			||||||
 | 
					  --p = colz[26]
 | 
				
			||||||
 | 
					  --XP1,YP1,zp1,c1 = p[1],p[2],p[3],p[4]
 | 
				
			||||||
 | 
					  --for n = #colz, 1, -1 do
 | 
				
			||||||
 | 
					  -- p = colz[27]
 | 
				
			||||||
 | 
					  -- XP2,YP2,zp2,c2 = p[1],p[2],p[3],p[4]
 | 
				
			||||||
 | 
					  -- drawline(XP1,YP1,XP2,YP2,c1)
 | 
				
			||||||
 | 
					  --end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 -- sort on z
 | 
					 -- sort on z
 | 
				
			||||||
 db.sorti(colz,3) 
 | 
					 db.sorti(colz,3) 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -317,6 +330,7 @@ while 1 < 2 do
 | 
				
			|||||||
  dorad = math.floor(radius - ZOOM*2 +  COLSIZE_ADJ) 
 | 
					  dorad = math.floor(radius - ZOOM*2 +  COLSIZE_ADJ) 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if dorad >= 1 then
 | 
					  if dorad >= 1 then
 | 
				
			||||||
 | 
					   --db.drawCircle(XP,YP,dorad,c) 
 | 
				
			||||||
   drawdisk(XP,YP,dorad,c) 
 | 
					   drawdisk(XP,YP,dorad,c) 
 | 
				
			||||||
   --db.drawRectangle(XP,YP,dorad,dorad,c)
 | 
					   --db.drawRectangle(XP,YP,dorad,dorad,c)
 | 
				
			||||||
   else putpicturepixel(XP,YP,c)
 | 
					   else putpicturepixel(XP,YP,c)
 | 
				
			||||||
@ -354,6 +368,7 @@ while 1 < 2 do
 | 
				
			|||||||
    old_mouse_b = mouse_b;
 | 
					    old_mouse_b = mouse_b;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    updatescreen()
 | 
					    updatescreen()
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
    moved, key, mouse_x, mouse_y, mouse_b = waitinput(0)
 | 
					    moved, key, mouse_x, mouse_y, mouse_b = waitinput(0)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if mouse_b == 1 then ANIM = 0; end
 | 
					    if mouse_b == 1 then ANIM = 0; end
 | 
				
			||||||
@ -367,6 +382,8 @@ while 1 < 2 do
 | 
				
			|||||||
    if (key==284) then  COLSIZE_ADJ = COLSIZE_ADJ + 0.5;       end -- F3
 | 
					    if (key==284) then  COLSIZE_ADJ = COLSIZE_ADJ + 0.5;       end -- F3
 | 
				
			||||||
    if (key==285) then  COLSIZE_ADJ = COLSIZE_ADJ - 0.5;       end -- F4
 | 
					    if (key==285) then  COLSIZE_ADJ = COLSIZE_ADJ - 0.5;       end -- F4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   --messagebox(key)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (key==286) then  
 | 
					    if (key==286) then  
 | 
				
			||||||
      --FG = (FG + 1) % 255; 
 | 
					      --FG = (FG + 1) % 255; 
 | 
				
			||||||
      palcol = (palcol + 1) % #pal 
 | 
					      palcol = (palcol + 1) % #pal 
 | 
				
			||||||
@ -390,6 +407,18 @@ while 1 < 2 do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (key==269) then  ZOOM = ZOOM + 0.1;  end
 | 
					    if (key==269) then  ZOOM = ZOOM + 0.1;  end
 | 
				
			||||||
    if (key==270) then  ZOOM = ZOOM - 0.1;  end
 | 
					    if (key==270) then  ZOOM = ZOOM - 0.1;  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (key==32) then  
 | 
				
			||||||
 | 
					       ZSELECT = (ZSELECT + math.pi/2) % (2*math.pi);  
 | 
				
			||||||
 | 
					       --YANG = ((YANG - math.pi/2) % (math.pi*2));
 | 
				
			||||||
 | 
					       --XANG = ((XANG + math.pi/2) % (math.pi*2));
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      YANG = ((YANG + math.pi/2) % (math.pi*2));
 | 
				
			||||||
 | 
					      XANG = ((XANG + math.pi/2) % (math.pi*2));
 | 
				
			||||||
 | 
					      YANG = ((YANG - math.pi/2) % (math.pi*2));
 | 
				
			||||||
 | 
					    end -- Rotate Z 90 Degrees
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SPEED = math.pi / 100
 | 
					    SPEED = math.pi / 100
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -411,7 +440,7 @@ while 1 < 2 do
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
  XANG = ((XANG - XD) % (math.pi*2));
 | 
					  XANG = ((XANG - XD) % (math.pi*2));
 | 
				
			||||||
  YANG = ((YANG + YD) % (math.pi*2));
 | 
					  YANG = ((YANG + YD) % (math.pi*2));
 | 
				
			||||||
  ZANG = 0
 | 
					  ZANG = ZSELECT
 | 
				
			||||||
 end 
 | 
					 end 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 if ANIM == 1 then
 | 
					 if ANIM == 1 then
 | 
				
			||||||
@ -424,8 +453,8 @@ while 1 < 2 do
 | 
				
			|||||||
  --YANG = ((mouse_x - CX) / 200  % (math.pi*2));
 | 
					  --YANG = ((mouse_x - CX) / 200  % (math.pi*2));
 | 
				
			||||||
  --ZANG = 0
 | 
					  --ZANG = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 statusmessage("x"..math.floor(XANG*57.3).."° y"..math.floor(YANG*57.3).."° z"..math.floor(ZANG*57.3).."° Zm: "..math.floor(-ZOOM*10).."   ")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  statusmessage("X: "..math.floor(XANG*57.3).."°, Y: "..math.floor(YANG*57.3).."°, Z: "..math.floor(ZANG*57.3).."°, Zoom: "..math.floor(-ZOOM*10).."   ")
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
end -- OK
 | 
					end -- OK
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
--ANIM: Sprite Animator v0.1
 | 
					--ANIM: Sprite Animator v0.15
 | 
				
			||||||
--Spare page holds data - Plays on current
 | 
					--Spare page holds data - Plays on current
 | 
				
			||||||
--by Richard Fhager
 | 
					--by Richard Fhager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -11,8 +11,8 @@ OK, XS, YS, SPACE, FRAMES, XOFF, YOFF, FPS = inputbox("Sprite-Sheet Animator",
 | 
				
			|||||||
 "Sprite Y-size",   arg.YS,    1, 256,0,
 | 
					 "Sprite Y-size",   arg.YS,    1, 256,0,
 | 
				
			||||||
 "Spacing",         arg.SPACE, 0,  32,0,
 | 
					 "Spacing",         arg.SPACE, 0,  32,0,
 | 
				
			||||||
 "# of Frames",     arg.FRAMES,2, 100,0,
 | 
					 "# of Frames",     arg.FRAMES,2, 100,0,
 | 
				
			||||||
 "X-offset",        arg.XOFF,  0, 256,0,
 | 
					  "X-offset",        arg.XOFF,  0, 800,0,
 | 
				
			||||||
 "Y-offset",        arg.YOFF,  0, 256,0,
 | 
					  "Y-offset",        arg.YOFF,  0, 800,0,
 | 
				
			||||||
 "Play Speed (FPS)",arg.FPS,   1,  60,0
 | 
					 "Play Speed (FPS)",arg.FPS,   1,  60,0
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -21,7 +21,7 @@ if OK == true then
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
memory.save({XS=XS,YS=YS,SPACE=SPACE,FRAMES=FRAMES,XOFF=XOFF,YOFF=YOFF,FPS=FPS})
 | 
					memory.save({XS=XS,YS=YS,SPACE=SPACE,FRAMES=FRAMES,XOFF=XOFF,YOFF=YOFF,FPS=FPS})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 MAXPLAYS = 25
 | 
					 MAXPLAYS = 100
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 w,h = getpicturesize()
 | 
					 w,h = getpicturesize()
 | 
				
			||||||
 OX = w / 2 - XS/2
 | 
					 OX = w / 2 - XS/2
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,47 +1,14 @@
 | 
				
			|||||||
--PICTURE: Rainbow - Dark to Bright
 | 
					--PICTURE: Rainbow - Dark to Bright v1.1
 | 
				
			||||||
--by Richard Fhager 
 | 
					--by Richard Fhager 
 | 
				
			||||||
--http://hem.fyristorg.com/dawnbringer/
 | 
					--http://hem.fyristorg.com/dawnbringer/
 | 
				
			||||||
-- Email: dawnbringer@hem.utfors.se
 | 
					-- Email: dawnbringer@hem.utfors.se
 | 
				
			||||||
-- MSN:   annassar@hotmail.com
 | 
					-- MSN:   annassar@hotmail.com
 | 
				
			||||||
--
 | 
					--
 | 
				
			||||||
-- Copyright 2010 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 <http://www.gnu.org/licenses/>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
 | 
					 | 
				
			||||||
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html 
 | 
					 | 
				
			||||||
--
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
--
 | 
					 | 
				
			||||||
function shiftHUE(r,g,b,deg) -- V1.3 R.Fhager 2007, adopted from Evalion
 | 
					 | 
				
			||||||
 local c,h,mi,mx,d,s,p,i,f,q,t
 | 
					 | 
				
			||||||
 c = {g,b,r}
 | 
					 | 
				
			||||||
 mi = math.min(r,g,b)
 | 
					 | 
				
			||||||
 mx = math.max(r,g,b); v = mx;
 | 
					 | 
				
			||||||
 d = mx - mi;
 | 
					 | 
				
			||||||
 s = 0; if mx ~= 0 then s = d/mx; end
 | 
					 | 
				
			||||||
 p = 1; if g ~= mx then p = 2; if b ~= mx then p = 0; end; end
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 if s~=0 then
 | 
					 | 
				
			||||||
  h=(deg/60+(6+p*2+(c[1+p]-c[1+(p+1)%3])/d))%6;
 | 
					 | 
				
			||||||
  i=math.floor(h);
 | 
					 | 
				
			||||||
  f=h-i;
 | 
					 | 
				
			||||||
  p=v*(1-s);
 | 
					 | 
				
			||||||
  q=v*(1-s*f);
 | 
					 | 
				
			||||||
  t=v*(1-s*(1-f));
 | 
					 | 
				
			||||||
  c={v,q,p,p,t,v}
 | 
					 | 
				
			||||||
  r = c[1+i]
 | 
					 | 
				
			||||||
  g = c[1+(i+4)%6]
 | 
					 | 
				
			||||||
  b = c[1+(i+2)%6]
 | 
					 | 
				
			||||||
 end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 return r,g,b
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
--
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--dofile("dawnbringer_lib.lua") 
 | 
				
			||||||
 | 
					run("../libs/dawnbringer_lib.lua")
 | 
				
			||||||
 | 
					--> db.shiftHUE(r,g,b, deg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
w, h = getpicturesize()
 | 
					w, h = getpicturesize()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -56,13 +23,14 @@ for y = 0, h - 1, 1 do
 | 
				
			|||||||
   g = (oy-0.5)*512 * oy
 | 
					   g = (oy-0.5)*512 * oy
 | 
				
			||||||
   b = (oy-0.5)*512 * oy
 | 
					   b = (oy-0.5)*512 * oy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   r, g, b = shiftHUE(r,g,b,ox * 360); 
 | 
					   r, g, b = db.shiftHUE(r,g,b,ox * 360); 
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
   c = matchcolor(math.max(0,math.min(255,r)),math.max(0,math.min(255,g)),math.max(0,math.min(255,b)))
 | 
					   c = matchcolor(r,g,b)
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
   putpicturepixel(x, y, c);
 | 
					   putpicturepixel(x, y, c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					  updatescreen(); if (waitbreak(0)==1) then return; end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user