Fandom

Scratchpad

Segments: dxEffects

216,076pages on
this wiki
Add New Page
Discuss this page0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Segments: DesktopX Effects

Introduction to Scripting DesktopX Effects

Creating effects for dx objects using dxscript.

Code: Zoom Effect

This was posted in the Wincustomize forums. Based on RomanDA's scripts. In effect what this does is moves and grows the object simultaneously giving the illusion of a zooming effect.

Dim MinW,MaxW
MinW = 48
MaxW = 256
MinH = 48
'This line is in here for future reference. Not functional in this script
MaxH = 256
Sub Object_OnScriptEnter
     object.width = MinW
     Object.Height = MinH
     Object.top = 594
     Object.left = 201
End Sub

'You can use place the script below into another object as follows
'Call DesktopX.ScriptObject("effect").Toggle
Sub Object_OnLButtonDown(x,y)
    Call Toggle
End Sub

' This Sub actually could be combined with the Grow/Shrink functions.
' It looks a little nicer this way.
Sub Toggle
    If object.width => MinW Then
         Call Shrink
  Else
     Call Grow
  End If
End Sub

Function Shrink
    object.KillTimer 200
    object.SetTimer 100,10
End Function
Function Grow
     object.KillTimer 100
     object.SetTimer 200,10
End Function

Sub object_ontimer100
     If object.width => MinW Then
          object.width = object.width - 4
          object.height = object.height - 4
          object.left = object.left - 8
          object.top = object.top + 8
     Else
          object.KillTimer 100
     End If
End Sub
Sub object_ontimer200
     If object.width <= MaxW Then
          object.width = object.width + 4
          object.height = object.height + 4
          object.left = object.left + 8
          object.top = object.top - 8
     Else
          object.KillTimer 200
     End If
End Sub

' Drop Files dynamically
Sub Object_OnDropFiles(files)
Object.picture = files
End Sub

Code: Creating a Cloned Popup

Similar to the idea behind the Zoom Effect. This object. Creates a second "popup" object at a new size. Positioned in relation to the master object. 1. Create a new object and name it thumb 2. Assign a 1px by 1px white.png to "Mouse Away" state 3. Insert the code below.

Dim obj1, objW, objH, objPW, objPH
obj1 = "PopUp"	'This is the name of the cloned object
objW = 72
objH = 72
objPW = 256
objPH = 256

Sub Object_OnScriptEnter
'Sets Objects Min
Object.Width = objW
Object.Height = objH
End Sub

Sub Object_OnLButtonDown(x,y)
	'Clones the object
	'Sets left positon of clone relative To the objects position
		'This formula centers the object in relation to width of thumb/cloned object 
	'Sets Top position of clone relative to the objects position
Object.Clone obj1, DesktopX.Object("thumb").Left - ((objPW-objW)/2),_
DesktopX.Object("thumb").Top - ((objPH-objH)*2)
	'Resizes object width & height
DesktopX.Object(obj1).Width = objPW
DesktopX.Object(obj1).Height = objPH
End Sub

Function Object_OnRButtonUp(x,y,dragged)
If Not dragged Then
'code to reduce the number
End If
Object_OnRButtonUp=True
End Function

Sub Object_OnRButtonDown(x,y)
If DesktopX.Object(obj1).Visible = True Then
			DesktopX.Object(obj1).delete
			Else
			Object_OnRButtonUp=True
	End If
End Sub

Sub Object_OnDropFiles(files)
Object.picture = files
End Sub

Code: Freaky Flashing Text

A basic flashing animation script for a text object using a timer.

Sub Object_OnStateChange(state)
	If state ="Mouse over" Then
	  Object.SetTimer 100,100
		Object.SetFont  "Arial", 200, Object.FontBold, Object.FontItalic, _
Object.FontUnderline, Object.FontStrikeout, 0	
		Else
			If state = "Mouse down" Then
			Object.KillTimer 100
			Object.SetFont  "Arial", 12, Object.FontBold, Object.FontItalic, _
Object.FontUnderline, Object.FontStrikeout, 0	
			End If
	End If
End Sub

Sub Object_OnScriptEnter
 Object.States("Mouse away").SetFont  "Arial", 12, Object.FontBold, Object.FontItalic, _
Object.FontUnderline, Object.FontStrikeout, 0	
End Sub

'Assign the colours for the animation
Sub Object_OnTimer100
Object.TextColor = RGB(0,0,0)
Object.TextColor = RGB(0,255,0)
Object.TextColor = RGB(0,255,255)
Object.TextColor = RGB(255,255,255)
Object.TextColor = RGB(0,255,255)
Object.TextColor = RGB(0,255,0)
Object.TextColor = RGB(0,0,0)
End Sub

