[xiph-commits] r10115 - trunk/planarity
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Sun Oct 2 23:51:12 PDT 2005
Author: xiphmont
Date: 2005-10-02 23:51:10 -0700 (Sun, 02 Oct 2005)
New Revision: 10115
Modified:
trunk/planarity/gameboard_logic.c
trunk/planarity/graph_generate.c
trunk/planarity/version.h
Log:
New expand code; rather than clipping x/y, clip magnitude so that
points will go to edge of board and 'stick' there, not slide to the corners.
Modified: trunk/planarity/gameboard_logic.c
===================================================================
--- trunk/planarity/gameboard_logic.c 2005-10-03 06:06:08 UTC (rev 10114)
+++ trunk/planarity/gameboard_logic.c 2005-10-03 06:51:10 UTC (rev 10115)
@@ -99,17 +99,46 @@
while(v){
if(!sel || v->selected){
- int nx = rint((v->x - x)*scale+x);
- int ny = rint((v->y - y)*scale+y);
-
- if(nx<0)nx=0;
- if(nx>=g->g.width)nx=g->g.width-1;
- if(ny<0)ny=0;
- if(ny>=g->g.height)ny=g->g.height-1;
+ float nx = (v->x - x)*scale+x;
+ float ny = (v->y - y)*scale+y;
+ if(nx<0 || nx>=g->g.width ||
+ ny<0 || ny>=g->g.height){
+
+ float mag = hypot(nx-x,ny-y);
+ if(mag){
+ float ang = acos((nx-x) / mag);
+ if(ny-y>0) ang = 2*M_PI-ang;
+
+ if(nx<0){
+ mag *= -x/(nx-x);
+ nx = cos(ang)*mag+x;
+ ny = -sin(ang)*mag+y;
+ }
+
+ if(nx>=g->g.width){
+ mag *= (g->g.width-x-1)/(nx-x);
+ nx = cos(ang)*mag+x;
+ ny = -sin(ang)*mag+y;
+ }
+
+ if(ny<0){
+ mag *= -y/(ny-y);
+ nx = cos(ang)*mag+x;
+ ny = -sin(ang)*mag+y;
+ }
+
+ if(ny>=g->g.height){
+ mag *= (g->g.height-y-1)/(ny-y);
+ nx = cos(ang)*mag+x;
+ ny = -sin(ang)*mag+y;
+ }
+ }
+ }
+
deactivate_vertex(&g->g,v);
- v->x = nx;
- v->y = ny;
+ v->x = rint(nx);
+ v->y = rint(ny);
}
v=v->next;
}
Modified: trunk/planarity/graph_generate.c
===================================================================
--- trunk/planarity/graph_generate.c 2005-10-03 06:06:08 UTC (rev 10114)
+++ trunk/planarity/graph_generate.c 2005-10-03 06:51:10 UTC (rev 10115)
@@ -62,22 +62,18 @@
{"free", 4, "Something Only Subtly Different", generate_freeform, 1.5,1., 3 }, // 14
{"free", 5, "It Can Roll! Granted, Not Very Well", generate_freeform, 1.5,1., 3 }, // 15
- {"free", 6, "If you squint, It's a Rounded Brick", generate_freeform, 1.5,1., 3 }, // 16
+ {"free", 6, "If You Squint, It's a Round Brick", generate_freeform, 1.5,1., 3 }, // 16
{"rogue", 5, "A New Objective", generate_rogue, 1.6,1., 3 }, // 17
{"rogue", 6, "How Low Can You Go?", generate_rogue, 1.6,1., 3 }, // 18
{"rogue", 7, "Industrial Military Complex", generate_rogue, 1.6,1., 4 }, // 19
- {"embed", 4, "The Hexagon is a Subtle And Wily Beast", generate_embed, 2.,1., 4 }, // 20
+ {"embed", 4, "The Hexagon is a Subtle and Wily Beast", generate_embed, 2.,1., 4 }, // 20
{"embed", 5, "No, Really, The Hexagon Puzzles Are Harder", generate_embed, 3.,1., 5 }, // 21
{"embed", 6, "Cursed? Call 1-800-HEX-A-GON Today!", generate_embed, 4.,1., 6 }, // 22
{"simple", 7, "Round but Straightforward", generate_simple, 1.,1., 4 }, // 23
-
-
-
- //{"meshS",10, "Tough and Stringy", generate_mesh_1S, 2.,1., 3 }, // 8
//{"cloud", 9, "More of a Mess Than Usual", generate_mesh_1_cloud, 2.,1., 3 }, // 9
};
Modified: trunk/planarity/version.h
===================================================================
--- trunk/planarity/version.h 2005-10-03 06:06:08 UTC (rev 10114)
+++ trunk/planarity/version.h 2005-10-03 06:51:10 UTC (rev 10115)
@@ -1,2 +1,2 @@
#define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Mon Oct 3 02:00:36 EDT 2005] */
+/* DO NOT EDIT: Automated versioning hack [Mon Oct 3 02:49:41 EDT 2005] */
More information about the commits
mailing list