Completed
Branch refactoring (26a65f)
by Johan
01:23
created

src/renderers/shared.js   A

Complexity

Total Complexity 9
Complexity/F 4.5

Size

Lines of Code 24
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 24
rs 10
wmc 9
mnd 4
bc 6
fnc 2
bpm 3
cpm 4.5
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
B shared.js ➔ getBarcodePadding 0 14 6
A shared.js ➔ getEncodingHeight 0 7 3
1
export {getEncodingHeight, getBarcodePadding};
2
3
function getEncodingHeight(encoding, options){
4
	return options.height +
5
		((options.displayValue && encoding.text.length > 0) ? options.fontSize : 0) +
6
		options.textMargin +
7
		options.marginTop +
8
		options.marginBottom;
9
}
10
11
function getBarcodePadding(textWidth, barcodeWidth, options){
12
	if(options.displayValue && barcodeWidth < textWidth){
13
		if(options.textAlign == "center"){
14
			return Math.floor((textWidth - barcodeWidth) / 2);
15
		}
16
		else if(options.textAlign == "left"){
17
			return 0;
18
		}
19
		else if(options.textAlign == "right"){
20
			return Math.floor(textWidth - barcodeWidth);
21
		}
22
	}
23
	return 0;
24
}
25