Code: Falling Star Effect

This script drops a clone (copy) that fades out.

Dim obj1, objW, objH
obj1 = "Star"	'This is the name of the cloned object
objW = 72
objH = 72

Sub Object_OnScriptEnter
'Sets Objects Min
Object.Width = objW
Object.Height = objH
End Sub

Sub Object_OnLButtonDown(x,y)
	'Clones the object & places clone at same position of calling object
		Object.Clone obj1, DesktopX.Object("thumb").Left, DesktopX.Object("thumb").Top
	'Calls animation sequence
		Object.SetTimer 100, 60
End Sub

'This is the "Falling Star Effect"
Sub Object_OnTimer100
'Determines if cloned object is visible, if not then deletes it
If DesktopX.Object(obj1).Opacity = 0 Then
	Object.KillTimer 100
	DesktopX.Object(obj1).delete
	Else
		' The moves the cloned object down & fades in out
		DesktopX.Object(obj1).Top = DesktopX.Object(obj1).Top + 25
		DesktopX.Object(obj1).Opacity = DesktopX.Object(obj1).Opacity - 4
 End If
End Sub

'Allows for dynamic changing of picture
Sub Object_OnDropFiles(files)
Object.picture = files
End Sub

Code: Starburst Effect

Another cloning script that shoots fading clones out in all directions.

Dim obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8, objW, objH, objCw, objCh
obj1 = "Star"	'This is the name of the cloned object
obj2 = "Star2"
objW = 72
objH = 72
objCw = 32
objCh = 32
obj3 = "Star3"
obj4 = "Star4"
obj5 = "Star5"
obj6 = "Star6"
obj7 = "Star7"
obj8 = "Star8"

Sub Object_OnScriptEnter
'Sets Objects Min
Object.Width = objW
Object.Height = objH
End Sub

Sub Object_OnLButtonDown(x,y)
	'Clones the object & places clone at same position of calling object
		Object.Clone obj1, DesktopX.Object("base").Left, DesktopX.Object("base").Top
		Object.Clone obj2, DesktopX.Object("base").Left, DesktopX.Object("base").Top
		Object.Clone obj3, DesktopX.Object("base").Left, DesktopX.Object("base").Top
		Object.Clone obj4, DesktopX.Object("base").Left, DesktopX.Object("base").Top
		Object.Clone obj5, DesktopX.Object("base").Left, DesktopX.Object("base").Top
		Object.Clone obj6, DesktopX.Object("base").Left, DesktopX.Object("base").Top
		Object.Clone obj7, DesktopX.Object("base").Left, DesktopX.Object("base").Top
		Object.Clone obj8, DesktopX.Object("base").Left, DesktopX.Object("base").Top

	'Bottom animation
		Object.SetTimer 100, 20
		Object.SetTimer 200, 20
		Object.SetTimer 300, 20
	'Top Animation
		Object.SetTimer 400, 20
		Object.SetTimer 500, 20
		Object.SetTimer 600, 20
	'Sides
		Object.SetTimer 700, 20
		Object.SetTimer 800, 20			
End Sub

'This is the "Falling Star Effect"
Sub Object_OnTimer100
'Determines if cloned object is visible, if not then deletes it
If DesktopX.Object(obj1).Opacity = 0 Then
	Object.KillTimer 100
	DesktopX.Object(obj1).delete
	Else
		' The moves the cloned object down & fades in out
		DesktopX.Object(obj1).Top = DesktopX.Object(obj1).Top + 25
		DesktopX.Object(obj1).Left = DesktopX.Object(obj1).Left - 25
		DesktopX.Object(obj1).Opacity = DesktopX.Object(obj1).Opacity - 4
 End If
End Sub

Sub Object_OnTimer200
'Determines if cloned object is visible, if not then deletes it
If DesktopX.Object(obj2).Opacity = 0 Then
	Object.KillTimer 200
	DesktopX.Object(obj2).delete
	Else
		' The moves the cloned object down & fades in out
		DesktopX.Object(obj2).Top = DesktopX.Object(obj2).Top + 25
		DesktopX.Object(obj2).Left = DesktopX.Object(obj2).Left + 25
		DesktopX.Object(obj2).Opacity = DesktopX.Object(obj2).Opacity - 4
 End If
End Sub

Sub Object_OnTimer300
'Determines if cloned object is visible, if not then deletes it
If DesktopX.Object(obj3).Opacity = 0 Then
	Object.KillTimer 300
	DesktopX.Object(obj3).delete
	Else
		' The moves the cloned object down & fades in out
		DesktopX.Object(obj3).Top = DesktopX.Object(obj3).Top + 25
		DesktopX.Object(obj3).Opacity = DesktopX.Object(obj3).Opacity - 4
 End If
