func Encode(text string, level Level) (*Code, error) {
	var enc coding.Encoding
	switch {
	case coding.Num(text).Check() == nil:
		enc = coding.Num(text)
	case coding.Alpha(text).Check() == nil:
		enc = coding.Alpha(text)
	default:
		enc = coding.String(text)
	}
	l := coding.Level(level)
	var v coding.Version
	for v = coding.MinVersion; ; v++ {
		if v > coding.MaxVersion {
			return nil, errors.New("text too long to encode as QR")
		}
		if enc.Bits(v) <= v.DataBytes(l)*8 {
			break
		}
	}
	p, err := coding.NewPlan(v, l, 0)
	if err != nil {
		return nil, err
	}
	cc, err := p.Encode(enc)
	if err != nil {
		return nil, err
	}
	return &Code{cc.Bitmap, cc.Size, cc.Stride, 8}, nil
}
Encode returns an encoding of text at the given error correction level.
package qr  
import (
	"errors"
	"image"
	"image/color"
	"rsc.io/qr/coding"
)
type Level int
const (
	L Level = iota  
	M               
	Q               
	H               
)