; **************************************************************************** ; * By PBFrance : http://www.pbfrance.com/?url=source&cmd=viewer&val=28 ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ ;- INITIALISATION DES DIRECTIVES COMPILEUR. DisableASM EnableExplicit ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ ;- DECLARATION DES VARIABLES (GLOBALE). ;{ - ENUMERATION Enumeration #Window_main EndEnumeration Enumeration #Canvas_0 #String_0 #Scroll_0 EndEnumeration ;} ;{ - CONSTANTE #metergadget_x = 255 #metergadget_y = 160 ;} ;{ - GLOBAL Global lPCnt.l = #metergadget_x / 2 Global lPosX.l = 0 Global lPosY.l = 0 Global lImage.l ;} ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ Global precalc.f = 2 * #PI / 360 Procedure.f GSin(angle.f) ; CALCUL DU PRECALCUL DES SINUS. ProcedureReturn Sin(angle * precalc) EndProcedure Procedure.f GCos(angle.f) ; CALCUL DU PRECALCUL DES COSINUS. ProcedureReturn Cos(angle * precalc) EndProcedure ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ Procedure DrawValue(x.l, y.l, rayonx, rayony .l, segment.l) ; ROUTINE DE TRACAGE D'UN CERCLE EN X SEGMENTS. Define i.l Define old_x.l Define old_y.l Define new_x.l Define new_y.l Define sav_x.l Define sav_y.l Define value = 0 If segment < 4 segment = 4 EndIf old_x = x - GSin(-80) * rayonx old_y = y - GCos(-80) * rayony DrawingMode(#PB_2DDrawing_Transparent) For i = -80 To 80 Step 10 new_x = x - GSin(i) * rayonx new_y = y - GCos(i) * rayony LineXY(old_x, old_y, new_x, new_y, $000000) old_x = new_x old_y = new_y Next i For i = -80 To 80 Step 5 new_x = x - GSin(i) * (rayonx + 5) new_y = y - GCos(i) * (rayony + 5) sav_x = x - GSin(i) * (rayonx - 5) sav_y = y - GCos(i) * (rayony - 5) LineXY(new_x, new_y, sav_x, sav_y, $000000) Next i EndProcedure Procedure DrawEllipse(x.l, y.l, rayonx.l, rayony.l, segment.l, value.l = 0) ; ROUTINE DE TRACAGE D'UN CERCLE EN X SEGMENTS. Define i.l Define grad.f Define old_x.l Define old_y.l Define new_x.l Define new_y.l Define sav_x.l = -1 Define sav_Y.l = -1 If segment < 4 segment = 4 EndIf grad = 80 - value new_x = x - GSin(grad) * rayonx new_y = y - GCos(grad) * rayony Circle(x, y, 20 , $eeeeee) LineXY(x - GSin(grad + 80) * 5, y - GCos(grad + 80) * 5, new_x - GSin(grad + 80) * 2, new_y - GCos(grad + 80) * 2, $000000) LineXY(x - GSin(grad - 80) * 5, y - GCos(grad - 80) * 5, new_x - GSin(grad - 80) * 2, new_y - GCos(grad - 80) * 2, $000000) Circle(new_x, new_y, 2 , $000000) For i=0 To 2 Circle(x, y, 5 + i , $000000) Next i FillArea(x - GSin(grad) * 9, y - GCos(grad) * 9, $000000, $000000) DrawingMode(#PB_2DDrawing_AlphaBlend) Box(5, 115, #metergadget_x - 10, 40, RGBA(220, 220, 220, 120)) EndProcedure ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ Procedure setGenerateStectre() ; ROUTINE DE PRECALCUL DU SPECTRE DE COULEUR. Define i.l Define lCenter.l = #metergadget_x / 2 Define lMumber.l = 16 Define lCPasXY.l = (#metergadget_x+1) / lMumber lImage = CreateImage(#PB_Any, #metergadget_x + 2, #metergadget_y + 2) If lImage <> 0 If StartDrawing(ImageOutput(lImage)) Box(0, 0, #metergadget_x + 1, #metergadget_y + 1, $000000) Box(1, 1, #metergadget_x - 1, #metergadget_y - 1, $FFFFFF) StopDrawing() EndIf EndIf EndProcedure Procedure setDrawSpectre(value.l = 0) ; ROUTINE D'AFFICHAGE DU SPECTRE ET CROIX. If StartDrawing(CanvasOutput(#Canvas_0)) If lImage <> 0 DrawAlphaImage(ImageID(lImage), 0, 0) EndIf DrawValue (127, 127, 120, 120, 20) DrawEllipse(127, 127, 110, 110, 40, value) StopDrawing() EndIf EndProcedure ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ Global pos.l Procedure ScrollCanvas() ; pos = GetGadgetState(#Scroll_0) setDrawSpectre(pos) SetGadgetText(#String_0, Str(pos)) EndProcedure ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ Define event.l Define evenp.l Define eveng.l Define hWnd.l = OpenWindow(#Window_main, 0, 0, #metergadget_x + 60, #metergadget_y + 84, #NULL$, #PB_Window_SystemMenu | #PB_Window_ScreenCentered) If hWnd <> 0 SmartWindowRefresh(#Window_main, 1) CanvasGadget(#Canvas_0, 5, 5, #metergadget_x + 1, #metergadget_y + 1) StringGadget(#String_0, #metergadget_x + 15, 5, 33, 20, "") ScrollBarGadget(#Scroll_0, 5, 170, #metergadget_x + 1, 18, 0, 160, 1) setGenerateStectre() setDrawSpectre() BindGadgetEvent(#Scroll_0, @ScrollCanvas()) Repeat event = WaitWindowEvent(20) evenp = EventType() eveng = EventGadget() Until event = #PB_Event_CloseWindow FreeImage(lImage) EndIf End