@@ -21,6 +21,11 @@ let palIt = 0
2121
2222let megaPalettes = { }
2323
24+
25+ let nSelPaltette ;
26+ let nSelMark ;
27+ let nSelType ;
28+
2429function addAPalette ( ) {
2530
2631 megaPalettes [ "temp" + palIt ] = {
@@ -35,7 +40,7 @@ function addAPalette() {
3540
3641 ++ palIt
3742 fillPalette ( )
38-
43+ addAMark ( )
3944 drawSvg ( )
4045}
4146
@@ -419,6 +424,27 @@ function onClickPalette(e) {
419424 // document.getElementById("selectedButton2").removeAttribute("id")
420425 // doc
421426 // el.setAttribute("id", "selectedButton2")
427+ } else if ( mode === "eraseColor" ) {
428+ let xy = getMousePos ( e ) ;
429+ xy = toWorld ( xy , paletteOrigin , paletteScale )
430+ console . log ( xy ) ;
431+
432+ let tcan = megaPalettes [ nSelPaltette ] . encodings . range . marks [ nSelMark ] . source
433+
434+ let tw = 60
435+ let th = 60
436+
437+ let tx = ( xy . x - paletteTempCan . width / 2 + tw / 2 )
438+ let ty = ( xy . y - paletteTempCan . height / 2 + th / 2 )
439+
440+ let cont = tcan . getContext ( "2d" )
441+ const [ r , g , b , a ] = cont . getImageData ( tx , ty , 1 , 1 ) . data ;
442+ console . log ( r , g , b , a ) ;
443+
444+ removeColor ( r , g , b , paletteTempCan , 50 )
445+ removeColor ( r , g , b , megaPalettes [ nSelPaltette ] . encodings . range . marks [ nSelMark ] . source , 50 )
446+ removeColor ( r , g , b , megaPalettes [ nSelPaltette ] . encodings . range . marks [ nSelMark ] . proto . canvas , 50 )
447+
422448 }
423449}
424450
@@ -435,7 +461,7 @@ function updateAnchorCont(container) {
435461
436462 let sel = ""
437463
438- if ( key == currAnchor ) {
464+ if ( key === currAnchor ) {
439465 sel = " selectedAnchor"
440466 }
441467
@@ -1127,8 +1153,7 @@ function setAnchorOnProto(e, el) {
11271153 // tx = (xy.x *source.width) / tw
11281154 // ty = (xy.y *source.height) / th
11291155
1130- }
1131- else {
1156+ } else {
11321157 console . log ( "heheheh" ) ;
11331158 // tx = clampVal(xy.x - tw / 2 + source.width / 2, 0, source.width)
11341159 // ty = clampVal(xy.y - th / 2 + source.height / 2, 0, source.height)
@@ -1137,8 +1162,8 @@ function setAnchorOnProto(e, el) {
11371162 tx = clampVal ( xy . x - tw / 2 + source . width / 2 , 0 , source . width )
11381163 ty = clampVal ( xy . y - th / 2 + source . height / 2 , 0 , source . height )
11391164 }
1140- tw = source . width * scale
1141- th = source . height * scale
1165+ tw = source . width * scale
1166+ th = source . height * scale
11421167 }
11431168
11441169
@@ -1481,6 +1506,7 @@ function makeSingleMark(key, label, type, can = undefined) {
14811506 tdiv_mark . setAttribute ( "type" , type )
14821507 tdiv_mark . setAttribute ( "number" , "" + label )
14831508
1509+
14841510 let mess = `<input type='text' value='${ label } ' class='paletteMarkName'>`
14851511
14861512 if ( type === "morph" ) {
@@ -1506,6 +1532,9 @@ function makeSingleMark(key, label, type, can = undefined) {
15061532
15071533 if ( mode !== "anchor" ) {
15081534 if ( e . target . matches ( "canvas" ) ) {
1535+ nSelPaltette = key
1536+ nSelMark = label
1537+ nSelType = type
15091538 editPalette ( this )
15101539 }
15111540 } else {
0 commit comments