lisette-stdlib 0.1.13

Little language inspired by Rust that compiles to Go
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
// Generated by Lisette bindgen
// Source: image (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.12

import "go:image/color"
import "go:io"

pub enum YCbCrSubsampleRatio: int {
  YCbCrSubsampleRatio410 = 5,
  YCbCrSubsampleRatio411 = 4,
  YCbCrSubsampleRatio420 = 2,
  YCbCrSubsampleRatio422 = 1,
  YCbCrSubsampleRatio440 = 3,
  YCbCrSubsampleRatio444 = 0,
}

pub const YCbCrSubsampleRatio410: YCbCrSubsampleRatio = 5

pub const YCbCrSubsampleRatio411: YCbCrSubsampleRatio = 4

pub const YCbCrSubsampleRatio420: YCbCrSubsampleRatio = 2

pub const YCbCrSubsampleRatio422: YCbCrSubsampleRatio = 1

pub const YCbCrSubsampleRatio440: YCbCrSubsampleRatio = 3

pub const YCbCrSubsampleRatio444: YCbCrSubsampleRatio = 0

pub fn Decode(r: io.Reader) -> Result<(Image, string), error>

pub fn DecodeConfig(r: io.Reader) -> Result<(Config, string), error>

pub fn NewAlpha(r: Rectangle) -> Ref<Alpha>

pub fn NewAlpha16(r: Rectangle) -> Ref<Alpha16>

pub fn NewCMYK(r: Rectangle) -> Ref<CMYK>

pub fn NewGray(r: Rectangle) -> Ref<Gray>

pub fn NewGray16(r: Rectangle) -> Ref<Gray16>

pub fn NewNRGBA(r: Rectangle) -> Ref<NRGBA>

pub fn NewNRGBA64(r: Rectangle) -> Ref<NRGBA64>

pub fn NewNYCbCrA(r: Rectangle, subsampleRatio: YCbCrSubsampleRatio) -> Ref<NYCbCrA>

pub fn NewPaletted(r: Rectangle, p: color.Palette) -> Ref<Paletted>

pub fn NewRGBA(r: Rectangle) -> Ref<RGBA>

pub fn NewRGBA64(r: Rectangle) -> Ref<RGBA64>

pub fn NewUniform(c: color.Color) -> Ref<Uniform>

pub fn NewYCbCr(r: Rectangle, subsampleRatio: YCbCrSubsampleRatio) -> Ref<YCbCr>

pub fn Pt(x: int, y: int) -> Point

pub fn Rect(x0: int, y0: int, x1: int, y1: int) -> Rectangle

/// RegisterFormat registers an image format for use by [Decode].
/// Name is the name of the format, like "jpeg" or "png".
/// Magic is the magic prefix that identifies the format's encoding. The magic
/// string can contain "?" wildcards that each match any one byte.
/// [Decode] is the function that decodes the encoded image.
/// [DecodeConfig] is the function that decodes just its configuration.
pub fn RegisterFormat(
  name: string,
  magic: string,
  decode: fn(io.Reader) -> Result<Image, error>,
  decodeConfig: fn(io.Reader) -> Result<Config, error>,
)

/// Alpha is an in-memory image whose At method returns [color.Alpha] values.
pub struct Alpha {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
}

/// Alpha16 is an in-memory image whose At method returns [color.Alpha16] values.
pub struct Alpha16 {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
}

/// CMYK is an in-memory image whose At method returns [color.CMYK] values.
pub struct CMYK {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
}

/// Config holds an image's color model and dimensions.
pub struct Config {
  pub ColorModel: Option<color.Model>,
  pub Width: int,
  pub Height: int,
}

/// Gray is an in-memory image whose At method returns [color.Gray] values.
pub struct Gray {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
}

/// Gray16 is an in-memory image whose At method returns [color.Gray16] values.
pub struct Gray16 {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
}

/// Image is a finite rectangular grid of [color.Color] values taken from a color
/// model.
pub interface Image {
  fn At(x: int, y: int) -> color.Color
  fn Bounds() -> Rectangle
  fn ColorModel() -> color.Model
}

/// NRGBA is an in-memory image whose At method returns [color.NRGBA] values.
pub struct NRGBA {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
}

/// NRGBA64 is an in-memory image whose At method returns [color.NRGBA64] values.
pub struct NRGBA64 {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
}

