Notifications
Clear all

[Closed] Interactive bitmaps

seems a really nice tool man !

don´t think i´m messing around,
i just couldn´t understand it…

please,
tell me more of some situations your tool can be usefull.

These are really sweet. Thanks for sharing Matan! It’s great to see more scripters coming out of the woodwork!

 PEN

Nice work Matan, I haven’t tried it all but are they subject to the same flashing that I was getting in the demo that I set up some time ago?

 PEN

Now that is interesting, you are using bitMaps and not imgTags and it isn’t flashing. That is very cool as I’m still working for a client in Max 8 and need a UI with this sort of setup and I was going to live with the flashing of the imgtag. I would what the difference between the two is.

 PEN

Ah I see the difference, You are having to use the createDialog event handlers instead of the bitMaps which you can do with imgTag. I still wonder ahy imgTag is slower to draw?

Wow,
How meny replies!

Paul – Yes I saw your imageTag joystick, I even comment you about the last
(psychedelic) test. I think the difference here is not between the image tag and
bitmap. I think your flashing problem comes from the timer.
I use the ‘on mouse move’ event handler instead.

RNThead – I started looking into this tool to find a solution for graphic representation
of 2 dimensional controllers, and carried away a bit into searching some other cool
stuff that can be done by changing the main function in it…

Hi Matan,

These are really cool! keep up the good work!

Josh.

Test #6:


  try destroyDialog bitmapTest catch ()
  rollout bitmapTest "Bitmap test 6"
  (
  -- Local Variable Declerations
  ------------------------------------------
  
  	local width = 70
  	local height = width
  	local boarder = 20
  	
  	local bgColor = white
  	local stripedLinesColor = bgColor / 2
  	local graphColor = blue
  	local bgMap
  
  -- User Interface
  ------------------------------------------
  
  	bitmap bmGraph "" width:(width * 2) height:(height + 2 * boarder)
  	spinner spMax "Max:" range:[-10,10,1] align:#left offset:[-10,0] fieldwidth:35 scale:0.01
  	spinner spMin "Min:" range:[-10,10,0] align:#right offset:[10,-22] fieldwidth:35 scale:0.01
  	spinner spPrec "precision:" range:[0.0001,0.1,0.0004] align:#center fieldwidth:40 scale:0.0002
  	
  -- Functions
  ------------------------------------------
  	
  	fn createBGMap =
  	(
  		bgMap = bitmap bmGraph.width bmGraph.height color:bgColor
  		
  		-- Draw Horizontal striped lines:
  		local linePixels = #()
  		for x = 0 to (bmGraph.width - 1) do (
  			append linePixels (if mod x 10 > 5 then stripedLinesColor else bgColor)
  		)
  		setPixels bgMap [0,boarder] linePixels
  		setPixels bgMap [0,boarder + height] linePixels
  		
  		-- Draw Vertical striped lines:
  		for y = 0 to (bmGraph.height - 1) do (
  			if mod y 10 > 5 then (
  				setPixels bgMap [width,y] #(stripedLinesColor)
  			)
  		)
  	)
  	
  	fn updateGraph =
  	(
  		-- Draw Bezier Curve:
  		local newMap = copy bgMap
  		local P0 = [0,height + boarder]
  		local P1 = [width / 3,boarder + height * (1 - spMin.value)]
  		local P2 = [width * 2 / 3,boarder + height * (1 - spMax.value)]
  		local P3 = [width,boarder]
  		
  		local lastPt = [0,0]
  		for t = 0.0 to 1.0 by spPrec.value do (
  			local Pt = (1-t) ^ 3 * P0 + 3 * (1-t) ^ 2 * t * P1 + 3 * (1-t) * t ^ 2 * P2 + t ^ 3 * P3
  			for i = 1 to 2 do (
  				Pt[i] = if Pt[i] - (floor Pt[i]) > 0.5 then ceil Pt[i] else floor Pt[i]
  			)
  			if Pt != lastPt then (
  				lastPt = Pt
  				setPixels newMap Pt #(graphColor)
  				setPixels newMap [2 * width - Pt.x,Pt.y] #(graphColor)
  			)
  		)
  		bmGraph.bitmap = newMap
  	) -- end updateGraph fn
  	
  	fn openDialog =
  	(
  		createDialog bitmapTest width:((width + 5) * 2) style:#(#style_titlebar, #style_border, #style_sysmenu,#style_resizing)
  	)
  	
  	fn init =
  	(
  		createBGMap()
  		updateGraph()
  	)
  
  	fn done =
  	(
  		-- cleanup code
  		gc light:true
  	)
  
  -- Event Handlers
  ------------------------------------------
  
  	on spPrec changed val do updateGraph()
  	on spMax changed val do updateGraph()
  	on spMin changed val do updateGraph()
  	
  	on bitmapTest open do init()
  	on bitmapTest close do done()
  
  ) -- end of rollout
  
  bitmapTest.openDialog()
              

I’m starting to feel like casandra here but I’ll say it again:

Bitmaps don’t flash. IMGTags do. So sayeth the Lord.

http://forums.cgsociety.org/showpost.php?p=5106919&postcount=40

http://forums.cgsociety.org/showpost.php?p=5027812&postcount=22

Wow these are great! Thanks for sharing.

Page 2 / 4