~mendelmaleh/dummy

7f35660a0f51e5934969a12bbf3fb697168ef9e3 — Mendel E 1 year, 6 months ago 72c6f59
Make naming more consistent
2 files changed, 8 insertions(+), 8 deletions(-)

M image.go
M main.go
M image.go => image.go +6 -6
@@ 10,26 10,26 @@ type img struct {
}

func Image(opt Options) image.Image {
	m := img{image.NewRGBA(image.Rectangle{image.Point{}, image.Point{opt.Width, opt.Height}})}
	im := img{image.NewRGBA(image.Rectangle{image.Point{}, image.Point{opt.Width, opt.Height}})}

	switch opt.Pattern {
	case "diagonal":
		var c [2]color.RGBA
		copy(c[:], opt.Colors)
		m.drawDiagonal(opt.Width, opt.Height, c)
		im.drawDiagonal(opt.Width, opt.Height, c)
	}

	return m
	return im
}

func (m *img) drawDiagonal(w, h int, c [2]color.RGBA) {
func (im *img) drawDiagonal(w, h int, c [2]color.RGBA) {
	for x := 0; x < w; x++ {
		for y := 0; y < h; y++ {
			// if y < h/w)*x) {
			if y <= h-x {
				m.Set(x, y, c[0])
				im.Set(x, y, c[0])
			} else {
				m.Set(x, y, c[1])
				im.Set(x, y, c[1])
			}
		}
	}

M main.go => main.go +2 -2
@@ 75,8 75,8 @@ func Dummy(w http.ResponseWriter, r *http.Request, opt Options) {
	// apply limits and hacks
	opt.Normalize()

	img := Image(opt)
	png.Encode(w, img)
	im := Image(opt)
	png.Encode(w, im)

	// fmt.Fprintf(w, "%+v\n", dopt)
}