Sign in to follow this  
Followers 0
davidkim

how png rotation mouse drag with ...

6 posts in this topic

#1 ·  Posted (edited)

I want to create a small CD player.

Posted Image

The current implementation is a structure.

The rotation of CD

Displays the playing time

According to the duration of the increased processing progress bar

How to dial the volume by dragging with mouse

Is it possible to rotate?

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=C:AutoIt3Aut2ExeIconsSETUP09.ICO
#AutoIt3Wrapper_Outfile=AutoCool_Player.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <sound.au3>
#include <Timers.au3>
Opt("GUIOnEventMode", 1)
FileInstall('.s.dat', @ScriptDir & 'sound.mp3', 1)
FileInstall('.box.png', @ScriptDir & 'box.png', 1)
FileInstall('.cd.png', @ScriptDir & 'cd.png', 1)
FileInstall('.non_star.png', @ScriptDir & 'non_star.png', 1)
FileInstall('.star.png', @ScriptDir & 'star.png', 1)
FileInstall('.pannel.png', @ScriptDir & 'pannel.png', 1)
FileInstall('.PlayerBack.png', @ScriptDir & 'PlayerBack.png', 1)
FileInstall('.pro.png', @ScriptDir & 'pro.png', 1)
FileInstall('.Vol.png', @ScriptDir & 'non_star.png', 1)
$song = _SoundOpen(@ScriptDir & "sound.mp3");진혜림 - A lover's concerto
Global $size = _SoundLength($song, 2)
Global Const $tagBITMAP = 'long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;'
_GDIPlus_Startup()
$hBackground = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'PlayerBack.png')
$cd_body = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'pannel.png')
$cd = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'cd.png')
$Vomume = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'Volume.png')
$Box = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'box.png')
$star = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'star.png')
$nstar = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'non_star.png')
$pro = _GDIPlus_ImageLoadFromFile(@ScriptDir & 'pro.png')
$State = Default
; create form
$hForm = GUICreate('', 700, 525, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
;~ $stop = GUICtrlCreateButton("stop", 392, 275, 59, 25)
;~ GUICtrlSetOnEvent(-1, '_stop_')
$back = GUICtrlCreateButton("back", 449, 260, 27, 25)
$pause = GUICtrlCreateButton("pause", 486, 260, 27, 25)
GUICtrlSetOnEvent(-1, '_pause_')
$play = GUICtrlCreateButton("play", 522, 260, 20, 25)
GUICtrlSetOnEvent(-1, 'start_play')
$next = GUICtrlCreateButton("next", 552, 260, 27, 25)

;~ $mini = GUICtrlCreateButton("Button6", 707, 286, 25, 16)
;~ GUICtrlSetOnEvent(-1,'_mini_')
;~ $exit = GUICtrlCreateButton("Button6", 742, 286, 25, 16)
;~ GUICtrlSetOnEvent(-1, '_exit_')
GUISetState()
$Text_OUT_Form = GUICreate("", 797, 473, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hForm)
GUISetBkColor(0x003842, $Text_OUT_Form)
_WinAPI_SetLayeredWindowAttributes($Text_OUT_Form, 0x003842, 255)
$info = GUICtrlCreateLabel(" 진혜림 - A lover's concerto   ", 118, 376, 237, 17)
GUICtrlSetColor(-1, 0xccffff)
GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
$time = GUICtrlCreateLabel("", 118, 406, 236, 17)
GUICtrlSetColor(-1, 0xccffff)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

;~ $Label1 = GUICtrlCreateLabel("Label1", 118, 376, 237, 17)
;~ $Label2 = GUICtrlCreateLabel("Label1", 118, 406, 236, 17)

;~ Global $vol = GUICtrlCreateSlider(600, 250, 100, 20)
;~ GUICtrlSetBkColor(-1,0x000000)
;~ GUICtrlSetLimit(-1, 100, 0)   ; change min/max value
;~ GUICtrlSetData($vol,100)
;~ GUICtrlSetOnEvent(-1,'_vol_')
;~ Global $now_vol = GUICtrlRead($vol)
GUISetState()
; moveable
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
; exit key
HotKeySet("{ESC}", '_exit_')

$times = TimerInit()
Global $p_sw = 0
Global $stop = 0
Global $ct = 1
Global $sound_position = ''
Global $pause = 0
Global $play_timer
_Movement(1, 0) ; form view
While 1
Sleep(30)
WEnd
;~ Func _mini_()
;~  GUISetState(@SW_MINIMIZE,$hForm)
;~  GUISetState(@SW_MINIMIZE,$Text_OUT_Form)
;~ EndFunc

Func _vol_()
;~ $per = GUICtrlRead($vol)
;~ SoundSetWaveVolume ( $per)
EndFunc   ;==>_vol_

Func start_play()
If $pause = 0 Then
  _SoundPlay($song, 0)
  $stop = 0
  $play_timer = _Timer_SetTimer($hForm, 1, "_Play_") ; cd rotation
Else
  _SoundResume($song)
  $stop = 0
  $play_timer = _Timer_SetTimer($hForm, 1, "_Play_") ;
  $pause = 0
EndIf
EndFunc   ;==>start_play
Func _Play_($hWnd, $Msg, $iIDTimer, $dwTime)
If $ct > 360 Then $ct = 0
$ct += 10
If $stop = 0 Then
  $p_sw += 1
  $mod = Mod($p_sw, 2)
  _Movement($ct, $mod)
  $get = _SoundPos($song, 1)
  GUICtrlSetData($time, $get)
  ScrollText($info)
  $end = _SoundStatus($song)
  If $end = 'stopped' Then
   $stop = 1
   $pause = 0
   _Timer_KillTimer($hForm, $play_timer)
  EndIf
EndIf
EndFunc   ;==>_Play_
Func _pause_()
$pause = 1
_SoundPause($song)
_Timer_KillTimer($hForm, $play_timer)
EndFunc   ;==>_pause_
Func _stop_()
_Timer_KillTimer($hForm, $play_timer)
$stop = 1
_SoundStop($song)
EndFunc   ;==>_stop_
Func ScrollText($CtrlID, $Step = 1)
$Data = GUICtrlRead($CtrlID)
$String = StringSplit($Data, "")
$Firstchars = ""
For $i = 1 To $Step
  $Firstchars &= $String[$i]
Next
$NewString = StringTrimLeft($Data, $Step) & $Firstchars
GUICtrlSetData($CtrlID, $NewString)
Sleep(100)
EndFunc   ;==>ScrollText
Func _exit_()
_Timer_KillTimer($hForm, $play_timer)
_GDIPlus_Shutdown()
Exit
EndFunc   ;==>_exit_
; form move
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
If ($hWnd = $hForm) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST
Func _Move_($graph, $png, $PngCenterX, $PngCenterY, $rAngle, $x, $y, $sw)
If $sw = 1 Then $rAngle = 0 - $rAngle
Local $status = DllCall($ghGDIPDll, "int", "GdipRotateWorldTransform", "hwnd", $graph, "float", $rAngle, "int", 1)
$status = DllCall($ghGDIPDll, "int", "GdipTranslateWorldTransform", "hwnd", $graph, "float", $x, "float", $y, "int", 1)
_GDIPlus_GraphicsDrawImageRect($graph, $png, -$PngCenterX - ($rAngle = 180), -$PngCenterY - ($rAngle = 180), _
   _GDIPlus_ImageGetWidth($png), _GDIPlus_ImageGetHeight($png))
$status = DllCall($ghGDIPDll, "int", "GdipResetWorldTransform", "hwnd", $graph)
EndFunc   ;==>_Move_
Func star($hGraphic)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $nstar, 411, 185, 29, 29)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $nstar, 411 + 45, 185, 29, 29)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $nstar, 411 + 90, 185, 29, 29)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $nstar, 411 + 135, 185, 29, 29)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $nstar, 411 + 180, 185, 29, 29)
$get = _SoundPos($song, 1)
$get = StringSplit($get, ':', 1)
If $play_timer Then
  If $get[2] = '00' Then
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409, 185, 34, 33)
  ElseIf $get[2] = '01' Then
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 45, 185, 34, 33)
  ElseIf $get[2] = '02' Then
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 45, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 90, 185, 34, 33)
  ElseIf $get[2] = '03' Then
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 45, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 90, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 135, 185, 34, 33)
  ElseIf $get[2] = '04' Then
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 45, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 90, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 135, 185, 34, 33)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $star, 409 + 180, 185, 34, 33)
  EndIf
  ; get sound pos
  $get = _SoundPos($song, 2)
  $n = Round(($get / $size) * 100, 0)
  $np = Round(($n / 173) * 100, 0)
  ConsoleWrite($get & ' ' & $n & '-' & $np & @CRLF)
  ; play progressbar
  _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $pro, 0, 0, $np, 12, 428, 323, $np, 12)