/// NYCbCrA is an in-memory image of non-alpha-premultiplied Y'CbCr-with-alpha
/// colors. A and AStride are analogous to the Y and YStride fields of the
/// embedded YCbCr.
pub struct NYCbCrA {
  pub YCbCr: YCbCr,
  pub A: Slice<uint8>,
  pub AStride: int,
}

/// Paletted is an in-memory image of uint8 indices into a given palette.
pub struct Paletted {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
  pub Palette: color.Palette,
}

/// PalettedImage is an image whose colors may come from a limited palette.
/// If m is a PalettedImage and m.ColorModel() returns a [color.Palette] p,
/// then m.At(x, y) should be equivalent to p[m.ColorIndexAt(x, y)]. If m's
/// color model is not a color.Palette, then ColorIndexAt's behavior is
/// undefined.
pub interface PalettedImage {
  fn At(x: int, y: int) -> color.Color
  fn Bounds() -> Rectangle
  fn ColorIndexAt(x: int, y: int) -> uint8
  fn ColorModel() -> color.Model
}

/// A Point is an X, Y coordinate pair. The axes increase right and down.
pub struct Point {
  pub X: int,
  pub Y: int,
}

/// RGBA is an in-memory image whose At method returns [color.RGBA] values.
pub struct RGBA {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
}

/// RGBA64 is an in-memory image whose At method returns [color.RGBA64] values.
pub struct RGBA64 {
  pub Pix: Slice<uint8>,
  pub Stride: int,
  pub Rect: Rectangle,
}

/// RGBA64Image is an [Image] whose pixels can be converted directly to a
/// color.RGBA64.
pub interface RGBA64Image {
  fn At(x: int, y: int) -> color.Color
  fn Bounds() -> Rectangle
  fn ColorModel() -> color.Model
  fn RGBA64At(x: int, y: int) -> color.RGBA64
}

/// A Rectangle contains the points with Min.X <= X < Max.X, Min.Y <= Y < Max.Y.
/// It is well-formed if Min.X <= Max.X and likewise for Y. Points are always
/// well-formed. A rectangle's methods always return well-formed outputs for
/// well-formed inputs.
/// 
/// A Rectangle is also an [Image] whose bounds are the rectangle itself. At
/// returns color.Opaque for points in the rectangle and color.Transparent
/// otherwise.
pub struct Rectangle {
  pub Min: Point,
  pub Max: Point,
}

/// Uniform is an infinite-sized [Image] of uniform color.
/// It implements the [color.Color], [color.Model], and [Image] interfaces.
pub struct Uniform {
  pub C: Option<color.Color>,
}

/// YCbCr is an in-memory image of Y'CbCr colors. There is one Y sample per
/// pixel, but each Cb and Cr sample can span one or more pixels.
/// YStride is the Y slice index delta between vertically adjacent pixels.
/// CStride is the Cb and Cr slice index delta between vertically adjacent pixels
/// that map to separate chroma samples.
/// It is not an absolute requirement, but YStride and len(Y) are typically
/// multiples of 8, and:
/// 
/// 	For 4:4:4, CStride == YStride/1 && len(Cb) == len(Cr) == len(Y)/1.
/// 	For 4:2:2, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/2.
/// 	For 4:2:0, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/4.
/// 	For 4:4:0, CStride == YStride/1 && len(Cb) == len(Cr) == len(Y)/2.
/// 	For 4:1:1, CStride == YStride/4 && len(Cb) == len(Cr) == len(Y)/4.
/// 	For 4:1:0, CStride == YStride/4 && len(Cb) == len(Cr) == len(Y)/8.
pub struct YCbCr {
  pub Y: Slice<uint8>,
  pub Cb: Slice<uint8>,
  pub Cr: Slice<uint8>,
  pub YStride: int,
  pub CStride: int,
  pub SubsampleRatio: YCbCrSubsampleRatio,
  pub Rect: Rectangle,
}

pub var Black: Ref<Uniform>

/// ErrFormat indicates that decoding encountered an unknown format.
pub var ErrFormat: error

pub var Opaque: Ref<Uniform>

pub var Transparent: Ref<Uniform>

pub var White: Ref<Uniform>

pub var ZP: Point

pub var ZR: Rectangle

