Skip to content
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

Feature request: bandaging cubelets, at least visually #46

Open
kupietools opened this issue Oct 16, 2024 · 2 comments
Open

Feature request: bandaging cubelets, at least visually #46

kupietools opened this issue Oct 16, 2024 · 2 comments

Comments

@kupietools
Copy link

kupietools commented Oct 16, 2024

Here's a probably low-priority feature I myself would love to see. I'm working on a simulator for bandaged cubes. The "bandaged" blocks are indicated by marking them, since in the simulator itself there's no faculty for drawing or simulating bandaged cubes. Here's what it currently looks like, with the cubelets on the lower left front being the "bandaged" ones:

image

What I would love is if there was a way to erase the visual borders between the bandaged cubelets, so it looks something like this:

image

I realize it's an obscure and probably difficult request, but if someone felt like doing it, I'd be grateful.

Even better would be if there were some way to tell it not to allow turns that would break the bandages; but, really, that would be a luxury, it's not that important. If I could just visually hide the edges between bandaged cubelets that would be enough. Sort of like the Florian mod has an array that tells it when to round certain corners... I'd like to tell it to make the width of certain borders 0 so there's no visual break between adjacent cubelets.

Just kind of an out-there pipe dream, but I thought I'd throw it out just in case someone ever felt like tackling it.

I could see it specified as another of those long 54-character formatting strings, with each character as specifying one cubelet, just like the colors. You could have a binary number with 1111 meaning top, right, bottom, and left, borders so any combination of hiding borders could be expressed with a single hexadecimal character from 0 to F. 0 = 0000 = don't hide any borders, 1 = 0001 = hide left border, 2 = 0010 = hide bottom border, 3= 0011 = hide left & bottom, etc. Or something like that. It looks in the code like only pairs of opposite (horiz/vertical) borders are specified in the border[][] array, so, not sure. Just brainstorming here.

Alternatively, and maybe simpler, if it were possible to add extra objects specified with xyz coords and "patch them in" to the cube, maybe specify a cubelet they stay "attached" to and follow the orientation of, and have the script manage rotating them as the cubelet they're attached to moves, that would be incredible. Then I could just draw my own rectangles over the parts of the cube I want to obscure. That would also let you do things like attach floating labels that hovered near specific pieces and stayed with them as they rotated during an algorithm to make it really easy to see how a given piece moves.

@kupietools
Copy link
Author

kupietools commented Oct 23, 2024

I did it.

I modified the drawMarker function in the markers customization to accept a color parameter, and created a 5th marker type, a solid filled color square, with a -0.65 margin instead of the .2 margins the other markers have.

function drawMarkerNew(g, xx, yy, m, color="black") {
var x = [];
    var y = [];
    var theAdjust;
    if (m === 5) {
    theAdjust = -0.065; 
    g.strokeStyle = color;} 
    else {
    theAdjust = 0.2; 
    g.strokeStyle = "black";}
    // scale down so there is a margin around the X
    for (var i = 0; i < 4; i++) {
      x[i] = Math.floor(xx[i] + (xx[superRotate[2][i]] - xx[i]) * theAdjust);
      y[i] = Math.floor(yy[i] + (yy[superRotate[2][i]] - yy[i]) * theAdjust);
    }
    g.lineWidth = 2*dpr;


    if (m === 1) {
      // an "X"
      g.beginPath();
      g.moveTo(x[0], y[0]);
      g.lineTo(x[2], y[2]);
      g.closePath();
      g.stroke();
      g.beginPath();
      g.moveTo(x[1], y[1]);
      g.lineTo(x[3], y[3]);
      g.closePath();
      g.stroke();
    } else if (m === 2) {
      // a square "□"
      g.beginPath();
      g.moveTo(x[0], y[0]);
      g.lineTo(x[1], y[1]);
      g.lineTo(x[2], y[2]);
      g.lineTo(x[3], y[3]);
      g.closePath();
      g.stroke();
    } else if (m === 3) {
      // a "+"
      g.beginPath();
      g.moveTo((x[0] + x[1]) / 2, (y[0] + y[1]) / 2);
      g.lineTo((x[2] + x[3]) / 2, (y[2] + y[3]) / 2);
      g.closePath();
      g.stroke();
      g.beginPath();
      g.moveTo((x[0] + x[3]) / 2, (y[0] + y[3]) / 2);
      g.lineTo((x[1] + x[2]) / 2, (y[1] + y[2]) / 2);
      g.closePath();
      g.stroke();
    } else if (m === 4) {
      // a 45°-rotated square "◇"
      g.beginPath();
      g.moveTo((x[0] + x[1]) / 2, (y[0] + y[1]) / 2);
      g.lineTo((x[1] + x[2]) / 2, (y[1] + y[2]) / 2);
      g.lineTo((x[2] + x[3]) / 2, (y[2] + y[3]) / 2);
      g.lineTo((x[3] + x[0]) / 2, (y[3] + y[0]) / 2);
      g.closePath();
      g.stroke();
    } else if (m === 5) {
      // a filled square "□"
      
      g.beginPath();
      g.moveTo(x[0], y[0]);
      g.lineTo(x[1], y[1]);
      g.lineTo(x[2], y[2]);
      g.lineTo(x[3], y[3]);
      g.closePath();
      g.stroke();
      g.fillStyle = color;
      g.fill();
    }
  }

then you just update calls to drawMarker(graphics, fillX, fillY) to drawMarkerNew(graphics, fillX, fillY, mcube[i][p * 3 + q]).

Then in the marker formatting string, you put a '5' in the cubelet positions that you want the color to go all the way to the edges of that cubelet and cover the black border.

markers: "000000000550550000055055000000000000000550550000000000"

Obviously the "bandage" is just visual, the cube can still turn to break it, but I just make sure that none of my demo algorithms do that.

image

(Update: I've integrated this into my fork at https://github.com/kupietools/AnimCubeJS3-mk. Not going to suggest a merge as my needs are pretty custom, I don't think my changes should be in the main branch. But anyone who happens to have the same needs is welcome to check it out.)

@bcube2
Copy link
Collaborator

bcube2 commented Oct 24, 2024

[non-programmer speaking]

Nice beginning, however, if you are taking inspiration for improvement in terms of both visual appearance and functionality, take a look at the Bicube and/or Bandaged 2x2x2 simulator by isaacvr (see his CubicDB project and simulators´s source codes in TypeScript).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants