MCPcopy Create free account
hub / github.com/boombuler/barcode / SetValues

Method SetValues

datamatrix/codelayout.go:106–163  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

104}
105
106func (l *codeLayout) SetValues(data []byte) {
107 idx := 0
108 row := 4
109 col := 0
110
111 for (row < l.size.MatrixRows()) || (col < l.size.MatrixColumns()) {
112 if (row == l.size.MatrixRows()) && (col == 0) {
113 l.Corner1(data[idx])
114 idx++
115 }
116 if (row == l.size.MatrixRows()-2) && (col == 0) && (l.size.MatrixColumns()%4 != 0) {
117 l.Corner2(data[idx])
118 idx++
119 }
120 if (row == l.size.MatrixRows()-2) && (col == 0) && (l.size.MatrixColumns()%8 == 4) {
121 l.Corner3(data[idx])
122 idx++
123 }
124
125 if (row == l.size.MatrixRows()+4) && (col == 2) && (l.size.MatrixColumns()%8 == 0) {
126 l.Corner4(data[idx])
127 idx++
128 }
129
130 for true {
131 if (row < l.size.MatrixRows()) && (col >= 0) && !l.Occupied(row, col) {
132 l.SetSimple(row, col, data[idx])
133 idx++
134 }
135 row -= 2
136 col += 2
137 if (row < 0) || (col >= l.size.MatrixColumns()) {
138 break
139 }
140 }
141 row += 1
142 col += 3
143
144 for true {
145 if (row >= 0) && (col < l.size.MatrixColumns()) && !l.Occupied(row, col) {
146 l.SetSimple(row, col, data[idx])
147 idx++
148 }
149 row += 2
150 col -= 2
151 if (row >= l.size.MatrixRows()) || (col < 0) {
152 break
153 }
154 }
155 row += 3
156 col += 1
157 }
158
159 if !l.Occupied(l.size.MatrixRows()-1, l.size.MatrixColumns()-1) {
160 l.Set(l.size.MatrixRows()-1, l.size.MatrixColumns()-1, 255, 0)
161 l.Set(l.size.MatrixRows()-2, l.size.MatrixColumns()-2, 255, 0)
162 }
163}

Callers 1

renderFunction · 0.80

Calls 9

Corner1Method · 0.95
Corner2Method · 0.95
Corner3Method · 0.95
Corner4Method · 0.95
OccupiedMethod · 0.95
SetSimpleMethod · 0.95
SetMethod · 0.95
MatrixRowsMethod · 0.80
MatrixColumnsMethod · 0.80

Tested by

no test coverage detected