Skip to content

Commit 93e33f3

Browse files
committed
fix pen tool
1 parent 0ad76f3 commit 93e33f3

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

src/containers/fill-color-indicator.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const FillColorIndicator = makeColorIndicator(messages.label, false);
2424

2525
const mapStateToProps = state => ({
2626
colorIndex: state.scratchPaint.fillMode.colorIndex,
27-
disabled: state.scratchPaint.mode === Modes.PEN,
27+
disabled: state.scratchPaint.mode === Modes.PEN || state.scratchPaint.mode === Modes.LINE,
2828
color: state.scratchPaint.color.fillColor.primary,
2929
color2: state.scratchPaint.color.fillColor.secondary,
3030
colorModalVisible: state.scratchPaint.modals.fillColor,

src/containers/pen-mode.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class PenMode extends React.Component {
8282
PenMode.propTypes = {
8383
clearSelectedItems: PropTypes.func.isRequired,
8484
colorState: PropTypes.shape({
85-
fillColor: PropTypes.string,
85+
fillStyle: PropTypes.string,
8686
strokeColor: PropTypes.string,
8787
strokeWidth: PropTypes.number
8888
}).isRequired,
@@ -96,7 +96,6 @@ PenMode.propTypes = {
9696
const mapStateToProps = state => ({
9797
colorState: state.scratchPaint.color,
9898
isPenModeActive: state.scratchPaint.mode === Modes.PEN
99-
10099
});
101100
const mapDispatchToProps = dispatch => ({
102101
clearSelectedItems: () => {

src/helper/tools/pen-tool.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import paper from '@scratch/paper';
2-
import {stylePath} from '../style-path';
2+
import {styleShape} from '../style-path';
33
import {endPointHit, touching} from '../snapping';
44
import {drawHitPoint, removeHitPoint} from '../guides';
55

@@ -57,12 +57,17 @@ class PenTool extends paper.Tool {
5757
handleMouseDown (event) {
5858
if (event.event.button > 0) return; // only first mouse button
5959
this.subpath = new paper.Path({insert: false});
60+
this.subpath.strokeCap = 'round';
6061

6162
// If you click near a point, continue that line instead of making a new line
6263
this.hitResult = endPointHit(event.point, PenTool.SNAP_TOLERANCE);
6364
if (this.hitResult) {
6465
this.path = this.hitResult.path;
65-
stylePath(this.path, this.colorState.strokeColor, this.colorState.strokeWidth);
66+
styleShape(this.path, {
67+
fillColor: null,
68+
strokeColor: this.colorState.strokeColor,
69+
strokeWidth: this.colorState.strokeWidth
70+
});
6671
if (this.hitResult.isFirst) {
6772
this.path.reverse();
6873
}
@@ -74,7 +79,12 @@ class PenTool extends paper.Tool {
7479
// If not near other path, start a new path
7580
if (!this.path) {
7681
this.path = new paper.Path();
77-
stylePath(this.path, this.colorState.strokeColor, this.colorState.strokeWidth);
82+
styleShape(this.path, {
83+
fillColor: null,
84+
strokeColor: this.colorState.strokeColor,
85+
strokeWidth: this.colorState.strokeWidth
86+
});
87+
this.path.strokeCap = 'round';
7888
this.path.add(event.point);
7989
this.subpath.add(event.point);
8090
paper.view.draw();

src/playground/index.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
<title><%= htmlWebpackPlugin.options.title %></title>
77
</head>
88
<body>
9-
<script src="/dist/scratch-paint.js"></script>
9+
<script src="/playground/playground.js"></script>
1010
</body>
1111
</html>

0 commit comments

Comments
 (0)