-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🎉 お絵かきキャンバス実装 #8
Conversation
99ab13f
to
afac853
Compare
Deploying nascalay-v2-preview with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
とりあえずfill
}, []); | ||
|
||
const undoHistory = useCallback((currentData: Entry) => { | ||
if (history.current.undoList.length === 0) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
実質これと同じだけどcanUndo
を使うのがよさそう
他のとこも
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こっちのほうがコストが低くて安全なので
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コスト周りあまり詳しくないけど例えばcanUndo/canRedoをなくしてhistoryだけをstateで管理するのとかはどう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
正直書いたの前だからあんまり覚えてないんだけど
history を ref で持ってるのは破壊的変更したほうがコピーのコスト削減できる & 読みやすいから state じゃなくて ref で持って破壊的変更してるはず
リレンダリング的な話だと history の途中 (最初でも最新でもないところ) でリレンダリング走らないからちょっとだけ得
変更し忘れ的な話をしたいんだと思うけど、この hooks 自体が小さいしシンプルだからこっちのほうが良くないかなと思うけど
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多重管理してるのがやっぱり気になるけどちょっとでもパフォーマンスいいならこれでもいいです
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ちょっとでもパフォーマンスがいいのは確かだよ (上にも理由書いてるけど)
const next = undoHistory(now); | ||
if (next === null) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
時間的にnextなのは分かるがprevだろみたいな気もする
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
次に適用するって意味で next ね
40fa14c
to
79f2108
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大体見たつもり
* @returns 右端の x 座標 | ||
*/ | ||
function drawToRight( | ||
data: Color[][], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data: Color[][], | |
colorMap: Color[][], |
とかpixelData
とかだと苦なく読める
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR 出してるし前言ったけど bucketFill は修正しないね
向こうでも data 使ってるからそっちに書いてくれ
}, []); | ||
|
||
const undoHistory = useCallback((currentData: Entry) => { | ||
if (history.current.undoList.length === 0) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コスト周りあまり詳しくないけど例えばcanUndo/canRedoをなくしてhistoryだけをstateで管理するのとかはどう
}, []); | ||
|
||
const undoHistory = useCallback((currentData: Entry) => { | ||
if (history.current.undoList.length === 0) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多重管理してるのがやっぱり気になるけどちょっとでもパフォーマンスいいならこれでもいいです
ベースは v1 のときのやつ
ガッツリリファクタしたから原型はあんまない
塗りつぶし部分はほぼまんま
端っこで途切れないようにいい感じにした
localhost:5173/tmp2
でぐりぐりできます