End Sub

Sub Object_OnTimer400
'Determines if cloned object is visible, if not then deletes it
If DesktopX.Object(obj4).Opacity = 0 Then
	Object.KillTimer 400
	DesktopX.Object(obj4).delete
	Else
		' The moves the cloned object down & fades in out
		DesktopX.Object(obj4).Top = DesktopX.Object(obj4).Top - 25
		DesktopX.Object(obj4).Left = DesktopX.Object(obj4).Left - 25
		DesktopX.Object(obj4).Opacity = DesktopX.Object(obj4).Opacity - 4
 End If
End Sub

Sub Object_OnTimer500
'Determines if cloned object is visible, if not then deletes it
If DesktopX.Object(obj5).Opacity = 0 Then
	Object.KillTimer 500
	DesktopX.Object(obj5).delete
	Else
		' The moves the cloned object down & fades in out
		DesktopX.Object(obj5).Top = DesktopX.Object(obj5).Top - 25
		DesktopX.Object(obj5).Left = DesktopX.Object(obj5).Left + 25
		DesktopX.Object(obj5).Opacity = DesktopX.Object(obj5).Opacity - 4
 End If
End Sub

Sub Object_OnTimer600
'Determines if cloned object is visible, if not then deletes it
If DesktopX.Object(obj6).Opacity = 0 Then
	Object.KillTimer 600
	DesktopX.Object(obj6).delete
	Else
		' The moves the cloned object down & fades in out
		DesktopX.Object(obj6).Top = DesktopX.Object(obj6).Top - 25
		DesktopX.Object(obj6).Opacity = DesktopX.Object(obj6).Opacity - 4
 End If
End Sub

Sub Object_OnTimer700
'Determines if cloned object is visible, if not then deletes it
If DesktopX.Object(obj7).Opacity = 0 Then
	Object.KillTimer 700
	DesktopX.Object(obj7).delete
	Else
		' The moves the cloned object down & fades in out
		DesktopX.Object(obj7).Left = DesktopX.Object(obj7).Left - 25
		DesktopX.Object(obj7).Opacity = DesktopX.Object(obj7).Opacity - 4
 End If
End Sub

Sub Object_OnTimer800
'Determines if cloned object is visible, if not then deletes it
If DesktopX.Object(obj8).Opacity = 0 Then
	Object.KillTimer 800
	DesktopX.Object(obj8).delete
	Else
		' The moves the cloned object down & fades in out
		DesktopX.Object(obj8).Left = DesktopX.Object(obj8).Left + 25
		DesktopX.Object(obj8).Opacity = DesktopX.Object(obj8).Opacity - 4
 End If
End Sub

'Allows for dynamic changing of picture
Sub Object_OnDropFiles(files)
Object.picture = files
End Sub

Code: Streamlined Zoom Effect

I've streamlined this code to achieve a smoother animation and cut down the script size.

Dim MinW,MaxW,MinH,MaxH,PosX,PosY
MinW = 26	'Changed from 16 to 26 because of timer script
MaxW = 132
MinH = 26
MaxH = 132
PosX = 500 'Position right from left edge
PosY = 200 'Position down from top edge

'Positions & sizes object on start
Sub Object_OnScriptEnter
		 Object.Left = PosX
		 Object.Top = PosY
     Object.width = MaxW
     Object.Height = MaxH
End Sub

'This controls the animation
'Streamlined the script from multiple subs/functions

Sub Object_OnLButtonUp(x,y,b)
	If Object.width => MinW Then
		 Object.KillTimer 200
     Object.SetTimer 100,25
  Else
     Object.KillTimer 100
     Object.SetTimer 200,25
  End If
End Sub

'This shrinks it
Sub Object_ontimer100
     If Object.width => MinW Then
				Object.Width = Object.Width - 10
				Object.Left = Object.Left + 5
				Object.Height = Object.Height - 10
				Object.Top = Object.Top + 5
     Else
     		Object.KillTimer 100
     End If
End Sub
'This grows it
Sub Object_ontimer200
     If Object.width <= MaxW Then
				Object.Width = Object.Width + 10
				Object.Left = Object.Left - 5
				Object.Height = Object.Height + 10
				Object.Top = Object.Top - 5
  	 Else
          Object.KillTimer 200
     End If
End Sub

Comments/Suggestions

One simple/pratical application would be be using this to create scripted "zoomer" icons that are dynamic. By leaving the drop script portion in place you are able to replace the image at will.

Also on Fandom

Random wikia