Jump to content

_FillGradientTriangleRect()


monoceres
 Share

Recommended Posts

Hi!

Stumpled across a quite interesting function on msdn today and decided to make a little UDF of it muttley

It fills a gradient triangle or a rect on a device context.

Here's the msdn link: msdn

This is how it looks:

Posted Image

Pretty sweet eh?

Here's the UDF and the above example:

http://monoceres.se/Uploads/_FillGradientTriangleRect.au3

http://monoceres.se/Uploads/Example.au3

I found some parts of the function quite confusing so the function is not anywhere near perfect, but hey! It works :)

Happy Coding!

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

It's great monoceres.

It needs some way to set the number of vertices in the dll call. If you change your example to have

_FillGradientTriangleRect($dc,$array,$GRADIENT_FILL_RECT_V)

then it draws 2 rectangles.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thanks everyone for your comments, really appreciate it :)

Maybe you should rename it to something like:

_GUIPlus_FillGradTriangle()

And see if it can be added to: _GUIPlus.au3

Good job!

It's GDIPlus :dance:

And yeah, maybe if I make this more structured I try to get it included.

Nice one monoceres!

... just the gui doesn't re-paint when taken off-screen or a gui is place on top of it

8)

Of course not, I didn't handle the WM_PAINT message :cheer:

Easy enough to add:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

;....
GUIRegisterMsg($WM_PAINT,"_ReDraw")

;....
Func _ReDraw()
    _GDIPlus_GraphicsClear($graphics, 0xFF000000)
    _FillGradientTriangleRect($dc, $array, $GRADIENT_FILL_TRIANGLE)
    Return $GUI_RUNDEFMSG
EndFunc

:(

It's great monoceres.

It needs some way to set the number of vertices in the dll call. If you change your example to have

_FillGradientTriangleRect($dc,$array,$GRADIENT_FILL_RECT_V)

then it draws 2 rectangles.

I think it's because I was lazy and always passed a GRADIENT_TRIANGLE structure to the dll. muttley

Fixing it later :P

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Of course not, I didn't handle the WM_PAINT message muttley

Easy enough to add:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

;....
GUIRegisterMsg($WM_PAINT,"_ReDraw")

;....
Func _ReDraw()
    _GDIPlus_GraphicsClear($graphics, 0xFF000000)
    _FillGradientTriangleRect($dc, $array, $GRADIENT_FILL_TRIANGLE)
    Return $GUI_RUNDEFMSG
EndFunc
Well that will draw a triangle which is not so good if you want to redraw a rectangle, and if you've changed to array to get ready for a later draw then it would be even worse. Maybe there should be something in the function _FillGradientTriangleRect to set some global varaibles with the parameters, and have the redraw function use those.

Func _ReDraw()
    _GDIPlus_GraphicsClear($graphics, 0xFF000000)
    _FillGradientTriangleRect($lastdc, $lastarray, $LAST_GRADIENT_TYPE)
    Return $GUI_RUNDEFMSG
EndFunc
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Well that will draw a triangle which is not so good if you want to redraw a rectangle, and if you've changed to array to get ready for a later draw then it would be even worse. Maybe there should be something in the function _FillGradientTriangleRect to set some global varaibles with the parameters, and have the redraw function use those.

Func _ReDraw()
     _GDIPlus_GraphicsClear($graphics, 0xFF000000)
     _FillGradientTriangleRect($lastdc, $lastarray, $LAST_GRADIENT_TYPE)
     Return $GUI_RUNDEFMSG
 EndFunc
You're right, but I will not implement any redrawing into the UDF, because I think it's up to the user to redraw the contents of his device.

I for one would not want a UDF to draw anything into my device when I don't call the function directly.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

You're right, but I will not implement any redrawing into the UDF, because I think it's up to the user to redraw the contents of his device.

I for one would not want a UDF to draw anything into my device when I don't call the function directly.

Yes, I agree with you.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Updated!

The script now uses the correct struct when drawing a Rect muttley

Thanks.

There's a typo/error. GUI appears on about line 7.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 3 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...