Index: work/remote/animator/Makefile =================================================================== --- work/remote/animator/Makefile (revision 5127) +++ work/remote/animator/Makefile (revision 5128) @@ -1,9 +1,9 @@ TRUNK=../../../trunk P=/usr/lib CFLAGS = -Wall -g -I$(TRUNK) -LDLIBS = $P/libporty_net_async.a $P/libporty_net.a $(TRUNK)/src_plugins/hid_remote/base64.o +LDLIBS = -lm $P/libporty_net_async.a $P/libporty_net.a $(TRUNK)/src_plugins/hid_remote/base64.o SPHASH = $(TRUNK)/src_3rd/sphash/sphash -OBJS= hid_anim.o cmds_hash.o compat.o +OBJS= hid_anim.o cmds_hash.o compat.o draw_helper.o hid_anim: $(OBJS) $(CC) $(OBJS) $(LDLIBS) -o $@ Index: work/remote/animator/draw_helper.c =================================================================== --- work/remote/animator/draw_helper.c (nonexistent) +++ work/remote/animator/draw_helper.c (revision 5128) @@ -0,0 +1,46 @@ +#include +#include + +/* draw a line with rounded ends + do not draw end circles if omit_ends is non-zero + extend both ends by length_bloat */ +void draw_rline(double x1, double y1, double x2, double y2, double width, int round_cap) +{ + double nx = y2-y1; + double ny = -1.0 * (x2-x1); + double len=sqrt(nx*nx+ny*ny); + double length_bloat = 0; + + if (len != 0) { + double vx, vy; + nx /= len; + ny /= len; + vx = -ny; + vy = nx; + + if (length_bloat != 0) { + x1 -= length_bloat * vx; + x2 += length_bloat * vx; + y1 -= length_bloat * vy; + y2 += length_bloat * vy; + } + +/* if there are no end circles, we are square and should extend by extra width/2 */ + if (!round_cap) { + x1 -= (width/2) * vx; + x2 += (width/2) * vx; + y1 -= (width/2) * vy; + y2 += (width/2) * vy; + } + + printf("poly %f %f %f %f %f %f %f %f\n", + x1+nx*width/2, y1+ny*width/2, x2+nx*width/2, y2+ny*width/2, + x2-nx*width/2, y2-ny*width/2, x1-nx*width/2, y1-ny*width/2); + } + + if (round_cap) { + printf("fillcircle %f %f %f %f\n", x1, y1, width/2, width/10); + if ((x1 != x2) || (y1 != y2)) + printf("fillcircle %f %f %f %f\n", x2, y2, width/2, width/10); + } +} Index: work/remote/animator/draw_helper.h =================================================================== --- work/remote/animator/draw_helper.h (nonexistent) +++ work/remote/animator/draw_helper.h (revision 5128) @@ -0,0 +1,2 @@ +void draw_rline(double x1, double y1, double x2, double y2, double width, int round_cap); + Index: work/remote/animator/hid_anim.c =================================================================== --- work/remote/animator/hid_anim.c (revision 5127) +++ work/remote/animator/hid_anim.c (revision 5128) @@ -10,6 +10,7 @@ #include "src_plugins/hid_remote/proto_lowparse.h" #include "cmds_hash.h" #include "compat.h" +#include "draw_helper.h" static proto_ctx_t pctx; P_net_socket s_netin, s_netout;