@@ -724,6 +724,13 @@ const (
724
724
PFD_STEREO_DONTCARE = 0x80000000
725
725
)
726
726
727
+ // GradientFill constants
728
+ const (
729
+ GRADIENT_FILL_RECT_H = 0x00
730
+ GRADIENT_FILL_RECT_V = 0x01
731
+ GRADIENT_FILL_TRIANGLE = 0x02
732
+ )
733
+
727
734
type (
728
735
COLORREF uint32
729
736
HBITMAP HGDIOBJ
@@ -964,9 +971,30 @@ type ENHMETAHEADER struct {
964
971
SzlMicrometers SIZE
965
972
}
966
973
974
+ type TRIVERTEX struct {
975
+ X int32
976
+ Y int32
977
+ Red uint16
978
+ Green uint16
979
+ Blue uint16
980
+ Alpha uint16
981
+ }
982
+
983
+ type GRADIENT_RECT struct {
984
+ UpperLeft uint32
985
+ LowerRight uint32
986
+ }
987
+
988
+ type GRADIENT_TRIANGLE struct {
989
+ Vertex1 uint32
990
+ Vertex2 uint32
991
+ Vertex3 uint32
992
+ }
993
+
967
994
var (
968
995
// Library
969
- libgdi32 uintptr
996
+ libgdi32 uintptr
997
+ libmsimg32 uintptr
970
998
971
999
// Functions
972
1000
abortDoc uintptr
@@ -983,6 +1011,7 @@ var (
983
1011
createFontIndirect uintptr
984
1012
createEnhMetaFile uintptr
985
1013
createIC uintptr
1014
+ createPatternBrush uintptr
986
1015
deleteDC uintptr
987
1016
deleteEnhMetaFile uintptr
988
1017
deleteObject uintptr
@@ -1001,6 +1030,7 @@ var (
1001
1030
getTextExtentPoint32 uintptr
1002
1031
getTextMetrics uintptr
1003
1032
getViewportOrgEx uintptr
1033
+ gradientFill uintptr
1004
1034
lineTo uintptr
1005
1035
moveToEx uintptr
1006
1036
playEnhMetaFile uintptr
@@ -1028,6 +1058,7 @@ var (
1028
1058
func init () {
1029
1059
// Library
1030
1060
libgdi32 = MustLoadLibrary ("gdi32.dll" )
1061
+ libmsimg32 = MustLoadLibrary ("msimg32.dll" )
1031
1062
1032
1063
// Functions
1033
1064
abortDoc = MustGetProcAddress (libgdi32 , "AbortDoc" )
@@ -1044,6 +1075,7 @@ func init() {
1044
1075
createEnhMetaFile = MustGetProcAddress (libgdi32 , "CreateEnhMetaFileW" )
1045
1076
createFontIndirect = MustGetProcAddress (libgdi32 , "CreateFontIndirectW" )
1046
1077
createIC = MustGetProcAddress (libgdi32 , "CreateICW" )
1078
+ createPatternBrush = MustGetProcAddress (libgdi32 , "CreatePatternBrush" )
1047
1079
deleteDC = MustGetProcAddress (libgdi32 , "DeleteDC" )
1048
1080
deleteEnhMetaFile = MustGetProcAddress (libgdi32 , "DeleteEnhMetaFile" )
1049
1081
deleteObject = MustGetProcAddress (libgdi32 , "DeleteObject" )
@@ -1085,6 +1117,7 @@ func init() {
1085
1117
swapBuffers = MustGetProcAddress (libgdi32 , "SwapBuffers" )
1086
1118
textOut = MustGetProcAddress (libgdi32 , "TextOutW" )
1087
1119
1120
+ gradientFill = MustGetProcAddress (libmsimg32 , "GradientFill" )
1088
1121
}
1089
1122
1090
1123
func AbortDoc (hdc HDC ) int32 {
@@ -1234,6 +1267,15 @@ func CreateIC(lpszDriver, lpszDevice, lpszOutput *uint16, lpdvmInit *DEVMODE) HD
1234
1267
return HDC (ret )
1235
1268
}
1236
1269
1270
+ func CreatePatternBrush (hbmp HBITMAP ) HBRUSH {
1271
+ ret , _ , _ := syscall .Syscall (createPatternBrush , 1 ,
1272
+ uintptr (hbmp ),
1273
+ 0 ,
1274
+ 0 )
1275
+
1276
+ return HBRUSH (ret )
1277
+ }
1278
+
1237
1279
func DeleteDC (hdc HDC ) bool {
1238
1280
ret , _ , _ := syscall .Syscall (deleteDC , 1 ,
1239
1281
uintptr (hdc ),
@@ -1416,6 +1458,18 @@ func GetViewportOrgEx(hdc HDC, lpPoint *POINT) bool {
1416
1458
return ret != 0
1417
1459
}
1418
1460
1461
+ func GradientFill (hdc HDC , pVertex * TRIVERTEX , nVertex uint32 , pMesh unsafe.Pointer , nMesh , ulMode uint32 ) bool {
1462
+ ret , _ , _ := syscall .Syscall6 (gradientFill , 6 ,
1463
+ uintptr (hdc ),
1464
+ uintptr (unsafe .Pointer (pVertex )),
1465
+ uintptr (nVertex ),
1466
+ uintptr (pMesh ),
1467
+ uintptr (nMesh ),
1468
+ uintptr (ulMode ))
1469
+
1470
+ return ret != 0
1471
+ }
1472
+
1419
1473
func LineTo (hdc HDC , nXEnd , nYEnd int32 ) bool {
1420
1474
ret , _ , _ := syscall .Syscall (lineTo , 3 ,
1421
1475
uintptr (hdc ),
0 commit comments