MCPcopy Create free account
hub / github.com/SolarLune/masterplan / CreateGridTexture

Method CreateGridTexture

project.go:135–180  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133}
134
135func (project *Project) CreateGridTexture() {
136
137 guiTex := globals.Resources.Get(LocalRelativePath("assets/gui.png")).AsImage()
138
139 // project.GridTexture = TileTexture(guiTex, &sdl.Rect{480, 0, 32, 32}, 512, 512)
140
141 srcRect := &sdl.FRect{480, 0, 32, 32}
142
143 if project.GridTexture == nil {
144
145 project.GridTexture = NewRenderTexture()
146
147 project.GridTexture.RenderFunc = func() {
148
149 project.GridTexture.Recreate(512, 512)
150
151 project.GridTexture.Image.Texture.SetScaleMode(sdl.SCALEMODE_NEAREST)
152
153 gridColor := getThemeColor(GUIGridColor).Mix(getThemeColor(GUIBGColor), 0.75)
154
155 guiTex.Texture.SetColorMod(gridColor.RGB())
156 guiTex.Texture.SetAlphaMod(gridColor[3])
157
158 project.GridTexture.Texture.SetBlendMode(sdl.BLENDMODE_BLEND)
159
160 SetRenderTarget(project.GridTexture.Texture)
161
162 dst := &sdl.FRect{0, 0, srcRect.W, srcRect.H}
163
164 for y := float32(0); y < project.GridTexture.Size.Y; y += srcRect.H {
165 for x := float32(0); x < project.GridTexture.Size.X; x += srcRect.W {
166 dst.X = x
167 dst.Y = y
168 globals.Renderer.RenderTexture(guiTex.Texture, srcRect, dst)
169 }
170 }
171
172 SetRenderTarget(nil)
173
174 }
175
176 }
177
178 project.GridTexture.RenderFunc()
179
180}
181
182func (project *Project) AutoBackup() {
183

Callers 2

NewProjectFunction · 0.95
refreshThemesFunction · 0.80

Calls 9

LocalRelativePathFunction · 0.85
NewRenderTextureFunction · 0.85
getThemeColorFunction · 0.85
SetRenderTargetFunction · 0.85
AsImageMethod · 0.80
MixMethod · 0.80
RGBMethod · 0.80
GetMethod · 0.45
RecreateMethod · 0.45

Tested by

no test coverage detected