Debian Codegraph @

exp/sprite/portable/portable.go

raw symbols SCIP
1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package portable implements a sprite Engine using the image package.
6 //
7 // It is intended to serve as a reference implementation for testing
8 // other sprite Engines written against OpenGL, or other more exotic
9 // modern hardware interfaces.
10 package portablescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/
11
12 import (
13 "imagescip-go gomod github.com/golang/go/src go1.24.0 image/"
14 "image/drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/"
15
16 xdrawscip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/draw`/ "golang.org/x/image/drawscip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/draw`/"
17 "golang.org/x/image/math/f64scip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/math/f64`/"
18 "golang.org/x/mobile/event/sizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/"
19 "golang.org/x/mobile/exp/f32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/"
20 "golang.org/x/mobile/exp/spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/"
21 "golang.org/x/mobile/exp/sprite/clockscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/clock`/"
22 )
23
24 // Engine builds a sprite Engine that renders onto dst.
25 func Enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/Engine().(dst *imagescip-go gomod github.com/golang/go/src go1.24.0 image/.RGBAscip-go gomod github.com/golang/go/src go1.24.0 image/RGBA#) spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/.Enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Engine# {
26 return &enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#{
27 dstscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#dst.: dst,
28 nodesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#nodes.: []*nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/node#{nil},
29 }
30 }
31
32 type nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/node# struct {
33 // TODO: move this into package sprite as Node.EngineFields.RelTransform??
34 relTransformscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/node#relTransform. f32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/.Affinescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#
35 }
36
37 type texturescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture# struct {
38 mscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#m. *imagescip-go gomod github.com/golang/go/src go1.24.0 image/.RGBAscip-go gomod github.com/golang/go/src go1.24.0 image/RGBA#
39 }
40
41 func (t *texturescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#) Boundsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#Bounds().() (w, h int) {
42 b := t.mscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#m..Boundsscip-go gomod github.com/golang/go/src go1.24.0 image/RGBA#Bounds().()
43 return b.Dxscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Dx().(), b.Dyscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Dy().()
44 }
45
46 func (t *texturescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#) Downloadscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#Download().(r imagescip-go gomod github.com/golang/go/src go1.24.0 image/.Rectanglescip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#, dst drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/.Imagescip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/Image#) {
47 drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/.Drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/Draw().(dst, r, t.mscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#m., t.mscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#m..Boundsscip-go gomod github.com/golang/go/src go1.24.0 image/RGBA#Bounds().().Minscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Min., drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/.Srcscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/Src.)
48 }
49
50 func (t *texturescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#) Uploadscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#Upload().(r imagescip-go gomod github.com/golang/go/src go1.24.0 image/.Rectanglescip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#, src imagescip-go gomod github.com/golang/go/src go1.24.0 image/.Imagescip-go gomod github.com/golang/go/src go1.24.0 image/Image#) {
51 drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/.Drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/Draw().(t.mscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#m., r, src, src.Boundsscip-go gomod github.com/golang/go/src go1.24.0 image/Image#Bounds().().Minscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Min., drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/.Srcscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/Src.)
52 }
53
54 func (t *texturescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#) Releasescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#Release().() {}
55
56 type enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine# struct {
57 dstscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#dst. *imagescip-go gomod github.com/golang/go/src go1.24.0 image/.RGBAscip-go gomod github.com/golang/go/src go1.24.0 image/RGBA#
58 nodesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#nodes. []*nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/node#
59 absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms. []f32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/.Affinescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#
60 }
61
62 func (e *enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#) Registerscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#Register().(n *spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/.Nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#) {
63 if n.EngineFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#EngineFields..Indexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#$anon_d2259bd86e77f8aa#Index. != 0 {
64 panic("portable: sprite.Node already registered")
65 }
66
67 o := &nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/node#{}
68 o.relTransformscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/node#relTransform..Identityscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#Identity().()
69
70 e.nodesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#nodes. = append(e.nodesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#nodes., o)
71 n.EngineFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#EngineFields..Indexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#$anon_d2259bd86e77f8aa#Index. = int32(len(e.nodesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#nodes.) - 1)
72 }
73
74 func (e *enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#) Unregisterscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#Unregister().(n *spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/.Nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#) {
75 panic("todo")
76 }
77
78 func (e *enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#) LoadTexturescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#LoadTexture().(m imagescip-go gomod github.com/golang/go/src go1.24.0 image/.Imagescip-go gomod github.com/golang/go/src go1.24.0 image/Image#) (spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/.Texturescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Texture#, error) {
79 b := m.Boundsscip-go gomod github.com/golang/go/src go1.24.0 image/Image#Bounds().()
80 w, h := b.Dxscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Dx().(), b.Dyscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Dy().()
81
82 t := &texturescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#{mscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#m.: imagescip-go gomod github.com/golang/go/src go1.24.0 image/.NewRGBAscip-go gomod github.com/golang/go/src go1.24.0 image/NewRGBA().(imagescip-go gomod github.com/golang/go/src go1.24.0 image/.Rectscip-go gomod github.com/golang/go/src go1.24.0 image/Rect().(0, 0, w, h))}
83 t.Uploadscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#Upload().(b, m)
84 return t, nil
85 }
86
87 func (e *enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#) SetSubTexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#SetSubTex().(n *spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/.Nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#, x spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/.SubTexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/SubTex#) {
88 n.EngineFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#EngineFields..Dirtyscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#$anon_d2259bd86e77f8aa#Dirty. = true // TODO: do we need to propagate dirtiness up/down the tree?
89 n.EngineFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#EngineFields..SubTexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#$anon_d2259bd86e77f8aa#SubTex. = x
90 }
91
92 func (e *enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#) SetTransformscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#SetTransform().(n *spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/.Nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#, m f32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/.Affinescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#) {
93 n.EngineFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#EngineFields..Dirtyscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#$anon_d2259bd86e77f8aa#Dirty. = true // TODO: do we need to propagate dirtiness up/down the tree?
94 e.nodesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#nodes.[n.EngineFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#EngineFields..Indexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#$anon_d2259bd86e77f8aa#Index.].relTransformscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/node#relTransform. = m
95 }
96
97 func (e *enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#) Renderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#Render().(scene *spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/.Nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#, t clockscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/clock`/.Timescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/clock`/Time#, sz sizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/.Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event#) {
98 // Affine transforms are done in geom.Pt. When finally drawing
99 // the geom.Pt onto an image.Image we need to convert to system
100 // pixels. We scale by sz.PixelsPerPt to do this.
101 e.absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms. = append(e.absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms.[:0], f32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/.Affinescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#{
102 {sz.PixelsPerPtscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event#PixelsPerPt., 0, 0},
103 {0, sz.PixelsPerPtscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event#PixelsPerPt., 0},
104 })
105 e.renderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#render().(scene, t)
106 }
107
108 func (e *enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#) renderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#render().(n *spritescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/.Nodescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#, t clockscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/clock`/.Timescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/clock`/Time#) {
109 if n.EngineFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#EngineFields..Indexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#$anon_d2259bd86e77f8aa#Index. == 0 {
110 panic("portable: sprite.Node not registered")
111 }
112 if n.Arrangerscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#Arranger. != nil {
113 n.Arrangerscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#Arranger..Arrangescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Arranger#Arrange.(e, n, t)
114 }
115
116 // Push absTransforms.
117 // TODO: cache absolute transforms and use EngineFields.Dirty?
118 rel := &e.nodesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#nodes.[n.EngineFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#EngineFields..Indexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#$anon_d2259bd86e77f8aa#Index.].relTransformscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/node#relTransform.
119 m := f32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/.Affinescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#{}
120 m.Mulscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#Mul().(&e.absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms.[len(e.absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms.)-1], rel)
121 e.absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms. = append(e.absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms., m)
122
123 if x := n.EngineFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#EngineFields..SubTexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#$anon_d2259bd86e77f8aa#SubTex.; x.Tscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/SubTex#T. != nil {
124 // Affine transforms work in geom.Pt, which is entirely
125 // independent of the number of pixels in a texture. A texture
126 // of any image.Rectangle bounds rendered with
127 //
128 // Affine{{1, 0, 0}, {0, 1, 0}}
129 //
130 // should have the dimensions (1pt, 1pt). To do this we divide
131 // by the pixel width and height, reducing the texture to
132 // (1px, 1px) of the destination image. Multiplying by
133 // sz.PixelsPerPt, done in Render above, makes it (1pt, 1pt).
134 dx, dy := x.Rscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/SubTex#R..Dxscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Dx().(), x.Rscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/SubTex#R..Dyscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Dy().()
135 if dx > 0 && dy > 0 {
136 m.Scalescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#Scale().(&m, 1/float32(dx), 1/float32(dy))
137 // TODO(nigeltao): delete the double-inverse: one here and one
138 // inside func affine.
139 m.Inversescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#Inverse().(&m) // See the documentation on the affine function.
140 affinescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/affine().(e.dstscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#dst., x.Tscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/SubTex#T..(*texturescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#).mscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/texture#m., x.Rscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/SubTex#R., nil, &m, drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/.Overscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/Over.)
141 }
142 }
143
144 for c := n.FirstChildscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#FirstChild.; c != nil; c = c.NextSiblingscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite`/Node#NextSibling. {
145 e.renderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#render().(c, t)
146 }
147
148 // Pop absTransforms.
149 e.absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms. = e.absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms.[:len(e.absTransformsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#absTransforms.)-1]
150 }
151
152 func (e *enginescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#) Releasescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/engine#Release().() {}
153
154 // affine draws each pixel of dst using bilinear interpolation of the
155 // affine-transformed position in src. This is equivalent to:
156 //
157 // for each (x,y) in dst:
158 // dst(x,y) = bilinear interpolation of src(a*(x,y))
159 //
160 // While this is the simpler implementation, it can be counter-
161 // intuitive as an affine transformation is usually described in terms
162 // of the source, not the destination. For example, a scale transform
163 //
164 // Affine{{2, 0, 0}, {0, 2, 0}}
165 //
166 // will produce a dst that is half the size of src. To perform a
167 // traditional affine transform, use the inverse of the affine matrix.
168 func affinescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/sprite/portable`/affine().(dst *imagescip-go gomod github.com/golang/go/src go1.24.0 image/.RGBAscip-go gomod github.com/golang/go/src go1.24.0 image/RGBA#, src imagescip-go gomod github.com/golang/go/src go1.24.0 image/.Imagescip-go gomod github.com/golang/go/src go1.24.0 image/Image#, srcb imagescip-go gomod github.com/golang/go/src go1.24.0 image/.Rectanglescip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#, mask imagescip-go gomod github.com/golang/go/src go1.24.0 image/.Imagescip-go gomod github.com/golang/go/src go1.24.0 image/Image#, a *f32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/.Affinescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#, op drawscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/.Opscip-go gomod github.com/golang/go/src go1.24.0 `image/draw`/Op#) {
169 // For legacy compatibility reasons, the matrix a transforms from dst-space
170 // to src-space. The golang.org/x/image/draw package's matrices transform
171 // from src-space to dst-space, so we invert (and adjust for different
172 // origins).
173 i := *a
174 i[0][2] += float32(srcb.Minscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Min..Xscip-go gomod github.com/golang/go/src go1.24.0 image/Point#X.)
175 i[1][2] += float32(srcb.Minscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Min..Yscip-go gomod github.com/golang/go/src go1.24.0 image/Point#Y.)
176 i.Inversescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Affine#Inverse().(&i)
177 i[0][2] += float32(dst.Rectscip-go gomod github.com/golang/go/src go1.24.0 image/RGBA#Rect..Minscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Min..Xscip-go gomod github.com/golang/go/src go1.24.0 image/Point#X.)
178 i[1][2] += float32(dst.Rectscip-go gomod github.com/golang/go/src go1.24.0 image/RGBA#Rect..Minscip-go gomod github.com/golang/go/src go1.24.0 image/Rectangle#Min..Yscip-go gomod github.com/golang/go/src go1.24.0 image/Point#Y.)
179 m := f64scip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/math/f64`/.Aff3scip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/math/f64`/Aff3#{
180 float64(i[0][0]),
181 float64(i[0][1]),
182 float64(i[0][2]),
183 float64(i[1][0]),
184 float64(i[1][1]),
185 float64(i[1][2]),
186 }
187 // TODO(nigeltao): is the caller or callee responsible for detecting
188 // transforms that are simple copies or scales, for which there are faster
189 // implementations in the xdraw package.
190 xdrawscip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/draw`/.ApproxBiLinearscip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/draw`/ApproxBiLinear..Transformscip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/draw`/Transformer#Transform().(dst, m, src, srcb, op, &xdrawscip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/draw`/.Optionsscip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/draw`/Options#{
191 SrcMaskscip-go gomod golang.org/x/image v0.35.0 `golang.org/x/image/draw`/Options#SrcMask.: mask,
192 })
193 }