blend2d-bindings 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/ChangeLog +26 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +41 -0
  5. data/examples/test.rb +46 -0
  6. data/examples/util/setup_blend2d.rb +46 -0
  7. data/lib/blend2d.rb +95 -0
  8. data/lib/blend2d_api.rb +255 -0
  9. data/lib/blend2d_array.rb +319 -0
  10. data/lib/blend2d_bitarray.rb +275 -0
  11. data/lib/blend2d_bitset.rb +311 -0
  12. data/lib/blend2d_context.rb +1613 -0
  13. data/lib/blend2d_filesystem.rb +211 -0
  14. data/lib/blend2d_font.rb +281 -0
  15. data/lib/blend2d_fontdata.rb +209 -0
  16. data/lib/blend2d_fontdefs.rb +552 -0
  17. data/lib/blend2d_fontface.rb +345 -0
  18. data/lib/blend2d_fontfeaturesettings.rb +210 -0
  19. data/lib/blend2d_fontmanager.rb +187 -0
  20. data/lib/blend2d_fontvariationsettings.rb +210 -0
  21. data/lib/blend2d_format.rb +112 -0
  22. data/lib/blend2d_geometry.rb +424 -0
  23. data/lib/blend2d_glyphbuffer.rb +141 -0
  24. data/lib/blend2d_glyphrun.rb +101 -0
  25. data/lib/blend2d_gradient.rb +429 -0
  26. data/lib/blend2d_image.rb +291 -0
  27. data/lib/blend2d_imagecodec.rb +219 -0
  28. data/lib/blend2d_imagedecoder.rb +168 -0
  29. data/lib/blend2d_imageencoder.rb +159 -0
  30. data/lib/blend2d_matrix.rb +132 -0
  31. data/lib/blend2d_object.rb +326 -0
  32. data/lib/blend2d_path.rb +511 -0
  33. data/lib/blend2d_pattern.rb +202 -0
  34. data/lib/blend2d_pixelconverter.rb +109 -0
  35. data/lib/blend2d_random.rb +77 -0
  36. data/lib/blend2d_rgba.rb +95 -0
  37. data/lib/blend2d_runtime.rb +259 -0
  38. data/lib/blend2d_string.rb +245 -0
  39. data/lib/blend2d_var.rb +294 -0
  40. data/lib/libblend2d.aarch64.so +0 -0
  41. data/lib/libblend2d.arm64.dylib +0 -0
  42. data/lib/libblend2d.dll +0 -0
  43. data/lib/libblend2d.x86_64.dylib +0 -0
  44. data/lib/libblend2d.x86_64.so +0 -0
  45. metadata +99 -0
