holys / initials-avatar Goto Github PK
View Code? Open in Web Editor NEWInitials avatar for golang
Home Page: https://initials.herokuapp.com
License: MIT License
Initials avatar for golang
Home Page: https://initials.herokuapp.com
License: MIT License
@holys I am currently working on tests for the avatar package.
If anyone else is working on this maybe we should see what is the best approach. Meanwhile I try to take the path to the font file from the environment variables.
This is how my makefile looks like in the moment.
.PHONY: test
fontFile=$(CURDIR)/resource/fonts/Hiragino_Sans_GB_W3.ttf
all: install
test:
AVATAR_FONT=$(fontFile) go test -v ./avatar
install:
go install github.com/holys/initials-avatar/cmd/avatar
Note I had to rename the font file to remove spaces inorder to work in my linux machine.
And the avatar_test.go
file
package avatar
import (
"os"
"testing"
)
func TestInitialsAvatar_DrawToBytes(t *testing.T) {
fontFile := os.Getenv("AVATAR_FONT")
if fontFile == "" {
t.Skip("Font file is needed")
}
av := New(fontFile)
stuffs := []struct {
name string
size int
undersize bool
oversize bool
}{
{"Swordsmen", 22, true, false},
{"Condor Heroes", 30, false, false},
{"Condor Heroes", 30, false, false},
// {"Condor Heroes", 200, false, true},
}
for _, v := range stuffs {
_, err := av.DrawToBytes(v.name, v.size)
if err != nil {
t.Error(err)
}
}
}
Before I do something crazy, any imput will be appreciated. This is due to the fact that the local fuctions will also need tests, and will it we okay to have a test case like TestGetInitials
for testing local getInitials
function ?
Would be neat to have an api to retrieve the initials used to make the image, that way we can use it for other things.
Hey, kudos for the nice work. It will be great if the project was easy to install without the make instructions.
That can be easy if the name of the repository would have to change and remove the dash(-) character. I suggest you name it something like avatar
.
That way, gor people who wants to install the command it can just type
go get -v github.com/holys/avatar/cmd/avatar
And for those who want to install the library can just type
go get -v github.com/holys/avatar
That is ofcourse after moving the contents of github.com/holys/initials-avatar/avatar
to github.com/holys/avatar
inspired by invatar
TODO
@gernest http://gr2m.github.io/initials/ That's what I expect initials to be. If you are interested, you can help improving this feature. ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.