Write a website using HTML, CSS, and JS that displays a grid of dots and allows the user…
- User
Write a website using HTML, CSS, and JS that displays a grid of dots and allows the user to input a transformation matrix to transform the dots.
- Assistant
Here's an example of how you could create a website using HTML, CSS, and JavaScript to display a grid of dots and allow the user to input a transformation matrix to transform the dots:
- User
Thank you, this code works but unfortunately subsequent and successive presses of the transform button seem to be destructive of the pattern resulting in fewer and fewer dots. Can you rewrite the JavaScript so that the grid of dots does not become unusable after it is transformed?
- Assistant
const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d');
const DOT_SIZE = 5; const GRID_SIZE = 50; const DOT_SPACING = 10; const NUM_DOTS = GRID_SIZE * GRID_SIZE; const dots = [];
function init() { canvas.width = GRID_SIZE * DOT_SPACING; canvas.height = GRID_SIZE * DOT_SPACING;
codefor (let i = 0; i < NUM_DOTS; i++) { dots.push({x: i % GRID_SIZE * DOT_SPACING, y: Math.floor(i / GRID_SIZE) * DOT_SPACING}); } drawDots();}
function drawDots() { ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = 'black';
codefor (let i = 0; i < NUM_DOTS; i++) { ctx.beginPath(); ctx.arc(dots[i].x, dots[i].y, DOT_SIZE, 0, Math.PI * 2); ctx.fill(); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)