@@ -0,0 +1,429 @@
1
+ # Ruby-Blend2D : Yet another Blend2D wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/blend2d-bindings
4
+ #
5
+ # [NOTICE] Autogenerated. Do not edit.
6
+
7
+ require 'ffi'
8
+ require_relative 'blend2d_geometry'
9
+ require_relative 'blend2d_matrix'
10
+ require_relative 'blend2d_object'
11
+ require_relative 'blend2d_rgba'
12
+
13
+ module Blend2D
14
+ extend FFI::Library
15
+ # Define/Macro
16
+
17
+
18
+ # Enum
19
+
20
+ BL_GRADIENT_TYPE_LINEAR = 0
21
+ BL_GRADIENT_TYPE_RADIAL = 1
22
+ BL_GRADIENT_TYPE_CONIC = 2
23
+ BL_GRADIENT_TYPE_MAX_VALUE = 2
24
+ BL_GRADIENT_TYPE_FORCE_UINT = -1
25
+ BL_GRADIENT_VALUE_COMMON_X0 = 0
26
+ BL_GRADIENT_VALUE_COMMON_Y0 = 1
27
+ BL_GRADIENT_VALUE_COMMON_X1 = 2
28
+ BL_GRADIENT_VALUE_COMMON_Y1 = 3
29
+ BL_GRADIENT_VALUE_RADIAL_R0 = 4
30
+ BL_GRADIENT_VALUE_RADIAL_R1 = 5
31
+ BL_GRADIENT_VALUE_CONIC_ANGLE = 2
32
+ BL_GRADIENT_VALUE_CONIC_REPEAT = 3
33
+ BL_GRADIENT_VALUE_MAX_VALUE = 5
34
+ BL_GRADIENT_VALUE_FORCE_UINT = -1
35
+ BL_GRADIENT_QUALITY_NEAREST = 0
36
+ BL_GRADIENT_QUALITY_SMOOTH = 1
37
+ BL_GRADIENT_QUALITY_DITHER = 2
38
+ BL_GRADIENT_QUALITY_MAX_VALUE = 2
39
+ BL_GRADIENT_QUALITY_FORCE_UINT = -1
40
+
41
+ # Typedef
42
+
43
+ typedef :int, :BLGradientType
44
+ typedef :int, :BLGradientValue
45
+ typedef :int, :BLGradientQuality
46
+
47
+ # Struct
48
+
49
+ class BLGradientStop < FFI::Struct
50
+ layout(
51
+ :offset, :double,
52
+ :rgba, BLRgba64,
53
+ )
54
+ def offset = self[:offset]
55
+ def offset=(v) self[:offset] = v end
56
+ def rgba = self[:rgba]
57
+ def rgba=(v) self[:rgba] = v end
58
+ def self.create_as(_offset_, _rgba_)
59
+ instance = BLGradientStop.new
60
+ instance[:offset] = _offset_
61
+ instance[:rgba] = _rgba_
62
+ instance
63
+ end
64
+ end
65
+
66
+ class BLLinearGradientValues < FFI::Struct
67
+ layout(
68
+ :x0, :double,
69
+ :y0, :double,
70
+ :x1, :double,
71
+ :y1, :double,
72
+ )
73
+ def x0 = self[:x0]
74
+ def x0=(v) self[:x0] = v end
75
+ def y0 = self[:y0]
76
+ def y0=(v) self[:y0] = v end
77
+ def x1 = self[:x1]
78
+ def x1=(v) self[:x1] = v end
79
+ def y1 = self[:y1]
80
+ def y1=(v) self[:y1] = v end
81
+ def self.create_as(_x0_, _y0_, _x1_, _y1_)
82
+ instance = BLLinearGradientValues.new
83
+ instance[:x0] = _x0_
84
+ instance[:y0] = _y0_
85
+ instance[:x1] = _x1_
86
+ instance[:y1] = _y1_
87
+ instance
88
+ end
89
+ end
90
+
91
+ class BLRadialGradientValues < FFI::Struct
92
+ layout(
93
+ :x0, :double,
94
+ :y0, :double,
95
+ :x1, :double,
96
+ :y1, :double,
97
+ :r0, :double,
98
+ :r1, :double,
99
+ )
100
+ def x0 = self[:x0]
101
+ def x0=(v) self[:x0] = v end
102
+ def y0 = self[:y0]
103
+ def y0=(v) self[:y0] = v end
104
+ def x1 = self[:x1]
105
+ def x1=(v) self[:x1] = v end
106
+ def y1 = self[:y1]
107
+ def y1=(v) self[:y1] = v end
108
+ def r0 = self[:r0]
109
+ def r0=(v) self[:r0] = v end
110
+ def r1 = self[:r1]
111
+ def r1=(v) self[:r1] = v end
112
+ def self.create_as(_x0_, _y0_, _x1_, _y1_, _r0_, _r1_)
113
+ instance = BLRadialGradientValues.new
114
+ instance[:x0] = _x0_
115
+ instance[:y0] = _y0_
116
+ instance[:x1] = _x1_
117
+ instance[:y1] = _y1_
118
+ instance[:r0] = _r0_
119
+ instance[:r1] = _r1_
120
+ instance
121
+ end
122
+ end
123
+
124
+ class BLConicGradientValues < FFI::Struct
125
+ layout(
126
+ :x0, :double,
127
+ :y0, :double,
128
+ :angle, :double,
129
+ :repeat, :double,
130
+ )
131
+ def x0 = self[:x0]
132
+ def x0=(v) self[:x0] = v end
133
+ def y0 = self[:y0]
134
+ def y0=(v) self[:y0] = v end
135
+ def angle = self[:angle]
136
+ def angle=(v) self[:angle] = v end
137
+ def repeat = self[:repeat]
138
+ def repeat=(v) self[:repeat] = v end
139
+ def self.create_as(_x0_, _y0_, _angle_, _repeat_)
140
+ instance = BLConicGradientValues.new
141
+ instance[:x0] = _x0_
142
+ instance[:y0] = _y0_
143
+ instance[:angle] = _angle_
144
+ instance[:repeat] = _repeat_
145
+ instance
146
+ end
147
+ end
148
+
149
+ class BLGradientCore < FFI::Struct
150
+ layout(
151
+ :_d, BLObjectDetail,
152
+ )
153
+ def _d = self[:_d]
154
+ def _d=(v) self[:_d] = v end
155
+ def init() = blGradientInit(self)
156
+ def self.create()
157
+ instance = BLGradientCore.new
158
+ blGradientInit(instance)
159
+ instance
160
+ end
161
+ def initMove(other) = blGradientInitMove(self, other)
162
+ def initWeak(other) = blGradientInitWeak(self, other)
163
+ def initAs(type, values, extendMode, stops, n, transform) = blGradientInitAs(self, type, values, extendMode, stops, n, transform)
164
+ def self.create_as(type, values, extendMode, stops, n, transform)
165
+ instance = BLGradientCore.new
166
+ blGradientInitAs(instance, type, values, extendMode, stops, n, transform)
167
+ instance
168
+ end
169
+ def destroy() = blGradientDestroy(self)
170
+ def reset() = blGradientReset(self)
171
+ def assignMove(other) = blGradientAssignMove(self, other)
172
+ def assignWeak(other) = blGradientAssignWeak(self, other)
173
+ def create(type, values, extendMode, stops, n, transform) = blGradientCreate(self, type, values, extendMode, stops, n, transform)
174
+ def shrink() = blGradientShrink(self)
175
+ def reserve(n) = blGradientReserve(self, n)
176
+ def getType() = blGradientGetType(self)
177
+ def setType(type) = blGradientSetType(self, type)
178
+ def getExtendMode() = blGradientGetExtendMode(self)
179
+ def setExtendMode(extendMode) = blGradientSetExtendMode(self, extendMode)
180
+ def getValue(index) = blGradientGetValue(self, index)
181
+ def setValue(index, value) = blGradientSetValue(self, index, value)
182
+ def setValues(index, values, n) = blGradientSetValues(self, index, values, n)
183
+ def getSize() = blGradientGetSize(self)
184
+ def getCapacity() = blGradientGetCapacity(self)
185
+ def getStops() = blGradientGetStops(self)
186
+ def resetStops() = blGradientResetStops(self)
187
+ def assignStops(stops, n) = blGradientAssignStops(self, stops, n)
188
+ def addStopRgba32(offset, argb32) = blGradientAddStopRgba32(self, offset, argb32)
189
+ def addStopRgba64(offset, argb64) = blGradientAddStopRgba64(self, offset, argb64)
190
+ def removeStop(index) = blGradientRemoveStop(self, index)
191
+ def removeStopByOffset(offset, all) = blGradientRemoveStopByOffset(self, offset, all)
192
+ def removeStopsByIndex(rStart, rEnd) = blGradientRemoveStopsByIndex(self, rStart, rEnd)
193
+ def removeStopsByOffset(offsetMin, offsetMax) = blGradientRemoveStopsByOffset(self, offsetMin, offsetMax)
194
+ def replaceStopRgba32(index, offset, rgba32) = blGradientReplaceStopRgba32(self, index, offset, rgba32)
195
+ def replaceStopRgba64(index, offset, rgba64) = blGradientReplaceStopRgba64(self, index, offset, rgba64)
196
+ def indexOfStop(offset) = blGradientIndexOfStop(self, offset)
197
+ def getTransform(transformOut) = blGradientGetTransform(self, transformOut)
198
+ def getTransformType() = blGradientGetTransformType(self)
199
+ def applyTransformOp(opType, opData) = blGradientApplyTransformOp(self, opType, opData)
200
+ def equals(b) = blGradientEquals(a, b)
201
+ end
202
+
203
+
204
+ # class BLGradientStop < FFI::Struct
205
+ # layout(
206
+ # :offset, :double,
207
+ # :rgba, BLRgba64,
208
+ # )
209
+ # end
210
+
211
+ # class BLLinearGradientValues < FFI::Struct
212
+ # layout(
213
+ # :x0, :double,
214
+ # :y0, :double,
215
+ # :x1, :double,
216
+ # :y1, :double,
217
+ # )
218
+ # end
219
+
220
+ # class BLRadialGradientValues < FFI::Struct
221
+ # layout(
222
+ # :x0, :double,
223
+ # :y0, :double,
224
+ # :x1, :double,
225
+ # :y1, :double,
226
+ # :r0, :double,
227
+ # )
228
+ # end
229
+
230
+ # class BLConicGradientValues < FFI::Struct
231
+ # layout(
232
+ # :x0, :double,
233
+ # :y0, :double,
234
+ # :angle, :double,
235
+ # )
236
+ # end
237
+
238
+ # class BLGradientCore < FFI::Struct
239
+ # layout(
240
+ # :_d, BLObjectDetail,
241
+ # )
242
+ # end
243
+
244
+ class BLGradientImpl_Contents < FFI::Union
245
+ layout(
246
+ :values, [:double, 6],
247
+ :linear, BLLinearGradientValues,
248
+ :radial, BLRadialGradientValues,
249
+ :conic, BLConicGradientValues,
250
+ )
251
+ end
252
+
253
+ class BLGradientImpl < FFI::Struct
254
+ layout(
255
+ :stops, :pointer,
256
+ :size, :ulong,
257
+ :capacity, :ulong,
258
+ :transform, BLMatrix2D,
259
+ :contents, BLGradientImpl_Contents,
260
+ )
261
+ end
262
+
263
+
264
+ # Function
265
+
266
+ def self.setup_gradient_symbols(output_error = false)
267
+ symbols = [
268
+ :blGradientInit,
269
+ :blGradientInitMove,
270
+ :blGradientInitWeak,
271
+ :blGradientInitAs,
272
+ :blGradientDestroy,
273
+ :blGradientReset,
274
+ :blGradientAssignMove,
275
+ :blGradientAssignWeak,
276
+ :blGradientCreate,
277
+ :blGradientShrink,
278
+ :blGradientReserve,
279
+ :blGradientGetType,
280
+ :blGradientSetType,
281
+ :blGradientGetExtendMode,
282
+ :blGradientSetExtendMode,
283
+ :blGradientGetValue,
284
+ :blGradientSetValue,
285
+ :blGradientSetValues,
286
+ :blGradientGetSize,
287
+ :blGradientGetCapacity,
288
+ :blGradientGetStops,
289
+ :blGradientResetStops,
290
+ :blGradientAssignStops,
291
+ :blGradientAddStopRgba32,
292
+ :blGradientAddStopRgba64,
293
+ :blGradientRemoveStop,
294
+ :blGradientRemoveStopByOffset,
295
+ :blGradientRemoveStopsByIndex,
296
+ :blGradientRemoveStopsByOffset,
297
+ :blGradientReplaceStopRgba32,
298
+ :blGradientReplaceStopRgba64,
299
+ :blGradientIndexOfStop,
300
+ :blGradientGetTransform,
301
+ :blGradientGetTransformType,
302
+ :blGradientApplyTransformOp,
303
+ :blGradientEquals,
304
+ ]
305
+ apis = {
306
+ :blGradientInit => :blGradientInit,
307
+ :blGradientInitMove => :blGradientInitMove,
308
+ :blGradientInitWeak => :blGradientInitWeak,
309
+ :blGradientInitAs => :blGradientInitAs,
310
+ :blGradientDestroy => :blGradientDestroy,
311
+ :blGradientReset => :blGradientReset,
312
+ :blGradientAssignMove => :blGradientAssignMove,
313
+ :blGradientAssignWeak => :blGradientAssignWeak,
314
+ :blGradientCreate => :blGradientCreate,
315
+ :blGradientShrink => :blGradientShrink,
316
+ :blGradientReserve => :blGradientReserve,
317
+ :blGradientGetType => :blGradientGetType,
318
+ :blGradientSetType => :blGradientSetType,
319
+ :blGradientGetExtendMode => :blGradientGetExtendMode,
320
+ :blGradientSetExtendMode => :blGradientSetExtendMode,
321
+ :blGradientGetValue => :blGradientGetValue,
322
+ :blGradientSetValue => :blGradientSetValue,
323
+ :blGradientSetValues => :blGradientSetValues,
324
+ :blGradientGetSize => :blGradientGetSize,
325
+ :blGradientGetCapacity => :blGradientGetCapacity,
326
+ :blGradientGetStops => :blGradientGetStops,
327
+ :blGradientResetStops => :blGradientResetStops,
328
+ :blGradientAssignStops => :blGradientAssignStops,
329
+ :blGradientAddStopRgba32 => :blGradientAddStopRgba32,
330
+ :blGradientAddStopRgba64 => :blGradientAddStopRgba64,
331
+ :blGradientRemoveStop => :blGradientRemoveStop,
332
+ :blGradientRemoveStopByOffset => :blGradientRemoveStopByOffset,
333
+ :blGradientRemoveStopsByIndex => :blGradientRemoveStopsByIndex,
334
+ :blGradientRemoveStopsByOffset => :blGradientRemoveStopsByOffset,
335
+ :blGradientReplaceStopRgba32 => :blGradientReplaceStopRgba32,
336
+ :blGradientReplaceStopRgba64 => :blGradientReplaceStopRgba64,
337
+ :blGradientIndexOfStop => :blGradientIndexOfStop,
338
+ :blGradientGetTransform => :blGradientGetTransform,
339
+ :blGradientGetTransformType => :blGradientGetTransformType,
340
+ :blGradientApplyTransformOp => :blGradientApplyTransformOp,
341
+ :blGradientEquals => :blGradientEquals,
342
+ }
343
+ args = {
344
+ :blGradientInit => [:pointer],
345
+ :blGradientInitMove => [:pointer, :pointer],
346
+ :blGradientInitWeak => [:pointer, :pointer],
347
+ :blGradientInitAs => [:pointer, :int, :pointer, :int, :pointer, :ulong_long, :pointer],
348
+ :blGradientDestroy => [:pointer],
349
+ :blGradientReset => [:pointer],
350
+ :blGradientAssignMove => [:pointer, :pointer],
351
+ :blGradientAssignWeak => [:pointer, :pointer],
352
+ :blGradientCreate => [:pointer, :int, :pointer, :int, :pointer, :ulong_long, :pointer],
353
+ :blGradientShrink => [:pointer],
354
+ :blGradientReserve => [:pointer, :ulong_long],
355
+ :blGradientGetType => [:pointer],
356
+ :blGradientSetType => [:pointer, :int],
357
+ :blGradientGetExtendMode => [:pointer],
358
+ :blGradientSetExtendMode => [:pointer, :int],
359
+ :blGradientGetValue => [:pointer, :ulong_long],
360
+ :blGradientSetValue => [:pointer, :ulong_long, :double],
361
+ :blGradientSetValues => [:pointer, :ulong_long, :pointer, :ulong_long],
362
+ :blGradientGetSize => [:pointer],
363
+ :blGradientGetCapacity => [:pointer],
364
+ :blGradientGetStops => [:pointer],
365
+ :blGradientResetStops => [:pointer],
366
+ :blGradientAssignStops => [:pointer, :pointer, :ulong_long],
367
+ :blGradientAddStopRgba32 => [:pointer, :double, :uint],
368
+ :blGradientAddStopRgba64 => [:pointer, :double, :ulong_long],
369
+ :blGradientRemoveStop => [:pointer, :ulong_long],
370
+ :blGradientRemoveStopByOffset => [:pointer, :double, :uint],
371
+ :blGradientRemoveStopsByIndex => [:pointer, :ulong_long, :ulong_long],
372
+ :blGradientRemoveStopsByOffset => [:pointer, :double, :double],
373
+ :blGradientReplaceStopRgba32 => [:pointer, :ulong_long, :double, :uint],
374
+ :blGradientReplaceStopRgba64 => [:pointer, :ulong_long, :double, :ulong_long],
375
+ :blGradientIndexOfStop => [:pointer, :double],
376
+ :blGradientGetTransform => [:pointer, :pointer],
377
+ :blGradientGetTransformType => [:pointer],
378
+ :blGradientApplyTransformOp => [:pointer, :int, :pointer],
379
+ :blGradientEquals => [:pointer, :pointer],
380
+ }
381
+ retvals = {
382
+ :blGradientInit => :uint,
383
+ :blGradientInitMove => :uint,
384
+ :blGradientInitWeak => :uint,
385
+ :blGradientInitAs => :uint,
386
+ :blGradientDestroy => :uint,
387
+ :blGradientReset => :uint,
388
+ :blGradientAssignMove => :uint,
389
+ :blGradientAssignWeak => :uint,
390
+ :blGradientCreate => :uint,
391
+ :blGradientShrink => :uint,
392
+ :blGradientReserve => :uint,
393
+ :blGradientGetType => :int,
394
+ :blGradientSetType => :uint,
395
+ :blGradientGetExtendMode => :int,
396
+ :blGradientSetExtendMode => :uint,
397
+ :blGradientGetValue => :double,
398
+ :blGradientSetValue => :uint,
399
+ :blGradientSetValues => :uint,
400
+ :blGradientGetSize => :ulong_long,
401
+ :blGradientGetCapacity => :ulong_long,
402
+ :blGradientGetStops => :pointer,
403
+ :blGradientResetStops => :uint,
404
+ :blGradientAssignStops => :uint,
405
+ :blGradientAddStopRgba32 => :uint,
406
+ :blGradientAddStopRgba64 => :uint,
407
+ :blGradientRemoveStop => :uint,
408
+ :blGradientRemoveStopByOffset => :uint,
409
+ :blGradientRemoveStopsByIndex => :uint,
410
+ :blGradientRemoveStopsByOffset => :uint,
411
+ :blGradientReplaceStopRgba32 => :uint,
412
+ :blGradientReplaceStopRgba64 => :uint,
413
+ :blGradientIndexOfStop => :ulong_long,
414
+ :blGradientGetTransform => :uint,
415
+ :blGradientGetTransformType => :int,
416
+ :blGradientApplyTransformOp => :uint,
417
+ :blGradientEquals => :bool,
418
+ }
419
+ symbols.each do |sym|
420
+ begin
421
+ attach_function apis[sym], sym, args[sym], retvals[sym]
422
+ rescue FFI::NotFoundError => error
423
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
424
+ end
425
+ end
426
+ end
427
+
428
+ end
429
+