Working on stacked buttons.
This commit is contained in:
+16
-49
@@ -1,4 +1,4 @@
|
||||
/* globals WebKitPoint */
|
||||
/* globals */
|
||||
|
||||
/** Tests whether an object is empty
|
||||
* @param {Object} obj - the object to be tested
|
||||
@@ -60,11 +60,9 @@ export function sample(population, k) {
|
||||
set and it doesn't suffer from frequent reselections.
|
||||
*/
|
||||
|
||||
if (!Array.isArray(population))
|
||||
throw new TypeError('Population must be an array.')
|
||||
if (!Array.isArray(population)) throw new TypeError('Population must be an array.')
|
||||
let n = population.length
|
||||
if (k < 0 || k > n)
|
||||
throw new RangeError('Sample larger than population or is negative')
|
||||
if (k < 0 || k > n) throw new RangeError('Sample larger than population or is negative')
|
||||
|
||||
let result = new Array(k)
|
||||
let setsize = 21 // size of a small set minus size of an empty list
|
||||
@@ -143,9 +141,7 @@ export class Dates {
|
||||
}
|
||||
|
||||
static startYearRange(date) {
|
||||
return new Date(
|
||||
Date.UTC(date.getFullYear() - 1, 11, 31, 23, 59, 59, 999)
|
||||
)
|
||||
return new Date(Date.UTC(date.getFullYear() - 1, 11, 31, 23, 59, 59, 999))
|
||||
}
|
||||
|
||||
static endYearRange(date) {
|
||||
@@ -165,11 +161,7 @@ export class Dates {
|
||||
}
|
||||
|
||||
static nextDay(date) {
|
||||
return this.create(
|
||||
date.getFullYear(),
|
||||
date.getMonth(),
|
||||
date.getDate() + 1
|
||||
)
|
||||
return this.create(date.getFullYear(), date.getMonth(), date.getDate() + 1)
|
||||
}
|
||||
|
||||
static nextHour(date) {
|
||||
@@ -672,15 +664,9 @@ export class Polygon {
|
||||
*/
|
||||
draw(context, { lineWidth = 2, stroke = '#000000', fill = null } = {}) {
|
||||
context.beginPath()
|
||||
context.moveTo(
|
||||
this.points[0].x + this.center.x,
|
||||
this.points[0].y + this.center.y
|
||||
)
|
||||
context.moveTo(this.points[0].x + this.center.x, this.points[0].y + this.center.y)
|
||||
for (let i = 1; i < this.points.length; i++) {
|
||||
context.lineTo(
|
||||
this.points[i].x + this.center.x,
|
||||
this.points[i].y + this.center.y
|
||||
)
|
||||
context.lineTo(this.points[i].x + this.center.x, this.points[i].y + this.center.y)
|
||||
}
|
||||
context.closePath()
|
||||
context.lineWidth = lineWidth
|
||||
@@ -737,10 +723,7 @@ export class Polygon {
|
||||
for (i = 0, j = nvert - 1; i < nvert; j = i++) {
|
||||
if (
|
||||
verty[i] > testy != verty[j] > testy &&
|
||||
testx <
|
||||
((vertx[j] - vertx[i]) * (testy - verty[i])) /
|
||||
(verty[j] - verty[i]) +
|
||||
vertx[i]
|
||||
testx < ((vertx[j] - vertx[i]) * (testy - verty[i])) / (verty[j] - verty[i]) + vertx[i]
|
||||
)
|
||||
c = !c
|
||||
}
|
||||
@@ -774,12 +757,8 @@ export class Polygon {
|
||||
for (side = 0; side < this.getNumberOfSides(); side++) {
|
||||
/* get the axis that we will project onto */
|
||||
if (side == 0) {
|
||||
axis.x =
|
||||
this.points[this.getNumberOfSides() - 1].y -
|
||||
this.points[0].y
|
||||
axis.y =
|
||||
this.points[0].x -
|
||||
this.points[this.getNumberOfSides() - 1].x
|
||||
axis.x = this.points[this.getNumberOfSides() - 1].y - this.points[0].y
|
||||
axis.y = this.points[0].x - this.points[this.getNumberOfSides() - 1].x
|
||||
} else {
|
||||
axis.x = this.points[side - 1].y - this.points[side].y
|
||||
axis.y = this.points[side].x - this.points[side - 1].x
|
||||
@@ -803,8 +782,7 @@ export class Polygon {
|
||||
maxA += tmp
|
||||
|
||||
/* project polygon B onto axis to determine the min/max */
|
||||
minB = maxB =
|
||||
other.points[0].x * axis.x + other.points[0].y * axis.y
|
||||
minB = maxB = other.points[0].x * axis.x + other.points[0].y * axis.y
|
||||
for (i = 1; i < other.getNumberOfSides(); i++) {
|
||||
tmp = other.points[i].x * axis.x + other.points[i].y * axis.y
|
||||
if (tmp > maxB) maxB = tmp
|
||||
@@ -831,12 +809,8 @@ export class Polygon {
|
||||
for (side = 0; side < other.getNumberOfSides(); side++) {
|
||||
/* get the axis that we will project onto */
|
||||
if (side == 0) {
|
||||
axis.x =
|
||||
other.points[other.getNumberOfSides() - 1].y -
|
||||
other.points[0].y
|
||||
axis.y =
|
||||
other.points[0].x -
|
||||
other.points[other.getNumberOfSides() - 1].x
|
||||
axis.x = other.points[other.getNumberOfSides() - 1].y - other.points[0].y
|
||||
axis.y = other.points[0].x - other.points[other.getNumberOfSides() - 1].x
|
||||
} else {
|
||||
axis.x = other.points[side - 1].y - other.points[side].y
|
||||
axis.y = other.points[side].x - other.points[side - 1].x
|
||||
@@ -860,8 +834,7 @@ export class Polygon {
|
||||
maxA += tmp
|
||||
|
||||
/* project polygon B onto axis to determine the min/max */
|
||||
minB = maxB =
|
||||
other.points[0].x * axis.x + other.points[0].y * axis.y
|
||||
minB = maxB = other.points[0].x * axis.x + other.points[0].y * axis.y
|
||||
for (i = 1; i < other.getNumberOfSides(); i++) {
|
||||
tmp = other.points[i].x * axis.x + other.points[i].y * axis.y
|
||||
if (tmp > maxB) maxB = tmp
|
||||
@@ -918,12 +891,7 @@ export class Rect {
|
||||
* @memberof Rect
|
||||
*/
|
||||
static contains(rect, point) {
|
||||
return (
|
||||
point.x > rect.left &&
|
||||
point.x < rect.x + rect.right &&
|
||||
point.y > rect.top &&
|
||||
point.y < rect.bottom
|
||||
)
|
||||
return point.x > rect.left && point.x < rect.x + rect.right && point.y > rect.top && point.y < rect.bottom
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1003,8 +971,7 @@ export class LowPassFilter {
|
||||
* @access private
|
||||
*/
|
||||
__push(value) {
|
||||
let removed =
|
||||
this.buffer.length === this.bufferMaxSize ? this.buffer.shift() : 0
|
||||
let removed = this.buffer.length === this.bufferMaxSize ? this.buffer.shift() : 0
|
||||
|
||||
this.buffer.push(value)
|
||||
return removed
|
||||
|
||||
Reference in New Issue
Block a user