From: <sm...@us...> - 2009-02-10 12:50:21
|
Revision: 9497 http://plplot.svn.sourceforge.net/plplot/?rev=9497&view=rev Author: smekal Date: 2009-02-10 12:50:17 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Added code for bitwise or operator. Example 11 produces now correct output. Modified Paths: -------------- trunk/examples/lua/x11.lua Modified: trunk/examples/lua/x11.lua =================================================================== --- trunk/examples/lua/x11.lua 2009-02-10 08:49:52 UTC (rev 9496) +++ trunk/examples/lua/x11.lua 2009-02-10 12:50:17 UTC (rev 9497) @@ -37,6 +37,24 @@ "#frPLplot Example 11 - Alt=33, Az=24, Opt=3", "#frPLplot Example 11 - Alt=17, Az=115, Opt=3" } + +-- bitwise or operator from http://lua-users.org/wiki/BaseSixtyFour +-- (c) 2006-2008 by Alex Kloss +-- licensed under the terms of the LGPL2 + +-- return single bit (for OR) +function bit(x,b) + return (math.mod(x, 2^b) - math.mod(x,2^(b-1)) > 0) +end + +-- logic OR for number values +function lor(x,y) + result = 0 + for p=1,8 do result = result + (((bit(x,p) or bit(y,p)) == true) and 2^(p-1) or 0) end + return result +end + + function cmap1_init() i = { 0, 1 } -- left boundary , right boundary h = { 240, 0 } -- blue -> green -> yellow -> red @@ -47,6 +65,7 @@ pl.scmap1l(0, i, h, l, s, {0}) end + ---------------------------------------------------------------------------- -- main -- @@ -118,17 +137,17 @@ -- magnitude colored wireframe plot if i==2 then - pl.mesh(x, y, z, opt[k] or MAG_COLOR) + pl.mesh(x, y, z, lor(opt[k], pl.MAG_COLOR)) end -- magnitude colored wireframe plot with sides if i==3 then - pl.plot3d(x, y, z, opt[k] or MAG_COLOR, 1) + pl.plot3d(x, y, z, lor(opt[k], pl.MAG_COLOR), 1) end -- magnitude colored wireframe plot with base contour if i==4 then - pl.meshc(x, y, z, opt[k] or MAG_COLOR or BASE_CONT, clevel) + pl.meshc(x, y, z, lor(lor(opt[k], pl.MAG_COLOR), pl.BASE_CONT), clevel) end pl.col0(3) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |