Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

30
LINES

< > BotCompany Repo | #1034958 // OnePathShifter - shift a OnePath one pixel to the left or right (along the path) [dev.]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (7621L/42K).

// only shift-right supported so far
srecord noeq OnePathShifter(OnePathWithOrigin path, bool shiftRight) { 
  Pt pIn, pOut;
  int direction;
  int iStep;
  gettable OnePathWithOrigin outPath;
  
  run {
    assertTrue(shiftRight);
    outPath = new OnePathWithOrigin;
    pIn = path.origin();
    
    while (iStep < path.nSteps()) {
      int step = path.getStep(iStep);
      Pt dir = onePathDirection(step);
      if (direction == 0) {
        direction = step;
        pOut = ptPlus(path.origin(), rotatePtRight(dir));
        outPath.setOrigin(pOut);
      }
        
      outPath.addStep(step);

      pIn = ptPlus(pIn, dir);
      ++iStep;
    }
  }
  
  OnePathWithOrigin get() { if (outPath == null) run(); ret outPath; }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034958
Snippet name: OnePathShifter - shift a OnePath one pixel to the left or right (along the path) [dev.]
Eternal ID of this version: #1034958/4
Text MD5: c7570d9a7b4aa8f10d858593e83452e8
Transpilation MD5: 85e3c34be8d2fd2bcf4d127e4163d981
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-18 00:57:15
Source code size: 763 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 58 / 128
Version history: 3 change(s)
Referenced in: [show references]