Skip to content

Instantly share code, notes, and snippets.

@xupeng
Created January 7, 2015 11:14
Show Gist options
  • Save xupeng/02011341aa9dfd8f428c to your computer and use it in GitHub Desktop.
Save xupeng/02011341aa9dfd8f428c to your computer and use it in GitHub Desktop.
code swarm patch
From ebfb3244047301facaef111a0414ae8f48a09a36 Mon Sep 17 00:00:00 2001
From: xupeng <xupeng@xupeng.me>
Date: Wed, 7 Jan 2015 19:07:02 +0800
Subject: [PATCH] save engine changes
---
physics_engine/Orderly.config | 2 +-
src/PhysicsEngineOrderly.java | 8 ++++----
src/code_swarm.java | 14 +++++++++-----
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/physics_engine/Orderly.config b/physics_engine/Orderly.config
index a6c3fb3..2f0e4f2 100644
--- a/physics_engine/Orderly.config
+++ b/physics_engine/Orderly.config
@@ -6,4 +6,4 @@ edgeMultiplier=1.0
calculationRandomizer=0.01
nodesMultiplier=1.0
speedMultiplier=1.0
-drag=0.5
\ No newline at end of file
+drag=0.5
diff --git a/src/PhysicsEngineOrderly.java b/src/PhysicsEngineOrderly.java
index b7615bb..896af80 100644
--- a/src/PhysicsEngineOrderly.java
+++ b/src/PhysicsEngineOrderly.java
@@ -38,7 +38,7 @@ public class PhysicsEngineOrderly extends PhysicsEngine
public void setup (CodeSwarmConfig p)
{
cfg = p;
- MIN_DISTANCE_SQR = 40000;
+ MIN_DISTANCE_SQR = 8000;
}
@@ -68,16 +68,16 @@ public class PhysicsEngineOrderly extends PhysicsEngine
delta.sub(pNode.mPosition, n.mPosition);
if (delta.lengthSquared() < MIN_DISTANCE_SQR) {
// This calculation gives a 'stiff spring' affect
- //float toMove = ((float)Math.sqrt(MIN_DISTANCE_SQR) - delta.length()) / 10.0f;
+ float toMove = ((float)Math.sqrt(MIN_DISTANCE_SQR) - delta.length()) / 10.0f;
// This calculation gives a much nicer flow
- float toMove = 0.03f;
+ //float toMove = 0.03f;
delta.scale((1 / delta.length()) * toMove);
n.mPosition.sub(delta);
pNode.mPosition.add(delta);
} else {
- float toMove = -0.003f;
+ float toMove = -0.006f;
delta.scale((1 / delta.length()) * toMove);
n.mPosition.sub(delta);
diff --git a/src/code_swarm.java b/src/code_swarm.java
index c7c156c..721c70f 100644
--- a/src/code_swarm.java
+++ b/src/code_swarm.java
@@ -177,6 +177,7 @@ public class code_swarm extends PApplet {
public AvatarFetcher avatarFetcher;
private int fontColor;
+ private int dateColor;
@@ -214,6 +215,7 @@ public class code_swarm extends PApplet {
background = cfg.getColorProperty(CodeSwarmConfig.BACKGROUND_KEY).getRGB();
fontColor = cfg.getColorProperty(CodeSwarmConfig.FONT_COLOR_KEY).getRGB();
+ dateColor = cfg.getColorProperty("DateColor").getRGB();
// Ensure we have sane values.
EDGE_LIFE_INIT = cfg.getPositiveIntProperty(CodeSwarmConfig.EDGE_LIFE_KEY);
@@ -488,11 +490,13 @@ public class code_swarm extends PApplet {
* Draw date in lower-right corner
*/
public void drawDate() {
- fill(fontColor, 255);
+ //fill(fontColor, 255);
+ fill(dateColor, 255);
String dateText = formatter.format(prevDate);
textAlign(RIGHT, BASELINE);
- textSize(font.size);
- text(dateText, width - 3, height - (2 + textDescent()));
+ //textSize(font.size);
+ textSize(28);
+ text(dateText, width - 100, height - (30 + textDescent()));
}
/**
@@ -530,11 +534,11 @@ public class code_swarm extends PApplet {
fill(fontColor, 255);
textFont(font);
textAlign(LEFT, TOP);
- text("Legend:", 3, 3);
+ text("Legend:", 30, 30);
for (int i = 0; i < colorAssigner.tests.size(); i++) {
ColorTest t = colorAssigner.tests.get(i);
fill(t.c1, 200);
- text(t.label, font.size, 3 + ((i + 1) * (font.size + 2)));
+ text(t.label, font.size, 30 + ((i + 1) * (font.size + 6)), -30);
}
}
--
1.9.3 (Apple Git-50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment