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

31
LINES

< > BotCompany Repo | #1035374 // G22MeshScrambler - reorder anchors, flip curves (but keep mesh the same)

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

Libraryless. Click here for Pure Java version (11917L/69K).

1  
srecord noeq G22MeshScrambler(G22Mesh mesh) {
2  
  delegate Anchor, Curve to G22Mesh.
3  
  
4  
  G22Mesh scrambledMesh;
5  
  new Map<Anchor> anchorMap;
6  
  
7  
  G22Mesh get() {
8  
    scrambledMesh = new G22Mesh;
9  
    
10  
    // copy anchors in shuffled order
11  
    
12  
    for (a1 : shuffled(mesh.anchors())) {
13  
      var a2 = scrambledMesh.newAnchor(a1.pt);
14  
      anchorMap.put(a1, a2);
15  
    }
16  
    
17  
    // copy curves (optionally flipping them)
18  
    
19  
    for (c1 : shuffled(mesh.curves())) {
20  
      bool flip = flipCoin();
21  
      var path = flip ? c1.path.reversed() : c1.path;
22  
      scrambledMesh.addCurve(new Curve(
23  
        anchorMap.get(c1.anchor(flip)),
24  
        anchorMap.get(c1.anchor(!flip)),
25  
        path
26  
      ));
27  
    }
28  
    
29  
    ret scrambledMesh;
30  
  }
31  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035374
Snippet name: G22MeshScrambler - reorder anchors, flip curves (but keep mesh the same)
Eternal ID of this version: #1035374/3
Text MD5: 669ef3023f3d75f2db2a35594da26770
Transpilation MD5: 501439120f7d8c4697f76ffb2c8a14e5
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-03 13:14:39
Source code size: 760 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 140 / 225
Version history: 2 change(s)
Referenced in: [show references]