impl Alpha {
  fn AlphaAt(self: Ref<Alpha>, x: int, y: int) -> color.Alpha

  fn At(self: Ref<Alpha>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<Alpha>) -> Rectangle

  fn ColorModel(self: Ref<Alpha>) -> color.Model

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<Alpha>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<Alpha>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<Alpha>, x: int, y: int) -> color.RGBA64

  fn Set(self: Ref<Alpha>, x: int, y: int, c: color.Color)

  fn SetAlpha(self: Ref<Alpha>, x: int, y: int, c: color.Alpha)

  fn SetRGBA64(self: Ref<Alpha>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<Alpha>, r: Rectangle) -> Image
}

impl Alpha16 {
  fn Alpha16At(self: Ref<Alpha16>, x: int, y: int) -> color.Alpha16

  fn At(self: Ref<Alpha16>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<Alpha16>) -> Rectangle

  fn ColorModel(self: Ref<Alpha16>) -> color.Model

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<Alpha16>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<Alpha16>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<Alpha16>, x: int, y: int) -> color.RGBA64

  fn Set(self: Ref<Alpha16>, x: int, y: int, c: color.Color)

  fn SetAlpha16(self: Ref<Alpha16>, x: int, y: int, c: color.Alpha16)

  fn SetRGBA64(self: Ref<Alpha16>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<Alpha16>, r: Rectangle) -> Image
}

impl CMYK {
  fn At(self: Ref<CMYK>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<CMYK>) -> Rectangle

  fn CMYKAt(self: Ref<CMYK>, x: int, y: int) -> color.CMYK

  fn ColorModel(self: Ref<CMYK>) -> color.Model

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<CMYK>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<CMYK>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<CMYK>, x: int, y: int) -> color.RGBA64

  fn Set(self: Ref<CMYK>, x: int, y: int, c: color.Color)

  fn SetCMYK(self: Ref<CMYK>, x: int, y: int, c: color.CMYK)

  fn SetRGBA64(self: Ref<CMYK>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<CMYK>, r: Rectangle) -> Image
}

impl Gray {
  fn At(self: Ref<Gray>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<Gray>) -> Rectangle

  fn ColorModel(self: Ref<Gray>) -> color.Model

  fn GrayAt(self: Ref<Gray>, x: int, y: int) -> color.Gray

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<Gray>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<Gray>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<Gray>, x: int, y: int) -> color.RGBA64

  fn Set(self: Ref<Gray>, x: int, y: int, c: color.Color)

  fn SetGray(self: Ref<Gray>, x: int, y: int, c: color.Gray)

  fn SetRGBA64(self: Ref<Gray>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<Gray>, r: Rectangle) -> Image
}

impl Gray16 {
  fn At(self: Ref<Gray16>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<Gray16>) -> Rectangle

  fn ColorModel(self: Ref<Gray16>) -> color.Model

  fn Gray16At(self: Ref<Gray16>, x: int, y: int) -> color.Gray16

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<Gray16>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<Gray16>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<Gray16>, x: int, y: int) -> color.RGBA64

  fn Set(self: Ref<Gray16>, x: int, y: int, c: color.Color)

  fn SetGray16(self: Ref<Gray16>, x: int, y: int, c: color.Gray16)

  fn SetRGBA64(self: Ref<Gray16>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<Gray16>, r: Rectangle) -> Image
}

impl NRGBA {
  fn At(self: Ref<NRGBA>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<NRGBA>) -> Rectangle

  fn ColorModel(self: Ref<NRGBA>) -> color.Model

  fn NRGBAAt(self: Ref<NRGBA>, x: int, y: int) -> color.NRGBA

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<NRGBA>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<NRGBA>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<NRGBA>, x: int, y: int) -> color.RGBA64

  fn Set(self: Ref<NRGBA>, x: int, y: int, c: color.Color)

  fn SetNRGBA(self: Ref<NRGBA>, x: int, y: int, c: color.NRGBA)

  fn SetRGBA64(self: Ref<NRGBA>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<NRGBA>, r: Rectangle) -> Image
}

impl NRGBA64 {
  fn At(self: Ref<NRGBA64>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<NRGBA64>) -> Rectangle

  fn ColorModel(self: Ref<NRGBA64>) -> color.Model