EndIf
EndFunc   ;==>star
Func _Movement($rAngle, $mod)
Local $hGraphic, $hImage
$hImage = _GDIPlus_ImageClone($hBackground)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
_Move_($hGraphic, $cd, 228, 228, $rAngle, 228 + 7, 228 + 6, 1) ;Right
_GDIPlus_GraphicsDrawImageRect($hGraphic, $cd_body, 0, 0, 700, 525)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $Vomume, 0, 0, 700, 525)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $Box, 0, 0, 700, 525)
star($hGraphic) ; get play time(min) display star
_WinAPI_UpdateLayeredWindowEx($hForm, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage), 255, 1)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
Sleep(100)
EndFunc   ;==>_Movement
Func _GDIPlus_ImageClone($hImage)
Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipCloneImage', 'ptr', $hImage, 'ptr*', 0)
If @error Then
  Return SetError(1, 0, 0)
Else
  If $aResult[0] Then
   Return SetError($aResult[0], 0, 0)
  EndIf
EndIf
Return $aResult[2]
EndFunc   ;==>_GDIPlus_ImageClone
Func _WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, $iOpacity = 255, $fDelete = 0)
Local $Ret, $tSIZE, $tPOINT, $tBLENDFUNCTION, $hDC, $hDestDC, $hDestSv
$Ret = DllCall('user32.dll', 'hwnd', 'GetDC', 'hwnd', $hWnd)
$hDC = $Ret[0]
$Ret = DllCall('gdi32.dll', 'hwnd', 'CreateCompatibleDC', 'hwnd', $hDC)
$hDestDC = $Ret[0]
$Ret = DllCall('gdi32.dll', 'hwnd', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hBitmap)
$hDestSv = $Ret[0]
$tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
$tPOINT = DllStructCreate($tagPOINT)
$tBLENDFUNCTION = DllStructCreate($tagBLENDFUNCTION)
DllStructSetData($tBLENDFUNCTION, 'Alpha', $iOpacity)
DllStructSetData($tBLENDFUNCTION, 'Format', 1)
$Ret = DllCall('user32.dll', 'int', 'UpdateLayeredWindow', 'hwnd', $hWnd, 'hwnd', $hDC, 'ptr', 0, 'ptr', DllStructGetPtr($tSIZE), 'hwnd', $hDestDC, 'ptr', DllStructGetPtr($tPOINT), 'dword', 0, 'ptr', DllStructGetPtr($tBLENDFUNCTION), 'dword', 0x02)
DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', $hWnd, 'hwnd', $hDC)
DllCall('gdi32.dll', 'ptr', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hDestSv)
DllCall('gdi32.dll', 'int', 'DeleteDC', 'hwnd', $hDestDC)
If Not $Ret[0] Then
  Return SetError(1, 0, 0)
