This was just a POC so the code isn't organized etc. Just wanted to try to make a slider that I could pull in any direction and had a tiny footprint.
Code: Select all
;***************************************************************************************************
#Include <My Altered Gdip Lib>
#Include <LayeredWindow Class>
;***************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
#NoEnv
HUD := New LayeredWindow( x := "" , y := "" , w := 500 , h := 500 , window := "2" , title := "Crazy Slider" , smoothing := 2 , options := "+AlwaysOnTop -DpiScale " , autoShow := 1 , GdipStart := 1 , WinMover := { x: 0 , y: 0 , w: w , h: 20 })
HUD.Draw( CrazySlider( ) , { X: 0 , Y: 0 , W: 500 , H: 500 } , update := 1 , disposeBitmap := 1 )
x := ( 500 / 2 ) - floor( 51 / 2 )
y := (500 / 2 ) - floor( 51 / 2 )
w := 51
h := 51
Gui, 2:Add, Text, % "x" x " y" y " w" w " h" h " hwndhwnd gTestLabel"
return
2GuiClose:
2GuiContextMenu:
*ESC::ExitApp
TestLabel:
SetTimer, WatchCursor, 60
Active := 1
return
WatchCursor:
if(!GetKeyState("LButton")){
Active := 0
SetTimer, WatchCursor, Off
Output := "New"
}else{
Output := "123"
}
CoordMode, Mouse, Client
MouseGetPos, x, y
HUD.ClearWindow()
HUD.Draw( CrazySlider( Active , x , y , Output ) , { X: 0 , Y: 0 , W: 500 , H: 500 } , update := 1 , disposeBitmap := 1 )
return
CrazySlider( Active := 0 , x2 := 0 , y2 := 0 , text := "123"){
;Bitmap Created Using: HB Bitmap Maker
local x := ( 500 / 2 ) - floor( 51 / 2 )
, y := (500 / 2 ) - floor( 51 / 2 )
, w := 51
, h := 51
pBitmap := Gdip_CreateBitmap( 500 , 500 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( "0xFF02060a" ) , Gdip_FillRectangle( G , Brush , -1 , -1 , 555 , 555 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , x , y , 51 , 51 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF33383f" ) , Gdip_FillRectangle( G , Brush , x + 2 , y + 2 , w - 4 , h - 4 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF222222" , 1 ) , Gdip_DrawRectangle( G , Pen , x + 2 , y + 2 , w - 4 , h - 4 ) , Gdip_DeletePen( Pen )
x1 := x + 26
, y1 := y + 26
SPosition := New HB_Vector(x1 , y1)
STarget := New HB_Vector( x2 , y2 )
SVel := New HB_Vector()
SVel.X := STarget.X, SVel.Y := STarget.Y
SVel.Sub(SPosition)
if( STarget.Dist(SPosition) >= 195 )
SVel.SetMag(195)
SPosition.Add(SVel)
;Border
Position := New HB_Vector(x1 , y1)
Target := New HB_Vector( x2 , y2 )
Vel := New HB_Vector()
Vel.X := Target.X , Vel.Y := Target.Y
Vel.Sub( Position )
Vel.SetMag(200)
Position.Add(Vel)
;~ Min := 1
Max := 195
Items := 15
interval := Max / Items
center := New HB_Vector(x1 , y1)
mouse := New HB_Vector( x2 , y2 )
text := ((temp := floor(center.Dist(mouse))) > 195 )?( Floor( 195 / Interval ) ):( Floor( temp / Interval ) )
count := 1
if(Text < ( count += 5 ) ){
SliderColor := "0xFF00FF00"
BGColor := "0x66006600"
Output := "Mild"
}else if(Text < ( count += 5 ) ){
SliderColor := "0xFFFFFF00"
BGColor := "0x66666600"
Output := "Mod"
}else if(Text < ( count += 5 ) ){
SliderColor := "0xFFFF0000"
BGColor := "0x66660000"
Output := "omg"
}
;~ SoundBeep, 500
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , Text , "s18 Center vCenter Bold c" Brush " x" x + 2 " y" y + 3 , "Segoe ui" , w - 4 , h - 4 ) , Gdip_DeleteBrush( Brush )
if(Active){
;~ Pen := Gdip_CreatePen( "0x66222222" , 19 ) , Gdip_DrawLine( G , Pen , x1 , y1 , Position.X , Position.Y ) , Gdip_DeletePen( Pen )
Pen := Gdip_CreatePen( BGColor , 19 ) , Gdip_DrawLine( G , Pen , x1 , y1 , Position.X , Position.Y ) , Gdip_DeletePen( Pen )
;~ Pen := Gdip_CreatePen( "0x99880000" , 5 ) , Gdip_DrawLine( G , Pen , x1 , y1 , SPosition.X , SPosition.Y ) , Gdip_DeletePen( Pen )
Pen := Gdip_CreatePen( SliderColor , 5 ) , Gdip_DrawLine( G , Pen , x1 , y1 , SPosition.X , SPosition.Y ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , SPosition.X + 20 , SPosition.Y , 50 , 20 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , SPosition.X + 20 + 1 , SPosition.Y + 1 , 50 - 2 , 20 - 2) , Gdip_DeleteBrush( Brush )
;~ Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , Text , "s18 Center vCenter Bold c" Brush " x" SPosition.X + 20 " y" SPosition.Y + 1, "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , output , "s18 Center vCenter Bold c" Brush " x" SPosition.X + 20 " y" SPosition.Y + 1, "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
}
Gdip_DeleteGraphics( G )
return pBitmap
}
Class HB_Vector {
__New(x:=0,y:=0){
This.X:=x
This.Y:=y
}
Add(Other_HB_Vector){
This.X+=Other_HB_Vector.X
This.Y+=Other_HB_Vector.Y
}
Sub(Other_HB_Vector){
This.X-=Other_HB_Vector.X
This.Y-=Other_HB_Vector.Y
}
mag(){
return Sqrt(This.X*This.X + This.Y*This.Y)
}
magsq(){
return This.Mag()**2
}
setMag(in1){
m:=This.Mag()
This.X := This.X * in1/m
This.Y := This.Y * in1/m
return This
}
mult(in1,in2:="",in3:="",in4:="",in5:=""){
if(IsObject(in1)&&in2=""){
This.X*=In1.X
This.Y*=In1.Y
}else if(!IsObject(In1)&&In2=""){
This.X*=In1
This.Y*=In1
}else if(!IsObject(In1)&&IsObject(In2)){
This.X*=In1*In2.X
This.Y*=In1*In2.Y
}else if(IsObject(In1)&&IsObject(In2)){
This.X*=In1.X*In2.X
This.Y*=In1.Y*In2.Y
}
}
div(in1,in2:="",in3:="",in4:="",in5:=""){
if(IsObject(in1)&&in2=""){
This.X/=In1.X
This.Y/=In1.Y
}else if(!IsObject(In1)&&In2=""){
This.X/=In1
This.Y/=In1
}else if(!IsObject(In1)&&IsObject(In2)){
This.X/=In1/In2.X
This.Y/=In1/In2.Y
}else if(IsObject(In1)&&IsObject(In2)){
This.X/=In1.X/In2.X
This.Y/=In1.Y/In2.Y
}
}
dist(in1){
return Sqrt(((This.X-In1.X)**2) + ((This.Y-In1.Y)**2))
}
dot(in1){
return (This.X*in1.X)+(This.Y*In1.Y)
}
cross(in1){
return This.X*In1.Y-This.Y*In1.X
}
Norm(){
m:=This.Mag()
This.X/=m
This.Y/=m
}
}
If you need any help with any of the steps, be it with the math, or with the graphics just LEMMiNO.
*EDIT* Misunderstood what you meant, give me a few mins to whip something up.