Ox.divideInt -> Ox.splitInt
This commit is contained in:
parent
703003bd2b
commit
f5782c475b
5 changed files with 22 additions and 23 deletions
|
@ -49,7 +49,7 @@ Ox.CheckboxGroup = function(options, self) {
|
|||
|
||||
self.$checkboxes = [];
|
||||
if (self.options.type == 'group') {
|
||||
self.checkboxWidth = Ox.divideInt(
|
||||
self.checkboxWidth = Ox.splitInt(
|
||||
self.options.width + (self.options.checkboxes.length - 1) * 6,
|
||||
self.options.checkboxes.length
|
||||
).map(function(v, i) {
|
||||
|
|
|
@ -128,7 +128,7 @@ Ox.InputGroup = function(options, self) {
|
|||
|
||||
function setWidths() {
|
||||
var length = self.options.inputs.length,
|
||||
inputWidths = Ox.divideInt(
|
||||
inputWidths = Ox.splitInt(
|
||||
self.options.width - Ox.sum(self.options.separators.map(function(v) {
|
||||
return v.width;
|
||||
})), length
|
||||
|
|
|
@ -218,7 +218,7 @@ Ox.Range = function(options, self) {
|
|||
self.thumbSize = Math.max(self.trackSize / self.values, self.options.thumbSize);
|
||||
self.trackImageWidths = self.trackImages == 1
|
||||
? [self.trackSize - 16]
|
||||
: Ox.divideInt(self.trackSize - 2, self.trackImages);
|
||||
: Ox.splitInt(self.trackSize - 2, self.trackImages);
|
||||
self.trackColorStart = self.options.trackGradient
|
||||
? self.thumbSize / 2 / self.options.size : 0;
|
||||
self.trackColorStep = self.options.trackGradient
|
||||
|
|
|
@ -1019,7 +1019,7 @@ Ox.VideoEditor = function(options, self) {
|
|||
}
|
||||
if (self.options.videoSize == 'small') {
|
||||
width = 0;
|
||||
widths = Ox.divideInt(contentWidth - 4 * self.margin, 3);
|
||||
widths = Ox.splitInt(contentWidth - 4 * self.margin, 3);
|
||||
[1, 0, 2].forEach(function(v, i) {
|
||||
size.player[v] = {
|
||||
left: (i + 0.5) * self.margin + width,
|
||||
|
|
|
@ -50,25 +50,6 @@ Ox.deg = function(rad) {
|
|||
return rad * 180 / Math.PI;
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.divideInt <f> Divides a number by another and returns an array of integers
|
||||
`Ox.divideInt(num, by)` returns a sorted array of integers that has a sum of
|
||||
`num`, a length of `by`, a minimum of `Math.floor(num / by)` and a maximum
|
||||
of `Math.ceil(num / by)`.
|
||||
> Ox.divideInt(100, 3)
|
||||
[33, 33, 34]
|
||||
> Ox.divideInt(100, 6)
|
||||
[16, 16, 17, 17, 17, 17]
|
||||
@*/
|
||||
// fixme: is splitInt a better name?
|
||||
Ox.divideInt = function(number, by) {
|
||||
var div = Math.floor(number / by),
|
||||
mod = number % by;
|
||||
return Ox.range(by).map(function(i) {
|
||||
return div + (i > by - 1 - mod);
|
||||
});
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.hypot <f> Returns the square root of the sum of the squares of its arguments
|
||||
(x, y[, z]) -> <n> Square root of the sum of the squares of its arguments
|
||||
|
@ -202,6 +183,24 @@ Ox.sinh = function(x) {
|
|||
return (Math.exp(x) - Math.exp(-x)) / 2;
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.splitInt <f> Splits an integer into an array of integers
|
||||
`Ox.splitInt(num, by)` returns a sorted array of integers that has a sum of
|
||||
`num`, a length of `by`, a minimum of `Math.floor(num / by)` and a maximum
|
||||
of `Math.ceil(num / by)`.
|
||||
> Ox.splitInt(100, 3)
|
||||
[33, 33, 34]
|
||||
> Ox.splitInt(100, 6)
|
||||
[16, 16, 17, 17, 17, 17]
|
||||
@*/
|
||||
Ox.splitInt = function(number, by) {
|
||||
var div = Math.floor(number / by),
|
||||
mod = number % by;
|
||||
return Ox.range(by).map(function(i) {
|
||||
return div + (i > by - 1 - mod);
|
||||
});
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.tanh <f> Hyperbolic tangent
|
||||
Missing from `Math`.
|
||||
|
|
Loading…
Reference in a new issue