source: branch/egtra-gdiplus/Classes/System/Drawing/Drawing2D/LinearGradientBrush.ab@ 569

Last change on this file since 569 was 241, checked in by イグトランス (egtra), 18 years ago

GDI+に対して名前空間で囲ったものの、現在コンパイルできないため分岐させておく

File size: 8.7 KB
Line 
1'Classes/System/Drawing/Drawing2D/LinearGradientBrush.ab
2
3/*
4ToDo:
5Get/SetBlend及びGet/SetInterpolationColorsのプロパティ化
6それにはBlend及びColorBlendクラスの実装が必要
7*/
8
9#require <Classes/System/Drawing/Brush.ab>
10#require <Classes/System/Drawing/Color.ab>
11#require <Classes/System/Drawing/Point.ab>
12#require <Classes/System/Drawing/PointF.ab>
13#require <Classes/System/Drawing/Rectangle.ab>
14#require <Classes/System/Drawing/RectangleF.ab>
15#require <Classes/System/Drawing/Drawing2D/misc.ab>
16#require <Classes/System/Drawing/Drawing2D/Matrix.ab>
17
18Namespace System
19Namespace Drawing
20Namespace Drawing2D
21
22Enum LinearGradientMode
23 Horizontal ' 0
24 Vertical ' 1
25 ForwardDiagonal ' 2
26 BackwardDiagonal ' 3
27End Enum
28
29Class LinearGradientBrush
30 Inherits Brush
31Public
32 Sub LinearGradientBrush(point1 As /*Const*/ PointF, point2 As /*Const*/ PointF, color1 As /*Const*/ Color, color2 As /*Const*/ Color)
33 Dim brush = 0 As *GpLineGradient
34 lastResult = GdiPlus.DllExports.GdipCreateLineBrush(point1, point2, color1.Value, color2.Value, WrapModeTile, brush)
35 SetNativeBrush(brush)
36 End Sub
37
38 Sub LinearGradientBrush(point1 As /*Const*/ Point, point2 As /*Const*/ Point, color1 As /*Const*/ Color, color2 As /*Const*/ Color)
39 Dim brush = 0 As *GpLineGradient
40 lastResult = GdiPlus.DllExports.GdipCreateLineBrushI(point1, point2, color1.Value, color2.Value, WrapModeTile, brush)
41 SetNativeBrush(brush)
42 End Sub
43
44 Sub LinearGradientBrush(rect As /*Const*/ RectangleF, color1 As /*Const*/ Color, color2 As /*Const*/ Color, mode As LinearGradientMode)
45 Dim brush = 0 As *GpLineGradient
46 lastResult = GdiPlus.DllExports.GdipCreateLineBrushFromRect(rect, color1.Value, color2.Value, mode, WrapModeTile, brush)
47 SetNativeBrush(brush)
48 End Sub
49
50 Sub LinearGradientBrush(rect As /*Const*/ Rectangle, color1 As /*Const*/ Color, color2 As /*Const*/ Color, mode As LinearGradientMode)
51 Dim brush = 0 As *GpLineGradient
52 lastResult = GdiPlus.DllExports.GdipCreateLineBrushFromRectI(rect, color1.Value, color2.Value, mode, WrapModeTile, brush)
53 SetNativeBrush(brush)
54 End Sub
55
56 Sub LinearGradientBrush(rect As /*Const*/ RectangleF, color1 As /*Const*/ Color, color2 As /*Const*/ Color, angle As Single, isAngleScalable = False As Boolean)
57 Dim brush = 0 As *GpLineGradient
58 lastResult = GdiPlus.DllExports.GdipCreateLineBrushFromRectWithAngle(rect, color1.Value, color2.Value, angle, isAngleScalable As BOOL, WrapModeTile, brush)
59 SetNativeBrush(brush)
60 End Sub
61
62 Sub LinearGradientBrush(rect As /*Const*/ Rectangle, color1 As /*Const*/ Color, color2 As /*Const*/ Color, angle As Single, isAngleScalable = False As Boolean)
63 Dim brush = 0 As *GpLineGradient
64 lastResult = GdiPlus.DllExports.GdipCreateLineBrushFromRectWithAngleI(rect, color1.Value, color2.Value, angle, isAngleScalable As BOOL, WrapModeTile, brush)
65 SetNativeBrush(brush)
66 End Sub
67
68 Function SetLinearColors(color1 As /*Const*/ Color, color2 As /*Const*/ Color) As Status
69 Return SetStatus(GdiPlus.DllExports.GdipSetLineColors(nativeBrush As GpLineGradient, color1.Value, color2.Value))
70 End Function
71
72 Const Function GetLinearColors(ByRef colors As *Color) As Status
73 Dim argb[1] As ARGB
74 colors = New[1] Color
75 GetLinearColors = SetStatus(GdiPlus.DllExports.GdipGetLineColors(nativeBrush As *GpLineGradient, argb))
76 If GetLinearColors = Status.Ok Then
77 colors[0] = New Color(argb[0])
78 colors[1] = New Color(argb[1])
79 End If
80 End Function
81
82 Const Function Rectangle() As RectangleF
83 Rectangle = New RectangleF
84 Return SetStatus(GdiPlus.DllExports.GdipGetLineRect(nativeBrush As *GpLineGradient, Rectangle))
85 End Function
86
87 Const Function Rectangle() As Rectangle
88 Rectangle = New Rectangle
89 Return SetStatus(GdiPlus.DllExports.GdipGetLineRectI(nativeBrush As *GpLineGradient, Rectangle))
90 End Function
91
92 Function GammaCorrection(useGammaCorrection As Boolean) As Status
93 Return SetStatus(GdiPlus.DllExports.GdipSetLineGammaCorrection(nativeBrush As *GpLineGradient, useGammaCorrection As BOOL))
94 End Function
95
96 Const Function GammaCorrection() As Boolean
97 Dim b As BOOL
98 SetStatus(GdiPlus.DllExports.GdipGetLineGammaCorrection(nativeBrush As *GpLineGradient, b))
99 Return b <> FALSE
100 End Function
101
102 Const Function GetBlendCount() As Long
103 SetStatus(GdiPlus.DllExports.GdipGetLineBlendCount(nativeBrush As *GpLineGradient, GetBlendCount))
104 End Function
105
106 Function SetBlend(blendFactors As * /*Const*/ Single, blendPositions As * /*Const*/ Single, count As Long) As Status
107 Return SetStatus(GdiPlus.DllExports.GdipSetLineBlend(nativeBrush As *GpLineGradient, blendFactors, blendPositions, count))
108 End Function
109
110 Const Function GetBlend(blendFactors As *Single, blendPositions As *Single, count As Long) As Status
111 Return SetStatus(GdiPlus.DllExports.GdipGetLineBlend(nativeBrush As *GpLineGradient, blendFactors, blendPositions, count))
112 End Function
113
114 Const Function GetInterpolationColorCount() As Long
115 GetInterpolationColorCount = 0
116 SetStatus(GdiPlus.DllExports.GdipGetLinePresetBlendCount(nativeBrush As *GpLineGradient, GetInterpolationColorCount))
117 End Function
118
119 Function SetInterpolationColors(presetColors As * /*Const*/ Color, blendPositions As * /*Const*/ Single, count As Long) As Status
120 If count <= 0 Or presetColors = 0 Then
121 Return SetStatus(Status.InvalidParameter)
122 End If
123
124 Dim argbs = malloc(SizeOf (ARGB) * count) As *ARGB
125 If argbs = 0 Then
126 Return SetStatus(Status.OutOfMemory)
127 End If
128
129 Dim i As Long
130 For i = 0 To ELM(count)
131 argbs[i] = presetColors[i].Value
132 Next
133
134 SetInterpolationColors = SetStatus(GdiPlus.DllExports.GdipSetLinePresetBlend( nativeBrush As *GpLineGradient, argbs, blendPositions, count))
135 free(argbs)
136 End Function
137
138 Const Function GetInterpolationColors(ByRef presetColors As *Color, blendPositions As *Single, count As Long) As Status
139 If count <= 0 Or presetColors = 0 Then
140 Return SetStatus(Status.InvalidParameter)
141 End If
142
143 Dim argbs = malloc(SizeOf (ARGB) * count) As *ARGB
144 If argbs = 0 Then
145 Return SetStatus(Status.OutOfMemory)
146 End If
147
148 GetInterpolationColors = SetStatus(GdiPlus.DllExports.GdipGetLinePresetBlend(nativeBrush As *GpLineGradient, argbs, blendPositions, count))
149 If GetInterpolationColors = Status.Ok Then
150 Dim i As Long
151 For i = 0 To ELM(count)
152 presetColors[i] = New Color(argbs[i])
153 Next
154 End If
155
156 free(argbs)
157 End Function
158
159 Function SetSigmaBellShape(focus As Single, scale = 1.0 As Single) As Status
160 Return SetStatus(GdiPlus.DllExports.GdipSetLineSigmaBlend(nativeBrush As *GpLineGradient, focus, scale))
161 End Function
162
163 Function SetBlendTriangularShape(focus As Single, scale = 1.0 As Single) As Status
164 Return SetStatus(GdiPlus.DllExports.GdipSetLineLinearBlend(nativeBrush As *GpLineGradient, focus, scale))
165 End Function
166
167 Function Transform(matrix As /*Const*/ Matrix) As Status
168 Return SetStatus(GdiPlus.DllExports.GdipSetLineTransform(nativeBrush As *GpLineGradient, matrix.NativeMatrix))
169 End Function
170
171 Const Function Transform() As Matrix
172 Transform = New Matrix
173 SetStatus(GdiPlus.DllExports.GdipGetLineTransform(nativeBrush As *GpLineGradient, Transform.NativeMatrix))
174 End Function
175
176 Function ResetTransform() As Status
177 Return SetStatus(GdiPlus.DllExports.GdipResetLineTransform(nativeBrush As *GpLineGradient))
178 End Function
179
180 Function MultiplyTransform(matrix As /*Const*/ Matrix, order = MatrixOrder.Prepend As MatrixOrder) As Status
181 Return SetStatus(GdiPlus.DllExports.GdipMultiplyLineTransform(nativeBrush As *GpLineGradient, matrix.NativeMatrix, order))
182 End Function
183
184 Function TranslateTransform(dx As Single, dy As Single, order = MatrixOrder.Prepend As MatrixOrder) As Status
185 Return SetStatus(GdiPlus.DllExports.GdipTranslateLineTransform(nativeBrush As *GpLineGradient, dx, dy, order))
186 End Function
187
188 Function ScaleTransform(sx As Single, sy As Single, order = MatrixOrder.Prepend As MatrixOrder) As Status
189 Return SetStatus(GdiPlus.DllExports.GdipScaleLineTransform(nativeBrush As *GpLineGradient, sx, sy, order))
190 End Function
191
192 Function RotateTransform(angl As Single, order = MatrixOrder.Prepend As MatrixOrder) As Status
193 Return SetStatus(GdiPlus.DllExports.GdipRotateLineTransform(nativeBrush As *GpLineGradient, angle, order))
194 End Function
195
196 Function WrapMode(wrapMode As WrapMode) As Status
197 Return SetStatus(GdiPlus.DllExports.GdipSetLineWrapMode(nativeBrush As *GpLineGradient, wrapMode))
198 End Function
199
200 Const Function WrapMode() As WrapMode
201 SetStatus(GdiPlus.DllExports.GdipGetLineWrapMode(nativeBrush As *GpLineGradient, GetWrapMode))
202 End Function
203
204'Protected
205 Sub LinearGradientBrush()
206 End Sub
207End Class
208
209End Namespace 'Drawing2D
210End Namespace 'Drawing
211End Namespace 'System
Note: See TracBrowser for help on using the repository browser.