A close friend of the Vexbot, the Polybot API sends you nothing but polygons. With every request, our Polybot will send you up to 1,000 polygons from 3 sides (a triangle) to 72 sides (a heptacontakaidigon!). Create dazzling patterns or use the random shapes to create the terrain of your next game.
A polygon—as you’ll recall from your ol’ geometry textbook—is a connected plane of n line segments, so if you send a request to:
api.noopschallenge.com/polybot
We’ll return a set of coordinates defining each vertex of the polygon:
{
"polygons": [
[
{"x":157,"y":998},
{"x":145,"y":1000},
{"x":122,"y":1000},
{"x":106,"y":989},
{"x":127,"y":969},
{"x":151,"y":972}
]
]
}
The API will return up to 1,000 polygons with a random number of sides between 3 to 72. You can specify the count
of polygons returns, minSides
and maxSides
, and the maximum size
you’d like your polygons to be. Or you can let the Polybot decide!
Here is a preview of the starter project.
When faced with an endless stream of polygons, what can you do?
First you could just draw one…
Nice! Then you could draw a whole bunch…
Neat. But what if you made them transparent, and overlapped them?
And what if we animated it?
What’s next is up to you! Fork the challenge and share what you do on Twitter (#noopschallenge) or in the GitHub community.
There are millions of things you can do with the Polybot, but here are a few ideas to get you started:
Have an idea of your own? Create an issue and we’ll add it to the list!
You can request up to 1,000 polygons, specify maxSides, minSides and size for your polygons, and set maximum x and y boundaries.
There’s a single endpoint: api.noopschallenge.com/polybot
The endpoint accepts 6 parameters, all optional:
minSides
and maxSides
to the same number.The endpoint returns a JSON object with an array named polygons
of n length. Each item in the polygons
array is an object with two properties: x and y.
Example return for a five-sided polygon:
GET https://api.noopschallenge.com/polybot
{
"polygons": [
[
{"x":157,"y":998},
{"x":145,"y":1000},
{"x":122,"y":1000},
{"x":106,"y":989},
{"x":151,"y":972}
]
]
}
Request a six-sided polygon:
GET https://api.noopschallenge.com/polybot?minSides=6&maxSides=6
{
"polygons": [
[
{ "x": 854, "y": 61 },
{ "x": 845, "y": 76 },
{ "x": 823, "y": 69 },
{ "x": 822, "y": 45 },
{ "x": 843, "y": 36 },
{ "x": 856, "y": 56 }
]
]
}
Request a polygon within a bounding box:
GET https://api.noopschallenge.com/polybot?count=2&width=10&height=10
{
"polygons": [
[
{ "x": 10, "y": 8 },
{ "x": 10, "y": 9 },
{ "x": 9, "y": 9 },
{ "x": 8, "y": 9 },
{ "x": 8, "y": 9 },
{ "x": 7, "y": 8 },
{ "x": 7, "y": 7 },
{ "x": 8, "y": 7 },
{ "x": 8, "y": 6 },
{ "x": 9, "y": 6 },
{ "x": 9, "y": 7 },
{ "x": 10, "y": 7 }
],
[
{ "x": 4, "y": 8 },
{ "x": 3, "y": 8 },
{ "x": 3, "y": 7 },
{ "x": 3, "y": 7 },
{ "x": 4, "y": 7 }
]
]
}
Read the complete API documentation.
More about Polybot on the challenge page at noopschallenge.com.