Given: a width, a height, and a set of sets of points. Output: An image where each set of points is connected and colored in (like a shape). Each shape must be a different color from all of the other shapes, but the actual color doesn't matter as long as each color is distinct. The shapes must be in order; whether you start at the end or the beginning of the set doesn't matter, though. The dots must be connected in the order they're given in the set.
Output formats are in accordance with standard image rules.
Examples
//the code here has nothing to do with the actual challenge and just shows examples
document.getElementById("one").getContext("2d").fillRect(0, 0, 300, 300)
const ctx = document.getElementById("two").getContext("2d")
ctx.fillStyle = "black"
ctx.beginPath();ctx.moveTo(0,0);ctx.lineTo(0,300);ctx.lineTo(300,0);ctx.closePath();ctx.fill()
ctx.fillStyle = "lime"
ctx.beginPath();ctx.moveTo(200,0);ctx.lineTo(600,0);ctx.lineTo(300,300);ctx.closePath();ctx.fill()
canvas {border: 1px dotted black}
<pre>Width: 500, Height: 500, Set: [[[0, 0], [0, 300], [300, 300], [300, 0]]]</pre>
<canvas id="one" width="500" height="500"></canvas>
<pre>Width: 600, Height: 300, Set:
[
[[0,0], [0,300], [300,0]],
[[200,0], [600,0], [300,300]]
]</pre>
<canvas id="two" width="600" height="300"></canvas>
Scoring is code-golf.
1 Answer 1
R, (削除) 122 (削除ここまで) 71 bytes
function(w,h,p){plot.new();plot.window(c(0,w),c(0,h));polygon(p,c=1:8)}
RDRR - actually shows graphics
A function that takes arguments width, height and a matrix of points detailing the shapes. Each shape is separated by a row of NAs. Output is a plot to the screen of the shapes.
#000000different to#000001? \$\endgroup\$