Skip to content

Commit 3c33194

Browse files
committed
ordinal color + interactions + remove bg on proto edit
1 parent 34c5392 commit 3c33194

5 files changed

Lines changed: 306 additions & 56 deletions

File tree

assets/css/main.css

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ li .fakeGrammarRow {
713713

714714
.colorRamp p {
715715
display: flex;
716-
margin-bottom: -11px ;
716+
margin-bottom: -3px ;
717+
717718
}
718719
.colorRamp span {
719720
width: 15px;
@@ -725,5 +726,30 @@ li .fakeGrammarRow {
725726

726727
.rampLabel {
727728
position: absolute;
728-
top: 27px;
729-
}
729+
top: 26px;
730+
}
731+
732+
.colorDisplay div {
733+
max-width: 25px;
734+
735+
}
736+
.colorDisplay {
737+
display: flex;
738+
margin-left: 45px;
739+
}
740+
741+
.colorDisplayElem {
742+
width: 15px;
743+
height: 15px;
744+
}
745+
746+
.colorDisplayLabel {
747+
transform-origin: center;
748+
transform: rotate(-45deg);
749+
margin-bottom: 11px;
750+
margin-left: -14px;
751+
font-size: 14px;
752+
text-overflow:ellipsis;
753+
overflow:hidden;
754+
width: 60px;
755+
}

assets/js/collageGrid.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ function makeCollageFromData(palettes, order, marks, row, color = undefined, siz
222222
let tcol = megaGlyph[order[j]].color.colorScale(megaGlyph[order[j]].color.linearScale(row[megaGlyph[order[j]].color.dataColumn])).replace("rgb(", "").replace(")", "").split(",")
223223
can = toColor(can, +tcol[0] * cl, +tcol[1] * cl, +tcol[2] * cl, 210)
224224
} else {
225-
let tcol = hexToRgb(megaGlyph[order[j]].color.colorScale(row[megaGlyph[order[j]].color.dataColumn]))
225+
let tcol = hexToRgb(megaGlyph[order[j]].color.colors["default"])
226+
if (megaGlyph[order[j]].color.colors[row[megaGlyph[order[j]].color.dataColumn]]) {
227+
tcol = hexToRgb(megaGlyph[order[j]].color.colors[row[megaGlyph[order[j]].color.dataColumn]])
228+
}
229+
226230
can = toColor(can, tcol.r * cl, tcol.g * cl, tcol.b * cl, 210)
227231
}
228232
removeColor(230, 230, 230, can, 25)

assets/js/paletteHandler.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ let palIt = 0
2121

2222
let megaPalettes = {}
2323

24+
25+
let nSelPaltette;
26+
let nSelMark;
27+
let nSelType;
28+
2429
function 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

Comments
 (0)