EndIf
If $fDelete Then
  _WinAPI_DeleteObject($hBitmap)
EndIf
Return 1
EndFunc   ;==>_WinAPI_UpdateLayeredWindowEx
Func _WinAPI_GetBitmapDimension($hBitmap)
Local $tObj = DllStructCreate($tagBITMAP)
Local $Ret = DllCall('gdi32.dll', 'int', 'GetObject', 'int', $hBitmap, 'int', DllStructGetSize($tObj), 'ptr', DllStructGetPtr($tObj))
If (@error) Or (Not $Ret[0]) Then
  Return SetError(1, 0, 0)
EndIf
Local $tSIZE = DllStructCreate($tagSIZE)
DllStructSetData($tSIZE, 1, DllStructGetData($tObj, 'bmWidth'))
DllStructSetData($tSIZE, 2, DllStructGetData($tObj, 'bmHeight'))
Return $tSIZE
EndFunc   ;==>_WinAPI_GetBitmapDimension

Posted Image

Several sheets are superimposed picture.

this volume would like to rotate the dial with mouse drag.

Depending on the angle I would like to adjust the sound volume

Posted Image

Posted Image

Way too difficult for me.

AutoCoolPlayer

Edited by davidkim

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It's an image that rotates when you move the mouse wheel, shouldn't be too much a big deal to do it in a different manner, I've used that code in two projects in my signature called and

Your project looks cool btw, I haven't seen something like this before.

Also, yashied has a udf called winapiex and with it comes an example similar to what you're trying to do, which is a rotating image within another rotating image.

Ok, so I was playing with it and I think now I understand what it is you're trying to do, you want to control the volume dial and have it light up as you rotate it right? Damn, that looks and sounds very hard, this is probably more of UEZs turf....

godspeed.

Edited by ApudAngelorum

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

It's an image that rotates when you move the mouse wheel, shouldn't be too much a big deal to do it in a different manner, I've used that code in two projects in my signature called and

Your project looks cool btw, I haven't seen something like this before.

Also, yashied has a udf called winapiex and with it comes an example similar to what you're trying to do, which is a rotating image within another rotating image.

Ok, so I was playing with it and I think now I understand what it is you're trying to do, you want to control the volume dial and have it light up as you rotate it right? Damn, that looks and sounds very hard, this is probably more of UEZs turf....

godspeed.

Angle output by the LED will come in pieces.

In the LED as a whole is

I've done is you want to make several.

Photoshop using i think.

UDF using too.


I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I would use several frames for displaying the LED when changing the volume level.

The biggest problem is that the LED are shown in a circle and rotated. If the LEDs were not rotated, eg.g in a h/v straight line, it would be easy.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

i cant download it ;)(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0