  fn NRGBA64At(self: Ref<NRGBA64>, x: int, y: int) -> color.NRGBA64

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<NRGBA64>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<NRGBA64>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<NRGBA64>, x: int, y: int) -> color.RGBA64

  fn Set(self: Ref<NRGBA64>, x: int, y: int, c: color.Color)

  fn SetNRGBA64(self: Ref<NRGBA64>, x: int, y: int, c: color.NRGBA64)

  fn SetRGBA64(self: Ref<NRGBA64>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<NRGBA64>, r: Rectangle) -> Image
}

impl NYCbCrA {
  /// AOffset returns the index of the first element of A that corresponds to the
  /// pixel at (x, y).
  fn AOffset(self: Ref<NYCbCrA>, x: int, y: int) -> int

  fn At(self: Ref<NYCbCrA>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<NYCbCrA>) -> Rectangle

  /// COffset returns the index of the first element of Cb or Cr that corresponds
  /// to the pixel at (x, y).
  fn COffset(self: Ref<NYCbCrA>, x: int, y: int) -> int

  fn ColorModel(self: Ref<NYCbCrA>) -> color.Model

  fn NYCbCrAAt(self: Ref<NYCbCrA>, x: int, y: int) -> color.NYCbCrA

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<NYCbCrA>) -> bool

  fn RGBA64At(self: Ref<NYCbCrA>, x: int, y: int) -> color.RGBA64

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<NYCbCrA>, r: Rectangle) -> Image

  fn YCbCrAt(self: Ref<NYCbCrA>, x: int, y: int) -> color.YCbCr

  /// YOffset returns the index of the first element of Y that corresponds to
  /// the pixel at (x, y).
  fn YOffset(self: Ref<NYCbCrA>, x: int, y: int) -> int
}

impl Paletted {
  fn At(self: Ref<Paletted>, x: int, y: int) -> Option<color.Color>

  fn Bounds(self: Ref<Paletted>) -> Rectangle

  fn ColorIndexAt(self: Ref<Paletted>, x: int, y: int) -> uint8

  fn ColorModel(self: Ref<Paletted>) -> color.Model

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<Paletted>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<Paletted>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<Paletted>, x: int, y: int) -> color.RGBA64

  fn Set(self: Ref<Paletted>, x: int, y: int, c: color.Color)

  fn SetColorIndex(self: Ref<Paletted>, x: int, y: int, index: uint8)

  fn SetRGBA64(self: Ref<Paletted>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<Paletted>, r: Rectangle) -> Image
}

impl Point {
  /// Add returns the vector p+q.
  fn Add(self, q: Point) -> Point

  /// Div returns the vector p/k.
  fn Div(self, k: int) -> Point

  /// Eq reports whether p and q are equal.
  fn Eq(self, q: Point) -> bool

  /// In reports whether p is in r.
  fn In(self, r: Rectangle) -> bool

  /// Mod returns the point q in r such that p.X-q.X is a multiple of r's width
  /// and p.Y-q.Y is a multiple of r's height.
  fn Mod(self, r: Rectangle) -> Point

  /// Mul returns the vector p*k.
  fn Mul(self, k: int) -> Point

  /// String returns a string representation of p like "(3,4)".
  fn String(self) -> string

  /// Sub returns the vector p-q.
  fn Sub(self, q: Point) -> Point
}

impl RGBA {
  fn At(self: Ref<RGBA>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<RGBA>) -> Rectangle

  fn ColorModel(self: Ref<RGBA>) -> color.Model

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<RGBA>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<RGBA>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<RGBA>, x: int, y: int) -> color.RGBA64

  fn RGBAAt(self: Ref<RGBA>, x: int, y: int) -> color.RGBA

  fn Set(self: Ref<RGBA>, x: int, y: int, c: color.Color)

  fn SetRGBA(self: Ref<RGBA>, x: int, y: int, c: color.RGBA)

  fn SetRGBA64(self: Ref<RGBA>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<RGBA>, r: Rectangle) -> Image
}

impl RGBA64 {
  fn At(self: Ref<RGBA64>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<RGBA64>) -> Rectangle

