1
Programming / Re: How do I get user_input for phone?
« on: April 01, 2017, 06:16:26 AM »
Maybe try RubyMotion. An example text field: http://hashnuke.com/2012/07/16/rubymotion-button-text-field-and-alert.html
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
const xDir = [0, 1, 1, 0,-1,-1];
const yDir = [1, 0,-1,-1, 0, 1];
// displacement vector for moving tangent to a circle counterclockwise in a certain sector
const tangent = [
[ 0,-1],// \
[-1, 0],// -
[-1, 1],// /
[ 0, 1],// \
[ 1, 0],// -
[ 1,-1],// /
[ 0,-1],// \
];
// displacement vector for moving normal to a circle outward in a certain sector
const normal = [
[ 1, 0],// -
[ 1,-1],// /
[ 0,-1],// \
[-1, 0],// -
[-1, 1],// /
[ 0, 1],// \
[ 1, 0],// -
];
// round a number, but round down if it ends in .5
const roundTieDown = n => Math.ceil(n - 0.5);
const fov = (ox, oy, transparent, reveal) => {
reveal(ox, oy);
const revealWall = (x, y) => {
if (!transparent(x, y)) {
reveal(x, y);
}
};
for (let i = 0; i < 6; i++) {
revealWall(ox + normal[i][0], oy + normal[i][1]);
}
const polar2rect = (radius, angle) => {
const sector = Math.floor(angle);
const arc = roundTieDown((angle - sector) * (radius - 0.5));
return [
ox + radius * normal[sector][0] + arc * tangent[sector][0],
oy + radius * normal[sector][1] + arc * tangent[sector][1],
radius * sector + arc,
];
};
// angles are measured from 0 to 6
// radius - radius of arc
// start & end - angles for start and end of arc
const scan = (radius, start, end) => {
let someRevealed = false;
let [x, y, arc] = polar2rect(radius, start);
let current = start;
while (current < end) {
if (transparent(x, y)) {
current = arc / radius;
if (current >= start && current <= end) {
reveal(x, y);
someRevealed = true;
if (current >= 0 && current <= 2) { revealWall(x + 1, y - 1); }
if (current >= 1 && current <= 3) { revealWall(x , y - 1); }
if (current >= 2 && current <= 4) { revealWall(x - 1, y ); }
if (current >= 3 && current <= 5) { revealWall(x - 1, y + 1); }
if (current >= 4 && current <= 6) { revealWall(x , y + 1); }
if (current <= 1 || current >= 5) { revealWall(x + 1, y ); }
}
} else {
current = (arc + 0.5) / radius;
if (someRevealed) {
scan(radius + 1, start, (arc - 0.5) / radius);
}
start = current;
}
// increment everything
const displacement = tangent[Math.floor(arc / radius)];
x += displacement[0];
y += displacement[1];
arc++;
}
if (someRevealed) {
scan(radius + 1, start, end);
}
}
scan(1, 0, 6);
};