News:

Function Finder  Find all the functions within source code files

Main Menu

Basic Kaleidoscope

Started by iloveTALLwoman, October 30, 2009, 07:53:27 PM

Previous topic - Next topic

iloveTALLwoman

Hi !!

I think that any .jpg image works, but in exemple I use a Tiled Image.
Just move the mouse across the image to see the effects.
:)


; PROJECT : Project1
; AUTHOR  : oi
; CREATED : 30/10/2009
; EDITED  : 30/10/2009
; ---------------------------------------------------------------------

; Include the PlayBasic Dialogs Expansion Library
      #Include "PBDialogs"
     

; =========================================================================
; calling the Load FileDialog  
; =========================================================================
Filename$=LoadDialog("Load Some JPG","Looking for file.jpg","(*.jpg)")
Show_Result(Filename$)


 
 Do
 
; create variables to hold the UV coords for out teture mapper
; U1/v1 = top left cord on texture
 u1=0
 v1=0
 
; U2/v2 = top left cord on texture
 u2=GetImageWidth(1)
 v2=0
 
 ; U3/v3 = top left cord on texture
 u3=MouseX()
 v3=MouseY()
   
   
 TextureTri 1,400,300,u1,v1,550,50,u2,v2,700,300,u3,v3,0 ;1q
 TextureTri 1,400,300,u1,v1,550,50,u2,v2,250,50,u3,v3,0 ;2q
 TextureTri 1,400,300,u1,v1,100,300,u2,v2,250,50,u3,v3,0 ;3q
 TextureTri 1,400,300,u1,v1,100,300,u2,v2,250,550,u3,v3,0 ;4q
 TextureTri 1,400,300,u1,v1,550,550,u2,v2,250,550,u3,v3,0 ;5q
 TextureTri 1,400,300,u1,v1,550,550,u2,v2,700,300,u3,v3,0 ;6q  
 
 TextureTri 1,800,50,u1,v1,550,50,u2,v2,700,300,u3,v3,0 ;1q1  
 TextureTri 1,800,550,u1,v1,550,550,u2,v2,700,300,u3,v3,0 ;6q1
 
 TextureTri 1,0,50,u1,v1,100,300,u2,v2,250,50,u3,v3,0 ;3q1
 TextureTri 1,0,550,u1,v1,100,300,u2,v2,250,550,u3,v3,0 ;4q1
 
 TextureTri 1,0,50,u1,v1,100,300,u2,v2,250,50,u3,v3,0 ;3q2
 TextureTri 1,0,550,u1,v1,100,300,u2,v2,250,550,u3,v3,0 ;4q2

 TextureTri 1,800,50,u1,v1,950,300,u2,v2,700,300,u3,v3,0 ;1q2
 TextureTri 1,800,550,u1,v1,950,300,u2,v2,700,300,u3,v3,0 ;6q2
 
 TextureTri 1,0,50,u1,v1,100,300,u2,v2,-300,300,u3,v3,0 ;3q2
 TextureTri 1,0,550,u1,v1,100,300,u2,v2,-300,300,u3,v3,0 ;4q2

 
; Display the Screen and wait for the user to press a key
 Sync
 Loop
 WaitKey


Function Show_Result(result$)
Print result$
LoadImage result$,1
Print "Press an key to see Kaleidoscope."
Print "Move the mouse to see changes."
Sync
Cls 0
EndFunction



kevin


Nice example !

Here's a slightly tweaked version, requires PB1.64j or above



; Include the PlayBasic Dialogs Expansion Library
       #Include "PBDialogs"

; =========================================================================
; calling the Load FileDialog   
; =========================================================================
Filename$=LoadDialog("Load Some JPG","Looking for file.jpg","(*.jpg)")
Show_Result(Filename$)


 
  Do
 
; create variables to hold the UV coords for out teture mapper
; U1/v1 = top left cord on texture
  u1=0
  v1=0
 
; U2/v2 = top left cord on texture
  u2=GetImageWidth(1)
  v2=0
 
  ; U3/v3 = top left cord on texture
  u3=MouseX()
  v3=MouseY()
   
lockbuffer     
  TextureTri 1,400,300,u1,v1,550,50,u2,v2,700,300,u3,v3,0 +8;1q
  TextureTri 1,400,300,u1,v1,550,50,u2,v2,250,50,u3,v3,0+8 ;2q
  TextureTri 1,400,300,u1,v1,100,300,u2,v2,250,50,u3,v3,0+8 ;3q
  TextureTri 1,400,300,u1,v1,100,300,u2,v2,250,550,u3,v3,0+8 ;4q
  TextureTri 1,400,300,u1,v1,550,550,u2,v2,250,550,u3,v3,0+8 ;5q
  TextureTri 1,400,300,u1,v1,550,550,u2,v2,700,300,u3,v3,0+8 ;6q 
 
  TextureTri 1,800,50,u1,v1,550,50,u2,v2,700,300,u3,v3,0 +8;1q1 
  TextureTri 1,800,550,u1,v1,550,550,u2,v2,700,300,u3,v3,0+8 ;6q1
 
  TextureTri 1,0,50,u1,v1,100,300,u2,v2,250,50,u3,v3,0+8 ;3q1
  TextureTri 1,0,550,u1,v1,100,300,u2,v2,250,550,u3,v3,0+8 ;4q1
 
  TextureTri 1,0,50,u1,v1,100,300,u2,v2,250,50,u3,v3,0+8 ;3q2
  TextureTri 1,0,550,u1,v1,100,300,u2,v2,250,550,u3,v3,0+8 ;4q2

  TextureTri 1,800,50,u1,v1,950,300,u2,v2,700,300,u3,v3,0+8 ;1q2
  TextureTri 1,800,550,u1,v1,950,300,u2,v2,700,300,u3,v3,0+8 ;6q2
 
  TextureTri 1,0,50,u1,v1,100,300,u2,v2,-300,300,u3,v3,0+8 ;3q2
  TextureTri 1,0,550,u1,v1,100,300,u2,v2,-300,300,u3,v3,0+8 ;4q2
unlockbuffer     

 
; Display the Screen and wait for the user to press a key
  Sync
  Loop
  WaitKey


Function Show_Result(result$)
Print result$
LoadfxImage result$,1
Print "Press an key to see Kaleidoscope."
Print "Move the mouse to see changes."
Sync
Cls 0
EndFunction


Vee

screenie looking good! Runs waay too slow on my pc for some reason...

kevin

 The code in the first post is attempting to read from to video memory surface, not a good idea! - See -> Tutorial