QString KicadSchematic2Svg::convertPoly(const QString & line) { QStringList s = splitLine(line); if (s.count() < 6) { DebugDialog::debug(QString("bad poly %1").arg(line)); return ""; } int np = s[1].toInt(); if (np < 2) { DebugDialog::debug(QString("degenerate poly %1").arg(line)); return ""; } if (s.count() < (np * 2) + 5) { DebugDialog::debug(QString("bad poly (2) %1").arg(line)); return ""; } if (s.count() < (np * 2) + 6) { s.append("N"); // assume unfilled } int ix = 5; if (np == 2) { int x1 = s[ix++].toInt(); int y1 = -s[ix++].toInt(); // KiCad flips y-axis w.r.t. svg int x2 = s[ix++].toInt(); int y2 = -s[ix++].toInt(); // KiCad flips y-axis w.r.t. svg checkXLimit(x1); checkYLimit(y1); checkXLimit(x2); checkYLimit(y2); QString line = QString("<line x1='%1' y1='%2' x2='%3' y2='%4' ").arg(x1).arg(y1).arg(x2).arg(y2); line += addFill(line, s[ix], s[4]); line += " />\n"; return line; } QString poly = "<polyline points='"; for (int i = 0; i < np; i++) { int x = s[ix++].toInt(); int y = -s[ix++].toInt(); // KiCad flips y-axis w.r.t. svg checkXLimit(x); checkYLimit(y); poly += QString("%1,%2,").arg(x).arg(y); } poly.chop(1); poly += "' "; poly += addFill(line, s[ix], s[4]); poly += " />\n"; return poly; }
QString KicadSchematic2Svg::convertCircle(const QString & line) { QStringList s = splitLine(line); if (s.count() < 8) { DebugDialog::debug(QString("bad circle %1").arg(line)); return ""; } int x = s[1].toInt(); int y = -s[2].toInt(); // KiCad flips y-axis w.r.t. svg int r = s[3].toInt(); checkXLimit(x + r); checkXLimit(x - r); checkYLimit(y + r); checkYLimit(y - r); QString circle = QString("<circle cx='%1' cy='%2' r='%3' ") .arg(x) .arg(y) .arg(r); circle += addFill(line, s[7], s[6]); circle += " />\n"; return circle; }
QString KicadSchematic2Svg::convertRect(const QString & line) { QStringList s = splitLine(line); if (s.count() < 8) { DebugDialog::debug(QString("bad rectangle %1").arg(line)); return ""; } if (s.count() < 9) { s.append("N"); // assume it's unfilled } int x = s[1].toInt(); int y = -s[2].toInt(); // KiCad flips y-axis w.r.t. svg int x2 = s[3].toInt(); int y2 = -s[4].toInt(); // KiCad flips y-axis w.r.t. svg checkXLimit(x); checkXLimit(x2); checkYLimit(y); checkYLimit(y2); QString rect = QString("<rect x='%1' y='%2' width='%3' height='%4' ") .arg(qMin(x, x2)) .arg(qMin(y, y2)) .arg(qAbs(x2 - x)) .arg(qAbs(y2 - y)); rect += addFill(line, s[8], s[7]); rect += " />\n"; return rect; }
void InternalProcess::setColor(int _fore, int _back) { // brush.back = vgacol[ mtrans[back] ]; back = _back; fore = _fore; brushback = addFill(back, 0xffffff); int rec = addRecolor(f->ti[32], fore, 0xffffff); brush0 = addMerge(brushback, rec, false); }
static void TCOD_noteye_render() { TCOD_noteye_init(); int sx = TCOD_console_get_width(NULL); int sy = TCOD_console_get_height(NULL); scr->setSize(sx, sy); char_t *buffer = tbuffer; for(int y=0; y<sy; y++) for(int x=0; x<sx; x++) { scr->get(x,y) = addMerge( // addFill(0), addRecolor(fnt->ti[buffer->c], 0xFFFFFF) addFill(noteyecolor(buffer->back), 0xFFFFFF), addRecolor(ourfont[buffer->c], noteyecolor(buffer->fore), recDefault), false ); buffer++; } lastframe = SDL_GetTicks(); }
QString KicadSchematic2Svg::convertArc(const QString & line) { QStringList s = splitLine(line); if (s.count() == 9) { s.append("N"); // assume unfilled } bool calcPoints = false; if (s.count() == 10) { s.append("N"); s.append("N"); s.append("N"); s.append("N"); calcPoints = true; } if (s.count() < 14) { DebugDialog::debug("bad arc " + line); return ""; } int x = s[1].toInt(); int y = -s[2].toInt(); // KiCad flips y-axis w.r.t. svg int r = s[3].toInt(); double startAngle = (s[4].toInt() % 3600) / 10.0; double endAngle = (s[5].toInt() % 3600) / 10.0; double x1 = s[10].toInt(); double y1 = -s[11].toInt(); // KiCad flips y-axis w.r.t. svg double x2 = s[12].toInt(); double y2 = -s[13].toInt(); // KiCad flips y-axis w.r.t. svg if (calcPoints) { x1 = x + (r * cos(startAngle * M_PI / 180.0)); y1 = y - (r * sin(startAngle * M_PI / 180.0)); x2 = x + (r * cos(endAngle * M_PI / 180.0)); y2 = y - (r * sin(endAngle * M_PI / 180.0)); } // kicad arcs will always sweep < 180, kicad uses multiple arcs for > 180 sweeps double diffAngle = endAngle - startAngle; if (diffAngle > 180) diffAngle -= 360; else if (diffAngle < -180) diffAngle += 360; // TODO: use actual bounding box of arc for clipping checkXLimit(x + r); checkXLimit(x - r); checkYLimit(y + r); checkYLimit(y - r); QString arc = QString("<path d='M%1,%2a%3,%4 0 %5,%6 %7,%8' ") .arg(x1) .arg(y1) .arg(r) .arg(r) .arg(qAbs(diffAngle) >= 180 ? 1 : 0) .arg(diffAngle > 0 ? 0 : 1) .arg(x2 - x1) .arg(y2 - y1); arc += addFill(line, s[9], s[8]); arc += " />\n"; return arc; }