BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Spline Handle Look a like"
, by trashman
Rough code to create Spline Handles, works out the vector length, angle and handle dragging of the handles.
Code
Type T_ZONE Field x Field y Field w Field h Field id End Type Global mx#, my# Global cx0# = 300 Global cy0# = 200 Graphics 800,600 SetBuffer BackBuffer() createzone (1, cx0+50,cy0+50, 10,10) createzone (2, cx0-50,cy0-50, 10,10) ex# = 150 : ey# = 150 Repeat Cls mx = MouseX() my = MouseY() If MouseDown (1) Mouseie = True Else mouseie = False EndIf zone = CheckZones() If Mouseie = True And (zone > -1 And zone < 3) ex# = mx# : ey# = my# ;MoveZone (zone, mx-5, my-5) EndIf Text 10,10,CheckZones() Text 10,20, mx + " : " + my DRAWHANDLES(cx0#, cy0#, ex, ey) Flip Until KeyDown (1) Function CreateZone (id, x,y,w,h) L_ZONE.T_ZONE = New T_ZONE L_ZONE\x = x-(w/2) L_ZONE\y = y-(h/2) L_ZONE\w = w L_ZONE\h = h L_ZONE\id = id Rect x,y,w,h, False End Function Function MoveZone (id, x, y) For L_ZONE.T_ZONE = Each T_ZONE If L_ZONE\id = id L_ZONE\x = x L_ZONE\y = y Return EndIf Next End Function ; ;returns Zone or -1 if not in zone Function CheckZones () id = -1 For L_ZONE.T_ZONE = Each T_ZONE Rect L_ZONE\x, L_ZONE\y, L_ZONE\w, L_ZONE\h, False If mx > L_ZONE\x And mx < L_ZONE\x+L_ZONE\w If my > L_ZONE\y And my < L_ZONE\y+L_ZONE\h id = L_ZONE\id EndIf EndIf Next ;L_ZONE Return (id) End Function Function DRAWHANDLES (cx#, cy#, ex#, ey#) cx1# = ex# cy1# = ey# x# = (cx1#-cx#) y# = (cy1#-cy#) ; get the length? U# = Sqr (x#*x# + y#*y#) ; get the angle? A# = ATan2(x#, y#) Oval cx#-5, cy#-5, 10,10 Text 50,60 ,x Text 50,70, y Color 255,255,255 ex1 = cx-ex ey1 = cy-ey Line cx, cy, cx-x, cy-y Line cx, cy, cx+x, cy+y Color 0,128,255 movezone (1,(cx#+x)-5, (cy+y)-5) movezone (2,(cx#-x)-5, (cy-y)-5) Rect (cx#+x)-5,(cy#+y)-5, 10,10 Color 128,0,255 Rect (cx#-x)-5,(cy#-y)-5, 10,10 Color 255,255,0 End Function
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations