Unverified Commit e56b0363 authored by santiaago's avatar santiaago Committed by GitHub
Browse files

Merge pull request #103 from Trane9991/master

"draw" images into generic io.Writer
parents 64dff00f 30cd98bd
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -23,3 +23,6 @@ _testmain.go
*.test
*~
*.DS_Store

*_got
*_expected
 No newline at end of file
+2 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ package isogrids

import (
	"image/color"
	"net/http"
	"io"

	svg "github.com/ajstarks/svgo"
	"github.com/taironas/tinygraphs/colors"
@@ -11,8 +11,7 @@ import (

// RandomGradientColor builds a isogrid image with with x colors selected at random for each quadrant.
// the background color stays the same the other colors get mixed in a gradient color from the first one to the last one.
func RandomGradientColor(w http.ResponseWriter, colors, gColors []color.RGBA, gv colors.GradientVector, width, height, lines int, prob float64) {

func RandomGradientColor(w io.Writer, colors, gColors []color.RGBA, gv colors.GradientVector, width, height, lines int, prob float64) {
	var gradientColors []svg.Offcolor
	gradientColors = make([]svg.Offcolor, len(gColors))
	percentage := uint8(0)
+3 −3
Original line number Diff line number Diff line
@@ -2,14 +2,14 @@ package isogrids

import (
	"image/color"
	"net/http"
	"io"

	"github.com/ajstarks/svgo"
	svg "github.com/ajstarks/svgo"
	"github.com/taironas/tinygraphs/draw"
)

// Hexa builds an image with lines x lines grids of half diagonals in the form of an hexagon
func Hexa(w http.ResponseWriter, key string, colors []color.RGBA, size, lines int) {
func Hexa(w io.Writer, key string, colors []color.RGBA, size, lines int) {
	canvas := svg.New(w)
	canvas.Start(size, size)

+3 −3
Original line number Diff line number Diff line
@@ -3,16 +3,16 @@ package isogrids
import (
	"errors"
	"image/color"
	"net/http"
	"io"

	"github.com/ajstarks/svgo"
	svg "github.com/ajstarks/svgo"
	"github.com/taironas/tinygraphs/draw"
)

// Hexa16 builds an image with lines x lines grids of half diagonals in the form of an hexagon
// it draws 6 triangles, triangle 1 to 5 are all rotations of triangle 0.
// triangle zero triangle on the center left.
func Hexa16(w http.ResponseWriter, key string, colors []color.RGBA, size, lines int) {
func Hexa16(w io.Writer, key string, colors []color.RGBA, size, lines int) {
	canvas := svg.New(w)
	canvas.Start(size, size)

+3 −3
Original line number Diff line number Diff line
@@ -2,14 +2,14 @@ package isogrids

import (
	"image/color"
	"net/http"
	"io"

	"github.com/ajstarks/svgo"
	svg "github.com/ajstarks/svgo"
	"github.com/taironas/tinygraphs/draw"
)

// Isogrids builds an image with 10x10 grids of half diagonals
func Isogrids(w http.ResponseWriter, key string, colors []color.RGBA, size, lines int) {
func Isogrids(w io.Writer, key string, colors []color.RGBA, size, lines int) {
	canvas := svg.New(w)
	canvas.Start(size, size)

Loading