Skip to content

Instantly share code, notes, and snippets.

@tejas77
Created June 16, 2020 06:28
Show Gist options
  • Save tejas77/28e90b743f60387f228bafd3ffb6b172 to your computer and use it in GitHub Desktop.
Save tejas77/28e90b743f60387f228bafd3ffb6b172 to your computer and use it in GitHub Desktop.
Cylinder Element of Tower Application
const { height, width } = Dimensions.get("window");
const centerX = width / 2,
centerY = height / 2;
// ....
let { beta, gamma } = data;
gamma = round(gamma);
beta = round(beta);
const cylinderElement = (
<>
<Line
x1={centerX}
y1={centerY}
x2={centerX - (gamma * width) / 3.14}
y2={centerY - (beta * height) / 3.14}
stroke="lightgray"
strokeWidth="60"
/>
<Circle cx={centerX} cy={centerY} r="30" fill="lightgray" />
{beta >= 0 && (
<Line
x1={centerX}
y1={centerY + 30}
x2={centerX - (gamma * width) / 3.14}
y2={centerY + 30 - (beta * height) / 3.14}
stroke="gray"
strokeWidth="1"
/>
)}
<Circle
cx={centerX - (gamma * width) / 3.14}
cy={centerY - (beta * height) / 3.14}
r="30"
fill="gray"
/>
</>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment