1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-23 20:53:21 +02:00

sch2fig/ (rx, ry): consolidate into misc.c (integer version)

This commit is contained in:
Werner Almesberger 2016-07-29 22:13:07 -03:00
parent 626cae2210
commit b8ec957471
4 changed files with 40 additions and 56 deletions

View File

@ -17,6 +17,7 @@
#include <assert.h>
#include "util.h"
#include "misc.h"
#include "style.h"
#include "text.h"
#include "fig.h"
@ -286,45 +287,6 @@ static int make_box(enum box_type box, int h, int *vx, int *vy)
}
/* @@@ rx, ry are from text.c; should go to misc.h or misc.c */
static int rx(int x, int y, int rot)
{
switch (rot) {
case 0:
return x;
case 90:
return y;
case 180:
return -x;
case 270:
return -y;
default:
assert(0);
}
}
static int ry(int x, int y, int rot)
{
switch (rot) {
case 0:
return y;
case 90:
return -x;
case 180:
return -y;
case 270:
return x;
default:
assert(0);
}
}
void dwg_hlabel(int x, int y, const char *s, int dir, int dim,
enum fig_shape shape)
{

View File

@ -76,3 +76,39 @@ int angle_add(int a, int b)
return a % 360;
}
int rx(int x, int y, int rot)
{
switch (rot) {
case 0:
return x;
case 90:
return y;
case 180:
return -x;
case 270:
return -y;
default:
assert(0);
}
}
int ry(int x, int y, int rot)
{
switch (rot) {
case 0:
return y;
case 90:
return -x;
case 180:
return -y;
case 270:
return x;
default:
assert(0);
}
}

View File

@ -45,4 +45,7 @@ unsigned matrix_to_angle(int m[6]);
bool matrix_is_mirrored(int m[6]);
int angle_add(int a, int b);
int rx(int x, int y, int rot);
int ry(int x, int y, int rot);
#endif /* !MISC_H */

View File

@ -15,7 +15,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "util.h"
#include "misc.h"
@ -77,22 +76,6 @@ void text_flip_x(struct text *txt)
}
static int rx(int x, int y, int rot)
{
float a = rot / 180.0 * M_PI;
return cos(a) * x + sin(a) * y;
}
static int ry(int x, int y, int rot)
{
float a = rot / 180.0 * M_PI;
return -sin(a) * x + cos(a) * y;
}
static int align(int dim, enum text_align align)
{
switch (align) {