Skip to content

Commit

Permalink
Added 3D mode and cleaned up files
Browse files Browse the repository at this point in the history
  • Loading branch information
bohnacker committed Jan 28, 2020
1 parent 0aa7ed0 commit 3eca2a0
Show file tree
Hide file tree
Showing 8 changed files with 390 additions and 7,305 deletions.
7,309 changes: 219 additions & 7,090 deletions dist/StretchTransform.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions examples/example_2D/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../dist/StretchTransform.js"></script>
<script src="../lib/p5.min.js"></script>
<script src="sketch.js"></script>
</head>
<body>
</body>
</html>
55 changes: 17 additions & 38 deletions test/js/sketch.js → examples/example_2D/sketch.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// KEYS:
// + : add new anchor at mouse position
// DELETE/BACKSPACE : delete selected anchor
// q/a : increase/decrease exponent for matrix direction weighting
// w/s : increase/decrease exponent for matrix distance weighting
// e/d : increase/decrease exponent for point weighting
// - : delete selected anchor
// q/a : increase/decrease exponent for matrix distance weighting
// w/s : increase/decrease exponent for point weighting
//
// MOUSE:
// click or drag: drag anchor origin or target
Expand Down Expand Up @@ -31,14 +30,12 @@ function setup() {
anchorColor = color(0, 150, 0);
anchorHiColor = color(200, 100, 0);

// myTransform.addAnchor([margin, margin]);
// myTransform.addAnchor([width - margin, margin]);
// myTransform.addAnchor([width - margin, height - margin]);
// myTransform.addAnchor([margin, height - margin]);
// myTransform.addAnchor([300, 300], [350, 330]);
// myTransform.addAnchor([400, 400], [350, 370]);

// myTransform.setWeightingMode(StretchTransform.DIRECTIONAL);
myTransform.addAnchor([margin, margin]);
myTransform.addAnchor([width - margin, margin]);
myTransform.addAnchor([width - margin, height - margin]);
myTransform.addAnchor([margin, height - margin]);
myTransform.addAnchor([300, 300], [350, 330]);
myTransform.addAnchor([400, 400], [350, 370]);

}

Expand All @@ -52,10 +49,10 @@ function draw() {

if (anchorNum >= 0) {
if (dragOrigin) {
myTransform.setAnchorOrigin(anchorNum, mouseX, mouseY);
myTransform.setAnchorOrigin(anchorNum, [mouseX, mouseY]);
}
if (dragTarget) {
myTransform.setAnchorTarget(anchorNum, mouseX, mouseY);
myTransform.setAnchorTarget(anchorNum, [mouseX, mouseY]);
}
}

Expand Down Expand Up @@ -113,8 +110,8 @@ function mousePressed() {
dragTarget = false;
anchorNum = -1;

var io = myTransform.getAnchorByOriginPos(mouseX, mouseY, 10);
var it = myTransform.getAnchorByTargetPos(mouseX, mouseY, 10);
var io = myTransform.getAnchorByOriginPos([mouseX, mouseY], 10);
var it = myTransform.getAnchorByTargetPos([mouseX, mouseY], 10);

if (it >= 0) {
anchorNum = it;
Expand Down Expand Up @@ -143,44 +140,26 @@ function keyTyped() {
anchorNum = myTransform.getAnchorCount() - 1;
}

if (keyCode == DELETE || keyCode == BACKSPACE) {
if (key == '-') {
if (anchorNum >= 0) {
myTransform.removeAnchor(anchorNum);
anchorNum = -1;
}
}

if (key == ' ') {
if (myTransform.isSimple()) {
myTransform.setWeightingMode("directional");
console.log("weightingMode = DIRECTIONAL");
} else {
myTransform.setWeightingMode("simple");
console.log("weightingMode = SIMPLE");
}
}

if (key == 'q' || key == 'Q') {
myTransform.setWeightingExponent3(myTransform.getWeightingExponent3() + 0.5);
console.log("exponent3 = " + myTransform.getWeightingExponent3());
}
if (key == 'a' || key == 'A') {
myTransform.setWeightingExponent3(myTransform.getWeightingExponent3() - 0.5);
console.log("exponent3 = " + myTransform.getWeightingExponent3());
}
if (key == 'w' || key == 'W') {
myTransform.setWeightingExponent1(myTransform.getWeightingExponent1() + 0.5);
console.log("exponent1 = " + myTransform.getWeightingExponent1());
}
if (key == 's' || key == 'S') {
if (key == 'a' || key == 'A') {
myTransform.setWeightingExponent1(myTransform.getWeightingExponent1() - 0.5);
console.log("exponent1 = " + myTransform.getWeightingExponent1());
}
if (key == 'e' || key == 'E') {
if (key == 'w' || key == 'W') {
myTransform.setWeightingExponent2(myTransform.getWeightingExponent2() + 0.5);
console.log("exponent2 = " + myTransform.getWeightingExponent2());
}
if (key == 'd' || key == 'D') {
if (key == 's' || key == 'S') {
myTransform.setWeightingExponent2(myTransform.getWeightingExponent2() - 0.5);
console.log("exponent2 = " + myTransform.getWeightingExponent2());
}
Expand Down
File renamed without changes.
Loading

0 comments on commit 3eca2a0

Please sign in to comment.