diff --git a/index.js b/index.js index a98dd2f..cb51e85 100644 --- a/index.js +++ b/index.js @@ -28,13 +28,13 @@ window.actions = actionWrapper(actions, store.dispatch); // add inital shapes import * as CAL from 'cal'; -store.dispatch(actions.addObject({ - type: 'FREE_HAND', - fill: false, - solid: false, - points: [new CAL.Vector(-20, 0), new CAL.Vector(10, 1)], - transform: new CAL.Matrix({ x: 0, y: 0 }) -})); +// store.dispatch(actions.addObject({ +// type: 'FREE_HAND', +// fill: false, +// solid: false, +// points: [new CAL.Vector(-20, 0), new CAL.Vector(10, 1)], +// transform: new CAL.Matrix({ x: 0, y: 0 }) +// })); store.dispatch(actions.addObject({ type: 'RECT', fill: true, diff --git a/src/components/D2Panel.js b/src/components/D2Panel.js index 2bc9012..b7377ca 100644 --- a/src/components/D2Panel.js +++ b/src/components/D2Panel.js @@ -4,6 +4,7 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import * as CAL from 'cal'; import * as toolNames from '../constants/d2Tools'; +import { PIPETTE } from '../constants/contextTools.js'; import { CANVAS_SIZE } from '../constants/d2Constants'; import createRAFOnce from '../utils/rafOnce.js'; import Grid from '../d2/Grid.js'; @@ -13,6 +14,7 @@ import EraserTool from '../d2/tools/EraserTool.js'; import BrushTool from '../d2/tools/BrushTool.js'; import PolygonTool from '../d2/tools/PolygonTool.js'; import CircleTool from '../d2/tools/CircleTool.js'; +import PipetteTool from '../d2/tools/PipetteTool.js'; import TextTool from '../d2/tools/TextTool.js'; import BucketTool from '../d2/tools/BucketTool.js'; import PhotoGuideTool from '../d2/tools/PhotoGuideTool.js'; @@ -30,14 +32,15 @@ const CANVAS_WIDTH = CANVAS_SIZE * 2; const CANVAS_HEIGHT = CANVAS_SIZE * 2; const tools = { - [toolNames.TRANSFORM]: TransformTool, - [toolNames.ERASER]: EraserTool, - [toolNames.TEXT]: TextTool, - [toolNames.BUCKET]: BucketTool, - [toolNames.PHOTO_GUIDE]: PhotoGuideTool, - [toolNames.BRUSH]: BrushTool, - [toolNames.POLYGON]: PolygonTool, - [toolNames.CIRCLE]: CircleTool + [toolNames.TRANSFORM]: TransformTool, + [toolNames.ERASER]: EraserTool, + [toolNames.TEXT]: TextTool, + [toolNames.BUCKET]: BucketTool, + [toolNames.PHOTO_GUIDE]: PhotoGuideTool, + [toolNames.BRUSH]: BrushTool, + [toolNames.POLYGON]: PolygonTool, + [toolNames.CIRCLE]: CircleTool, + [PIPETTE]: PipetteTool }; // TODO the same as 3d diff --git a/src/components/SubMenu.js b/src/components/SubMenu.js index 5d4cfdf..44f4ea8 100644 --- a/src/components/SubMenu.js +++ b/src/components/SubMenu.js @@ -3,10 +3,12 @@ import PropTypes from 'prop-types'; import Button from './Button.js'; import Menu from './Menu.js'; import bowser from 'bowser'; +import { connect } from 'react-redux'; +import { hexToStyle } from '../utils/colorUtils.js'; // import createDebug from 'debug'; // const debug = createDebug('d3d:ui:submenu'); -export default class SubMenu extends React.Component { +class SubMenu extends React.Component { static propTypes = { onSelect: PropTypes.func, onOpen: PropTypes.func, @@ -64,12 +66,17 @@ export default class SubMenu extends React.Component { } }; render() { - const { id, value, selected, open, selectedValue, children, svg, toggleBehavior } = this.props; + const { id, value, selected, open, selectedValue, children, svg, toggleBehavior, color, solid } = this.props; + + const style = {}; + if (id === 'color-picker-tool') { + style.fill = solid ? hexToStyle(color) : 'url(#holepattern)'; + } let className = 'submenu'; if (open) className += ' open'; return ( -
  • +