  fn ColorModel(self: Ref<RGBA64>) -> color.Model

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<RGBA64>) -> bool

  /// PixOffset returns the index of the first element of Pix that corresponds to
  /// the pixel at (x, y).
  fn PixOffset(self: Ref<RGBA64>, x: int, y: int) -> int

  fn RGBA64At(self: Ref<RGBA64>, x: int, y: int) -> color.RGBA64

  fn Set(self: Ref<RGBA64>, x: int, y: int, c: color.Color)

  fn SetRGBA64(self: Ref<RGBA64>, x: int, y: int, c: color.RGBA64)

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<RGBA64>, r: Rectangle) -> Image
}

impl Rectangle {
  /// Add returns the rectangle r translated by p.
  fn Add(self, p: Point) -> Rectangle

  /// At implements the [Image] interface.
  fn At(self, x: int, y: int) -> color.Color

  /// Bounds implements the [Image] interface.
  fn Bounds(self) -> Rectangle

  /// Canon returns the canonical version of r. The returned rectangle has minimum
  /// and maximum coordinates swapped if necessary so that it is well-formed.
  fn Canon(self) -> Rectangle

  /// ColorModel implements the [Image] interface.
  fn ColorModel(self) -> color.Model

  /// Dx returns r's width.
  fn Dx(self) -> int

  /// Dy returns r's height.
  fn Dy(self) -> int

  /// Empty reports whether the rectangle contains no points.
  fn Empty(self) -> bool

  /// Eq reports whether r and s contain the same set of points. All empty
  /// rectangles are considered equal.
  fn Eq(self, s: Rectangle) -> bool

  /// In reports whether every point in r is in s.
  fn In(self, s: Rectangle) -> bool

  /// Inset returns the rectangle r inset by n, which may be negative. If either
  /// of r's dimensions is less than 2*n then an empty rectangle near the center
  /// of r will be returned.
  fn Inset(self, n: int) -> Rectangle

  /// Intersect returns the largest rectangle contained by both r and s. If the
  /// two rectangles do not overlap then the zero rectangle will be returned.
  fn Intersect(self, s: Rectangle) -> Rectangle

  /// Overlaps reports whether r and s have a non-empty intersection.
  fn Overlaps(self, s: Rectangle) -> bool

  /// RGBA64At implements the [RGBA64Image] interface.
  fn RGBA64At(self, x: int, y: int) -> color.RGBA64

  /// Size returns r's width and height.
  fn Size(self) -> Point

  /// String returns a string representation of r like "(3,4)-(6,5)".
  fn String(self) -> string

  /// Sub returns the rectangle r translated by -p.
  fn Sub(self, p: Point) -> Rectangle

  /// Union returns the smallest rectangle that contains both r and s.
  fn Union(self, s: Rectangle) -> Rectangle
}

impl Uniform {
  fn At(self: Ref<Uniform>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<Uniform>) -> Rectangle

  fn ColorModel(self: Ref<Uniform>) -> color.Model

  fn Convert(self: Ref<Uniform>, arg0: color.Color) -> color.Color

  /// Opaque scans the entire image and reports whether it is fully opaque.
  fn Opaque(self: Ref<Uniform>) -> bool

  fn RGBA(self: Ref<Uniform>) -> (uint32, uint32, uint32, uint32)

  fn RGBA64At(self: Ref<Uniform>, x: int, y: int) -> color.RGBA64
}

impl YCbCr {
  fn At(self: Ref<YCbCr>, x: int, y: int) -> color.Color

  fn Bounds(self: Ref<YCbCr>) -> Rectangle

  /// COffset returns the index of the first element of Cb or Cr that corresponds
  /// to the pixel at (x, y).
  fn COffset(self: Ref<YCbCr>, x: int, y: int) -> int

  fn ColorModel(self: Ref<YCbCr>) -> color.Model

  fn Opaque(self: Ref<YCbCr>) -> bool

  fn RGBA64At(self: Ref<YCbCr>, x: int, y: int) -> color.RGBA64

  /// SubImage returns an image representing the portion of the image p visible
  /// through r. The returned value shares pixels with the original image.
  fn SubImage(self: Ref<YCbCr>, r: Rectangle) -> Image

  fn YCbCrAt(self: Ref<YCbCr>, x: int, y: int) -> color.YCbCr

  /// YOffset returns the index of the first element of Y that corresponds to
  /// the pixel at (x, y).
  fn YOffset(self: Ref<YCbCr>, x: int, y: int) -> int
}

impl YCbCrSubsampleRatio {
  fn String(self) -> string
}