From 10e7ce5764b3b456e1f909cd6b6a90f076c2e014 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Thu, 17 May 2018 20:17:01 +0100 Subject: Fixed rotation problem. Added rotate function. Added docker file --- src/PaintArea.js | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'src/PaintArea.js') diff --git a/src/PaintArea.js b/src/PaintArea.js index 1ffec83..3b64beb 100644 --- a/src/PaintArea.js +++ b/src/PaintArea.js @@ -1,4 +1,5 @@ import React, { Component } from 'react' +import { rgb, getPixel } from './Utils' /** * Expects props: @@ -44,29 +45,33 @@ export default class PaintArea extends Component { } render() { - let cells = this.props.data.map((row, iy) => { - let rowCells = row.map((cell, ix) => { - let r = cell[0] - let g = cell[1] - let b = cell[2] - return this.handleMouseMove(ix, iy)} - onClick={() => this.props.onTool(ix, iy)} - className="paintareacell" - style={{ - background: `rgb(${r},${g},${b})` - }} - key={(ix * 100000) + iy}/> - }) - return {rowCells} - }) + let data = this.props.data + let height = data[0] ? data[0].length : 0 + let rows = [] + for (var y=height-1; y>=0; y--) { + let cells = [] + for (var x=0; x this.handleMouseMove(ix, iy)} + onClick={() => this.props.onTool(ix, iy)} + className="paintareacell" + style={{ + background: `rgb(${r},${g},${b})` + }} + key={(ix * 100000) + iy}/>) + } + rows.push({cells}) + } return ( - {cells} + {rows}
) -- cgit v1.2.3-ZIG