Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/10/2021 in all areas

  1. The standard for date format is ISO-8601, which also specifies how to espress durations. For instance, year 0000 doesn't exist which makes your output an invalid ISO-8601date string! To see what makes dates and durations differ, consider a similar question. I give you two points in 3D space by their coordinates in some base. The 2 points are then well defined and so is the length of the segment joining them. Now I ask you to compute that length expressed in the input format, that is in 3D coordinates and ... you tell Houston you have a problem. Theses formats differ by nature and properties, you can't apply the input format to the output. You have to express the fact that the output is a period, that is prepend 'P' to the output format. See https://en.wikipedia.org/wiki/ISO_8601#Durations Add to this fundamental problem the variability of a month (is that 28, 29, 30 or 31 days?) and of a year (is that 365 or 366 days?): this output date format looses its meaning and, if using the period format, it looses precision. Periods beyond days, hours and seconds are approximate at best. The ISO-8601date format is very practical, thanks to its human-readability, un-ambiguousness and self-collating property. It's not even a 6D vector (Y, M, D, h, m, s) since year, month and day are not independant coordinates. But it can't express durations or time periods in the general case unless you use the 'P' format and accept its fuzzy meaning. Things would be different if your input was in Julian date format: a Julian date is a real >= 0.0 and is in fact a Julian period from the start of the conventional Julian calendar. The difference between two Julian dates is then also a period, hence expressable in Julian date format. See AutoIt _DateToDayValue() and _DayValueToDate() functions albeit they don't handle fractional days (hms are unfortunately ignored).
    2 points
  2. I couldn't leave it alone 😀 There was a bug that caused different offsets to change the overall size of the image, this fixes that. #include <GUIConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> $main = GUICreate(" ", 300, 300, -1, -1) GUICtrlCreatePic("", 15, 15, 256, 256) CreateBG(-1, 250, 0XFFFF9000) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) ;Main Process Loop ====================================================================================== While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ;== Graphic Functions ====================================== Func CreateBG($control, $gw, $color) _GDIPlus_Startup() Local $ghandle = _GDIPlus_GraphicsCreateFromHWND($main) Local $hImage = _GDIPlus_BitmapCreateFromGraphics($gw, $gw, $ghandle) Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) Local $hBrush = _GDIPlus_BrushCreateSolid($color) Local $hBrush2 = _GDIPlus_BrushCreateSolid(0xFF000000) Local $hPath = _GDIPlus_PathCreate() Local $nBorderSize = 100 $gw -= $nBorderSize; ;Offset to allow for scaling Local $nOffset = $nBorderSize/2 _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 5) ;Path used instead of Graphic _GDIPlus_PathAddEllipse($hPath, 0+$nOffset, ($gw/8)+$nOffset, ($gw/4), ($gw*0.75)) _GDIPlus_PathAddEllipse($hPath, ($gw/8)+$nOffset, 0+$nOffset, ($gw*0.75), ($gw/4)) _GDIPlus_PathAddEllipse($hPath, ($gw-($gw/4))+$nOffset, ($gw/8)+$nOffset, ($gw/4), ($gw*0.75)) _GDIPlus_PathAddEllipse($hPath, ($gw/8)+$nOffset, ($gw-($gw/4))+$nOffset, ($gw*0.75), ($gw/4)) _GDIPlus_PathAddEllipse($hPath, ($gw/18)+$nOffset, ($gw/18)+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw-($gw*0.43))+$nOffset, ($gw/18)+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw-($gw*0.43))+$nOffset, ($gw-($gw*0.43))+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw/18)+$nOffset, ($gw-($gw*0.43))+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw/8)+$nOffset, ($gw/8)+$nOffset, ($gw*.75), ($gw*.75)) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_PathSetFillMode($hPath, 1) ;Set fill mode to union Local $hPath2 = _GDIPlus_PathClone($hPath) ;Clone the first path Local $hPen_Widen = _GDIPlus_PenCreate(0, $nBorderSize) _GDIPlus_PenSetLineJoin($hPen_Widen, $GDIP_PENSETLINEJOIN_ROUND) _GDIPlus_PathWiden($hPath2, $hPen_Widen) ;Widen second path _GDIPlus_GraphicsFillPath($hGraphic, $hPath2, $hBrush2) ; IMPORTANT Fill second path to graphic first _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ; Then first path on top $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($control, $STM_SETIMAGE, $IMAGE_BITMAP, $hbitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush2) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath2) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Endfunc
    1 point
×
×
  • Create New...