Skip to content

Commit

Permalink
styl(draw): correct h expression
Browse files Browse the repository at this point in the history
  • Loading branch information
yeqown committed Nov 4, 2021
1 parent 0cbd44a commit bc30022
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ func draw(mat matrix.Matrix, opt *outputImageOptions) image.Image {
top, right, bottom, left := opt.borderWidths[0], opt.borderWidths[1], opt.borderWidths[2], opt.borderWidths[3]
// w as image width, h as image height
w := mat.Width()*opt.qrBlockWidth() + left + right
h := mat.Width()*opt.qrBlockWidth() + top + bottom
// rgba := image.NewRGBA(image.Rect(0, 0, w, h))
h := mat.Height()*opt.qrBlockWidth() + top + bottom
dc := gg.NewContext(w, h)

// draw background
Expand Down
6 changes: 3 additions & 3 deletions image_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ func (oo *outputImageOptions) getShape() IShape {
}

// preCalculateAttribute this function must reference to draw function.
func (oo *outputImageOptions) preCalculateAttribute(w int) *Attribute {
func (oo *outputImageOptions) preCalculateAttribute(dimension int) *Attribute {
if oo == nil {
return nil
}

top, right, bottom, left := oo.borderWidths[0], oo.borderWidths[1], oo.borderWidths[2], oo.borderWidths[3]
return &Attribute{
W: w*oo.qrBlockWidth() + right + left,
H: w*oo.qrBlockWidth() + top + bottom,
W: dimension*oo.qrBlockWidth() + right + left,
H: dimension*oo.qrBlockWidth() + top + bottom,
Borders: oo.borderWidths,
BlockWidth: oo.qrBlockWidth(),
}
Expand Down

0 comments on commit bc30022

Please sign in to comment.