comparison samples/freetype.tp @ 333:577406b25f89

Added binding for SDL_SetTextureColorMod and SDL_GetTextureColorMod and updated the Freetype sample to use it for setting the color of text
author Michael Pavone <pavone@retrodev.com>
date Sun, 29 Mar 2015 09:43:24 -0700
parents e70f9d3f19f8
children
comparison
equal deleted inserted replaced
332:ead24192ed45 333:577406b25f89
184 x <- 0 184 x <- 0
185 while: { x < (curGlyph width) } do: { 185 while: { x < (curGlyph width) } do: {
186 //FIXME: This will probably only work on little endian machines 186 //FIXME: This will probably only work on little endian machines
187 bytearr set: dstIdx (pixels get: idx) 187 bytearr set: dstIdx (pixels get: idx)
188 dstIdx <- dstIdx + 1 188 dstIdx <- dstIdx + 1
189 bytearr set: dstIdx (color r) 189 bytearr set: dstIdx 255u8 //(color r)
190 dstIdx <- dstIdx + 1 190 dstIdx <- dstIdx + 1
191 bytearr set: dstIdx (color g) 191 bytearr set: dstIdx 255u8 (color g)
192 dstIdx <- dstIdx + 1 192 dstIdx <- dstIdx + 1
193 bytearr set: dstIdx (color b) 193 bytearr set: dstIdx 255u8 (color b)
194 dstIdx <- dstIdx + 1 194 dstIdx <- dstIdx + 1
195 195
196 idx <- idx + 1 196 idx <- idx + 1
197 x <- x + 1 197 x <- x + 1
198 } 198 }
225 x <- 0 225 x <- 0
226 while: { x < (curGlyph width) } do: { 226 while: { x < (curGlyph width) } do: {
227 //FIXME: This will probably only work on little endian machines 227 //FIXME: This will probably only work on little endian machines
228 bytearr set: dstIdx (pixels get: idx) 228 bytearr set: dstIdx (pixels get: idx)
229 dstIdx <- dstIdx + 1 229 dstIdx <- dstIdx + 1
230 bytearr set: dstIdx (color r) 230 bytearr set: dstIdx 255u8 //(color r)
231 dstIdx <- dstIdx + 1 231 dstIdx <- dstIdx + 1
232 bytearr set: dstIdx (color g) 232 bytearr set: dstIdx 255u8 (color g)
233 dstIdx <- dstIdx + 1 233 dstIdx <- dstIdx + 1
234 bytearr set: dstIdx (color b) 234 bytearr set: dstIdx 255u8 (color b)
235 dstIdx <- dstIdx + 1 235 dstIdx <- dstIdx + 1
236 236
237 idx <- idx + 1 237 idx <- idx + 1
238 x <- x + 1 238 x <- x + 1
239 } 239 }
258 } 258 }
259 glyphDict <- dict hash 259 glyphDict <- dict hash
260 foreach: glyphs :idx glyph { 260 foreach: glyphs :idx glyph {
261 glyphDict set: (glyph charCode) glyph 261 glyphDict set: (glyph charCode) glyph
262 } 262 }
263 drawTex colorMod!: color
263 _pixelFactor <- ((face unitsPerEm) f64) * 72.0 / (fontSize * (dpi f64)) 264 _pixelFactor <- ((face unitsPerEm) f64) * 72.0 / (fontSize * (dpi f64))
264 option value: #{ 265 option value: #{
265 texture <- drawTex 266 texture <- drawTex
266 width <- aWidth 267 width <- aWidth
267 height <- aHeight 268 height <- aHeight