Beispiel #1
0
string
Screen::toString(unsigned int indent) const
{
	string indention = "";
	for( unsigned int i=0; i<indent; i++ ){
		indention = indention + "\t";
	}
	
	stringstream ss;
	ss << indention << toLine() << " ("
	   << "width = " << m_width << " m, "
	   << "height = " << m_height << " m, "
	   << "m_missed = " << m_missed  
	   << ") {\n";
	
	unsigned int cells_hor = m_dots_per_meter * m_width;
	unsigned int cells_ver = m_dots_per_meter * m_height;
	
	for( unsigned int y=0; y<cells_ver; y++ ){
		ss << indention << "\t";
		for( unsigned int x=0; x<cells_hor; x++ ){
			ss << m_pixel[cells_hor * y + x] << " ";		
		}
		ss << "\n";
	}
	ss << indention << "}";	   
	return ss.str();
}
Beispiel #2
0
static PyObject* output_stroke(PyObject* _self, PyObject* args, PyObject* kwargs)
{
    OutputObject* self = (OutputObject*)_self;
    PyObject*_line=0;
    PyObject*_bitmap=0;
    static char *kwlist[] = {"line", "width", "color", NULL};

    PyObject* color=0;

    int a=255,r=0,g=0,b=0;
    float width = 1.0;
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!fO", kwlist, &PyList_Type, &_line, &width, &color))
	return NULL;

    if(!PyArg_ParseTuple(color, "iiii:color",  &a, &r, &g, &b)) {
        return NULL;
    }

    gfxcolor_t c;
    c.r = r; c.g = g; c.b = b; c.a = a;

    gfxline_t*line = toLine(_line);
    if(!line) 
        return 0;

    self->output_device->stroke(self->output_device, line, width, &c, 
            /*TODO*/ gfx_capRound, gfx_joinRound, 0.0);
    gfxline_free(line);
    return PY_NONE;
}
Beispiel #3
0
static PyObject* output_fill(PyObject* _self, PyObject* args, PyObject* kwargs)
{
    OutputObject* self = (OutputObject*)_self;
    PyObject*_line=0;
    PyObject*_bitmap=0;
    static char *kwlist[] = {"line", "color", NULL};

    PyObject* color=0;

    int a=255,r=0,g=0,b=0;
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O", kwlist, &PyList_Type, &_line, &color))
	return NULL;

    if(!PyArg_ParseTuple(color, "iiii:color",  &a, &r, &g, &b)) {
        return NULL;
    }

    gfxcolor_t c;
    c.r = r; c.g = g; c.b = b; c.a = a;

    gfxline_t*line = toLine(_line);
    if(!line) 
        return 0;

    /* TODO */
    gfxmatrix_t m;
    memset(&m, 0, sizeof(gfxmatrix_t));
    m.m00 = m.m11 = 1.0;

    self->output_device->fill(self->output_device, line, &c);
    gfxline_free(line);
    return PY_NONE;
}
Beispiel #4
0
static PyObject* output_fillbitmap(PyObject* _self, PyObject* args, PyObject* kwargs)
{
    OutputObject* self = (OutputObject*)_self;
    PyObject*_line=0;
    PyObject*_bitmap=0;
    static char *kwlist[] = {"line", "bitmap", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O", kwlist, &PyList_Type, &_line, &_bitmap))
	return NULL;

    gfximage_t*image = toImage(_bitmap);
    if(!image)
        return PY_ERROR("invalid image");

    gfxline_t*line = toLine(_line);
    if(!line) 
        return 0;

    /* TODO */
    gfxmatrix_t m;
    memset(&m, 0, sizeof(gfxmatrix_t));
    m.m00 = m.m11 = 1.0;

    self->output_device->fillbitmap(self->output_device, line, image, &m, 0);
    gfxline_free(line);
    return PY_NONE;
}
Beispiel #5
0
void Art_Speaker_meshVocalTract (Art art, Speaker speaker,
	double xi [], double yi [], double xe [], double ye [],
	double xmm [], double ymm [], int closed [])
{
	double f = speaker -> relativeSize * 1e-3;
	double intX [1 + 16], intY [1 + 16], extX [1 + 11], extY [1 + 11], d_angle;
	double xm [40], ym [40];
	int i;

	Art_Speaker_toVocalTract (art, speaker, intX, intY, extX, extY, & bodyX, & bodyY);
	bodyRadius = 20 * f;

	xe [1] = extX [1];   /* Eq. 5.45 */
	ye [1] = extY [1];
	xe [2] = 0.2 * extX [2] + 0.8 * extX [1];
	ye [2] = 0.2 * extY [2] + 0.8 * extY [1];
	xe [3] = 0.6 * extX [2] + 0.4 * extX [1];
	ye [3] = 0.6 * extY [2] + 0.4 * extY [1];
	xe [4] = 0.9 * extX [3] + 0.1 * extX [4];   /* Eq. 5.46 */
	ye [4] = 0.9 * extY [3] + 0.1 * extY [4];
	xe [5] = 0.7 * extX [3] + 0.3 * extX [4];
	ye [5] = 0.7 * extY [3] + 0.3 * extY [4];
	xe [6] = 0.5 * extX [3] + 0.5 * extX [4];
	ye [6] = 0.5 * extY [3] + 0.5 * extY [4];
	xe [7] = 0.3 * extX [3] + 0.7 * extX [4];
	ye [7] = 0.3 * extY [3] + 0.7 * extY [4];
	xe [8] = 0.1 * extX [3] + 0.9 * extX [4];
	ye [8] = 0.1 * extY [3] + 0.9 * extY [4];
	xe [9] = 0.9 * extX [4] + 0.1 * extX [5];
	ye [9] = 0.9 * extY [4] + 0.1 * extY [5];
	xe [10] = 0.7 * extX [4] + 0.3 * extX [5];
	ye [10] = 0.7 * extY [4] + 0.3 * extY [5];
	xe [11] = 0.5 * extX [4] + 0.5 * extX [5];
	ye [11] = 0.5 * extY [4] + 0.5 * extY [5];
	xe [12] = 0.3 * extX [4] + 0.7 * extX [5];
	ye [12] = 0.3 * extY [4] + 0.7 * extY [5];
	xe [13] = 0.1 * extX [4] + 0.9 * extX [5];
	ye [13] = 0.1 * extY [4] + 0.9 * extY [5];
	d_angle = (atan2 (ye [13], xe [13]) - 0.5 * NUMpi) / 6;   /* Eq. 5.47 */
	for (i = 14; i <= 18; i ++) {
		double a = 0.5 * NUMpi + (19 - i) * d_angle;
		xe [i] = speaker -> palate.radius * cos (a);
		ye [i] = speaker -> palate.radius * sin (a);
	}
	xe [19] = 0;
	ye [19] = speaker -> palate.radius;
	xe [20] = 0.25 * extX [7];
	xe [21] = 0.50 * extX [7];
	xe [22] = 0.75 * extX [7];
	for (i = 20; i <= 22; i ++) {
		ye [i] = speaker -> palate.radius * sqrt (1.0 - xe [i] * xe [i] /
			(speaker -> palate.radius * speaker -> palate.radius));
	}
	xe [23] = extX [7];
	ye [23] = extY [7];
	xe [24] = 0.5 * (extX [7] + extX [8]);
	ye [24] = 0.5 * (extY [7] + extY [8]);
	xe [25] = extX [8];
	ye [25] = extY [8];
	xe [26] = 0.25 * extX [11] + 0.75 * extX [9];
	xe [27] = 0.75 * extX [11] + 0.25 * extX [9];
	ye [26] = extY [10];
	ye [27] = 0.5 * (extY [10] + extY [11]);
	for (i = 1; i <= 27; i ++) {   /* Every mesh point. */
		double minimum = 100000;
		int j;
		for (j = 1; j <= 15 - 1; j ++) {   /* Every internal segment. */
			double d = toLine (xe [i], ye [i], intX, intY, j);
			if (d < minimum) minimum = d;
		}
		if ((closed [i] = inside (xe [i], ye [i], intX, intY)) != 0)
			minimum = - minimum;
		if (xe [i] >= 0.0) {   /* Vertical line pieces. */
			xi [i] = xe [i];
			yi [i] = ye [i] - minimum;
		} else if (ye [i] <= 0.0) {   /* Horizontal line pieces. */
			xi [i] = xe [i] + minimum;
			yi [i] = ye [i];
		} else {   /* Radial line pieces, centre = centre of palate arc. */
			double angle = atan2 (ye [i], xe [i]);
			xi [i] = xe [i] - minimum * cos (angle);
			yi [i] = ye [i] - minimum * sin (angle);
		}
	}
	for (i = 1; i <= Art_Speaker_meshCount; i ++) {
		xm [i] = 0.5 * (xe [i] + xi [i]);
		ym [i] = 0.5 * (ye [i] + yi [i]);
	}
	for (i = 2; i <= Art_Speaker_meshCount; i ++) {
		xmm [i] = 0.5 * (xm [i - 1] + xm [i]);
		ymm [i] = 0.5 * (ym [i - 1] + ym [i]);
	}
	xmm [1] = 2 * xm [1] - xmm [2];
	ymm [1] = 2 * ym [1] - ymm [2];
	xmm [Art_Speaker_meshCount + 1] = 2 * xm [Art_Speaker_meshCount]
		- xmm [Art_Speaker_meshCount];
	ymm [Art_Speaker_meshCount + 1] = 2 * ym [Art_Speaker_meshCount]
		- ymm [Art_Speaker_meshCount];
}
Beispiel #6
0
double PointLine::angle(PointLine other)
{
	Line l1 = toLine();
	Line l2 = other.toLine();
	return l1.angle(l2);
}