@@ -13,14 +13,12 @@ import {
1313 editingState ,
1414 nibSizeState ,
1515 paletteNibState ,
16- paletteSelectionState ,
1716 preloadNibState ,
1817 sceneScreenState ,
1918 sceneState
2019} from '../recoils' ;
2120import { useDropper } from '../recoils/useDropper' ;
2221import Cursor , { cursorClasses } from '../utils/cursor' ;
23- import { getMatrix } from '../utils/selection' ;
2422import { editWithCursor } from '../utils/updateScene' ;
2523import { Paper } from './Paper' ;
2624
@@ -93,24 +91,9 @@ export function CanvasView() {
9391 const canvas = nibCanvasRef . current ;
9492 const ctx = canvas ?. getContext ( '2d' ) ;
9593 if ( ! canvas || ! ctx ) return ;
96- const selectionLoadable = getLoadable ( paletteSelectionState ) ;
97- let rows = 0 ;
98- let cols = 0 ;
99- if ( selectionLoadable . state === 'hasValue' ) {
100- const selection = selectionLoadable . contents ;
101- if ( selection ) {
102- const matrix = getMatrix ( selection ) ;
103- rows = matrix . length ;
104- cols = matrix [ 0 ] ?. length || 0 ;
105- }
106- }
107- const nibSizeLoadable = getLoadable ( nibSizeState ) ;
108- if (
109- nibSizeLoadable . state === 'hasValue' &&
110- nibSizeLoadable . contents > 1
111- ) {
112- rows = cols = nibSizeLoadable . contents ;
113- }
94+ const loadable = getLoadable ( nibSizeState ) ;
95+ if ( loadable . state !== 'hasValue' ) return ;
96+ const { cols, rows } = loadable . contents ;
11497 ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
11598 ctx . strokeStyle = '#333' ;
11699 ctx . strokeRect ( x * 32 , y * 32 , 32 * cols , 32 * rows ) ;
0 commit comments