Skip to content

Commit

Permalink
Fixes bug with freehand, improves cursor.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveruizok committed Mar 12, 2021
1 parent a5cd98b commit f891202
Show file tree
Hide file tree
Showing 8 changed files with 3,894 additions and 19 deletions.
3,857 changes: 3,856 additions & 1 deletion app/background.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/background.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
"release:mac": "gh release create v0.3.5 ./dist/*.dmg"
},
"dependencies": {
"@state-designer/react": "^1.5.6",
"cardinal-spline": "^0.0.1",
"@state-designer/react": "^1.6.1",
"electron-serve": "^1.0.0",
"electron-store": "^6.0.1",
"electron-updater": "^4.3.8",
"framer-motion": "^3.3.0",
"lodash-es": "^4.17.20",
"perfect-freehand": "^0.3.0",
"perfect-freehand": "^0.3.4",
"react-feather": "^2.0.9",
"state-designer": "^1.5.6",
"styled-components": "^5.2.1",
Expand Down
2 changes: 1 addition & 1 deletion renderer/components/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function App() {
const rMarksCanvas = React.useRef<HTMLCanvasElement>()
const rCurrentCanvas = React.useRef<HTMLCanvasElement>()
const showCursor = useSelector((state) => {
return state.isIn("active", "cursorVisible")
return state.isIn("active", "cursorVisible") && !state.isIn("drawing")
})

React.useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions renderer/components/cursor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { mvPointer } from "hooks/usePointer"

export default function Cursor() {
const activeColor = useSelector((state) => state.data.color)

return (
<CursorContainer
data-cursor="true"
Expand Down
9 changes: 6 additions & 3 deletions renderer/lib/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ const state = createState({
notDrawing: {
on: {
STARTED_DRAWING: {
if: "drawingWithPen",
to: ["cursorHidden", "drawing"],
else: { to: "drawing" },
to: "drawing",
// Yes for iPad, no for Wacom. Hmm...
// if: "drawingWithPen",
// to: ["cursorHidden", "drawing"],
// else: { to: "drawing" },
},
},
onEnter: {
Expand Down Expand Up @@ -686,6 +688,7 @@ const state = createState({
ctx.clearRect(0, 0, cvs.width, cvs.height)

if (mark === undefined) return
if (mark.points.length === 0) return

const { type } = mark

Expand Down
4 changes: 4 additions & 0 deletions renderer/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export function getSvgPathFromStroke(stroke: number[][]) {
const d: string[] = []

if (stroke.length < 2) {
return ""
}

let [p0, p1] = stroke

d.push(`M ${p0[0]} ${p0[1]} Q`)
Expand Down
33 changes: 23 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,17 @@
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==

"@state-designer/[email protected]":
version "1.6.1"
resolved "https://registry.yarnpkg.com/@state-designer/core/-/core-1.6.1.tgz#12afaccc1930cee9f5b0c9a22f41d15f41685eac"
integrity sha512-Ynx9l19GffKtA25HeZwi8Gd9KDBTTbwsQksjZxpNkdCEzDdYw5oeliw42kItjiY2kJnVhjv31IjqR6RlIDNq6A==
dependencies:
immer "^8.0.1"
lodash "^4.17.20"
lodash-es "^4.17.20"
object.entries "^1.1.1"
object.fromentries "^2.0.2"

"@state-designer/core@latest":
version "1.4.5"
resolved "https://registry.yarnpkg.com/@state-designer/core/-/core-1.4.5.tgz#efb4e7ed8f71d354d1cf612183e23c1c0926e0b9"
Expand All @@ -1123,7 +1134,14 @@
object.entries "^1.1.1"
object.fromentries "^2.0.2"

"@state-designer/react@^1.5.6", "@state-designer/react@latest":
"@state-designer/react@^1.6.1":
version "1.6.1"
resolved "https://registry.yarnpkg.com/@state-designer/react/-/react-1.6.1.tgz#e41e2f66babb981c120dc7fa8d9851cc89812368"
integrity sha512-W2AsP2XYAvgFddEdzX842FoOLVYVOvlfedmF1c1bAnAhzZhq52l+/pG/RljqxTAHr/dJImoqeJ3WXP1HZZJvEQ==
dependencies:
"@state-designer/core" "1.6.1"

"@state-designer/react@latest":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@state-designer/react/-/react-1.5.6.tgz#c13483646689a4565a6a82054ea6c2e60da3fbb2"
integrity sha512-6/ICOt5lJKZn/V7C/AeWsbe64gjor3Ddn2hE/NblViYvFmWokUrLF1lMTa+RnKIvZGkE+KUAv8GGCWvjy5H6zQ==
Expand Down Expand Up @@ -2106,11 +2124,6 @@ caniuse-lite@^1.0.30001181:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001196.tgz#00518a2044b1abf3e0df31fadbe5ed90b63f4e64"
integrity sha512-CPvObjD3ovWrNBaXlAIGWmg2gQQuJ5YhuciUOjPRox6hIQttu8O+b51dx6VIpIY9ESd2d0Vac1RKpICdG4rGUg==

cardinal-spline@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/cardinal-spline/-/cardinal-spline-0.0.1.tgz#55066f224d5e441bf79b5a484bf6573941f141de"
integrity sha1-VQZvIk1eRBv3m1pIS/ZXOUHxQd4=

[email protected], chalk@^2.0.0, chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
Expand Down Expand Up @@ -5018,10 +5031,10 @@ pend@~1.2.0:
resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50"
integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA=

perfect-freehand@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/perfect-freehand/-/perfect-freehand-0.3.0.tgz#892624c83550ed2c71b5c9fbe67fc87b1b13ba8a"
integrity sha512-8jdmc0So/NLfZokOGD1g+7JfJsD02MF0dHFP3QxKbESC7R6TBavM6aD08hWPX3KUTp25OhrrTYb6HzVVxgUq/w==
perfect-freehand@^0.3.4:
version "0.3.4"
resolved "https://registry.yarnpkg.com/perfect-freehand/-/perfect-freehand-0.3.4.tgz#13a3740cf2fa52e0778f99b666fd64d19edf8ed0"
integrity sha512-1Ad5Ra26uZ3u1Q/qw02YkREm8aq2v47FS7pHjB80A5yqFHjMFBy/lSD631wtrDC31pwB6GOuMjAbiPQXs5Gswg==

picomatch@^2.0.4, picomatch@^2.2.1:
version "2.2.2"
Expand Down

0 comments on commit f891202

Please sign in to comment.