forked from sarah/microworlds
Fixing up scaling
This commit is contained in:
parent
6f714b5545
commit
c0a11bc2da
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/veandco/go-sdl2/sdl"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
//"strconv"
|
||||
)
|
||||
|
||||
type Graphics struct {
|
||||
|
@ -55,7 +55,9 @@ func (g *Graphics) Render(env *core.Environment, turtles []*core.Turtle) {
|
|||
amount := math.Min(float64(env.Sniff(name, x, y)), 255)
|
||||
|
||||
if amount > 0 {
|
||||
g.renderer.SetDrawColor(color[0]*uint8(amount), color[1]*uint8(amount), color[2]*uint8(amount), uint8(255))
|
||||
// TODO explictly define this scale
|
||||
scaledamount := uint8(float64(color[0]) * (amount/2))
|
||||
g.renderer.SetDrawColor(scaledamount,0,scaledamount, uint8(0xF0))
|
||||
g.renderer.DrawPoint(int32(x), int32(y))
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +83,7 @@ func (g *Graphics) Render(env *core.Environment, turtles []*core.Turtle) {
|
|||
|
||||
g.renderer.Present()
|
||||
g.window.UpdateSurface()
|
||||
surface, _ := g.window.GetSurface()
|
||||
surface.SaveBMP("./images/" + strconv.Itoa(g.t) + ".bmp")
|
||||
// surface, _ := g.window.GetSurface()
|
||||
// surface.SaveBMP("./images/" + strconv.Itoa(g.t) + ".bmp")
|
||||
g.t++
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue