spacing between bars in a barcode

2

I have the code below that generates a copy of bars from an inserted number, but I think the bars are very close, is there a way to leave them with a greater spacing between them?

below the code:

const digitos : array['0'..'9'] of string[5]= ('00110', '10001', '01001', '11000', '00101', '10100', '01100', '00011', '10010', '01010');
 var s : string; i, j, x, t : Integer;
  begin // Gerar o valor para desenhar o código de barras //
   s := '0000';
   for i := 1 to length(codigo)div 2 do
   for j := 1 to 5 do s := s + Copy(Digitos[codigo[i * 2 - 1]], j, 1) + Copy(Digitos[codigo[i * 2]], j, 1);
   s := s + '100';
    x := 0;
   Canvas.Brush.Color := clWhite;
    Canvas.Pen.Color := clWhite;
    Canvas.Rectangle(0,0, 2000, 79);
    Canvas.Brush.Color := clBlack;
     Canvas.Pen.Color := clBlack;
     for i := 1 to length(s) do
      begin
      t := strToInt(s[i]) * 3 + 1;
      if i mod 2 = 1 then
      Canvas.Rectangle(x, 0, x + t, 67);
      x := x + t;
      end;
      end;
    
asked by anonymous 16.12.2015 / 11:46

1 answer

1

Change as shown. And create a variable thickness and value it and see if it gets the way you need it.

const digitos : array['0'..'9'] of string[5]= ('00110', '10001', '01001',  
'11000', '00101', '10100', '01100', '00011', '10010', '01010');  
var s : string; i, j, x, t : Integer;  
begin // Gerar o valor para desenhar o código de barras //  
s := '0000';  
for i := 1 to length(codigo)div 2 do   
for j := 1 to 5 do s := s + Copy(Digitos[codigo[i * 2 - 1]], j, 1) + 
Copy(Digitos[codigo[i * 2]], j, 1);
s := s + '100';
x := 0;
Canvas.Brush.Color := clWhite;
Canvas.Pen.Color := clWhite;
Canvas.Rectangle(0,0, 2000, 79);
Canvas.Brush.Color := clBlack;
Canvas.Pen.Color := clBlack;
for i := 1 to length(s) do
begin
  

t: = strToInt (s [i]) * 3 + 1; change to "t: = strToInt (s [i]) * 2 + thickness;"

if i mod 2 = 1 then
Canvas.Rectangle(x, 0, x + t, 67);
x := x + t;
end;
end;
    
16.12.2015 / 12:13