void sC() { dash(); dot(); dash(); dot(); cBreak(); }
void sJ() { dot(); dash(); dash(); dash(); cBreak(); }
void sP() { dot(); dash(); dash(); dot(); cBreak(); }
void o(void) { dash(); dash(); dash(); delay_ms(LETTERSPACE); }
void O() { dash(); beep(200,100); space(1); dash(); beep(200,100); space(1); dash(); beep(200,100); space(3); }
void Morse::emitWord(String word) { int len = word.length(); int i, ci; for (i = 0; i < len; i++) { String code = textToMorse(word.charAt(i)); int codeLen = code.length(); for (ci = 0; ci < codeLen; ci++) { if (code[ci] == '.') { dot(); } else { dash(); } } // morse code states there should be a 3 time unit pause between // characters // 2 here and one at the end of dot/dash delay(_timeUnit * 2); } // morse code states there should be a 7 time unit pause between words // 4 here and 3 above delay(_timeUnit * 4); }
std::vector< std::vector<double> > readIn2dData(const char* filename) { std::vector< std::vector<double> > table; std::fstream ifs; ifs.open(filename); while (true) { std::string line; std::string dash ("--"); double buf; getline(ifs, line); std::stringstream ss(line, std::ios_base::out|std::ios_base::in|std::ios_base::binary); if (!ifs) break; if (line[0] == '#' || line.empty() || line == "--" ) continue; std::vector<double> row; while (ss >> buf){ row.push_back(buf); } table.push_back(row); } ifs.close(); return table; }
void TargetPhrase::SetAlignmentInfo(const StringPiece &alignString) { AlignmentInfo::CollType alignTerm, alignNonTerm; for (util::TokenIter<util::AnyCharacter, true> token(alignString, util::AnyCharacter(" \t")); token; ++token) { util::TokenIter<util::SingleCharacter, false> dash(*token, util::SingleCharacter('-')); char *endptr; size_t sourcePos = strtoul(dash->data(), &endptr, 10); UTIL_THROW_IF(endptr != dash->data() + dash->size(), util::ErrnoException, "Error parsing alignment" << *dash); ++dash; size_t targetPos = strtoul(dash->data(), &endptr, 10); UTIL_THROW_IF(endptr != dash->data() + dash->size(), util::ErrnoException, "Error parsing alignment" << *dash); UTIL_THROW_IF(++dash, util::Exception, "Extra gunk in alignment " << *token); if (GetWord(targetPos).IsNonTerminal()) { alignNonTerm.insert(std::pair<size_t,size_t>(sourcePos, targetPos)); } else { alignTerm.insert(std::pair<size_t,size_t>(sourcePos, targetPos)); } } SetAlignTerm(alignTerm); SetAlignNonTerm(alignNonTerm); }
/* proceed one character per cycle */ static inline void loop() { byte encodedChar; byte charNumSymbols; /* read next char */ char messageChar = message[messageIdx]; /* handle special cases and validate input */ if (messageChar == ' ') { /* space */ delay(wordSpaceLength_ms - charSpaceLength_ms - blinkSpaceLength_ms); advanceChar(); return; } else if (messageChar < '0' || (messageChar > '9' && messageChar < 'A') || messageChar > 'Z') { /* Invalid char! Skip. */ advanceChar(); return; } /* unpack current character encoding */ encodedChar = morseEncoding[messageChar - '0']; charNumSymbols = encodedChar >> 5; /* top three bits */ /* iterate over symbols in char frorm right to left */ while (charNumSymbols--) { if (encodedChar & 1) dash(); else dot(); delay(blinkSpaceLength_ms); encodedChar >>= 1; } /* terminate char */ delay(charSpaceLength_ms - blinkSpaceLength_ms); advanceChar(); }
// **************************************************************************** void MolDraw2DSVG::drawLine(const Point2D &cds1, const Point2D &cds2) { Point2D c1 = getDrawCoords(cds1); Point2D c2 = getDrawCoords(cds2); std::string col = DrawColourToSVG(colour()); unsigned int width = lineWidth(); std::string dashString = ""; const DashPattern &dashes = dash(); if (dashes.size()) { std::stringstream dss; dss << ";stroke-dasharray:"; std::copy(dashes.begin(), dashes.end() - 1, std::ostream_iterator<unsigned int>(dss, ",")); dss << dashes.back(); dashString = dss.str(); } d_os << "<path "; if (d_activeClass != "") { d_os << "class='" << d_activeClass << "' "; } d_os << "d='M " << c1.x << "," << c1.y << " " << c2.x << "," << c2.y << "' "; d_os << "style='fill:none;fill-rule:evenodd;stroke:" << col << ";stroke-width:" << width << "px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" << dashString << "'"; d_os << " />\n"; }
void sB() { dash(); dot(); dot(); dot(); cBreak(); }
virtual void onDrawContent(SkCanvas* canvas) { SkScalar intervals[8] = { .5f, .3f, .5f, .3f, .5f, .3f, .5f, .3f }; SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, fPhase)); SkAutoTUnref<SkCornerPathEffect> corner(SkCornerPathEffect::Create(.25f)); SkAutoTUnref<SkComposePathEffect> compose(SkComposePathEffect::Create(dash, corner)); SkPaint outlinePaint; outlinePaint.setAntiAlias(true); // dashed paint for bitmap outlinePaint.setStyle(SkPaint::kStroke_Style); outlinePaint.setPathEffect(compose); canvas->scale(10.0f, 10.0f); // scales up for (int i = 0; i < fNumBits; ++i) { canvas->save(); for (size_t j = 0; j < SK_ARRAY_COUNT(gBitsToPath_fns); ++j) { SkPath path; gBitsToPath_fns[j](&path, (char*) &gBits[i], fW, fH, fRowBytes); //draw skPath and outline canvas->drawPath(path, fBmpPaint); canvas->translate(1.5f * fW, 0); // translates past previous bitmap canvas->drawPath(path, outlinePaint); canvas->translate(1.5f * fW, 0); // translates past previous bitmap } canvas->restore(); canvas->translate(0, 1.5f * fH); //translate to next row } // for animated pathEffect fPhase += .01f; this->inval(NULL); }
int DoTurnKickCommand(TurnKickCommand com) { if (com.time != Mem->CurrentTime) { my_error("DoTurnKickCommand- told to do command not set this cycle"); return 0; } switch (com.type) { case CMD_none: break; case CMD_dash: DebugKick(printf("DoTurnKickCommand: dash\n")); dash(com.power); break; case CMD_turn: DebugKick(printf("DoTurnKickCommand: turn\n")); turn(com.angle); break; case CMD_kick: DebugKick(printf("DoTurnKickCommand: kick\n")); kick(com.power, com.angle); break; default: my_error("DoTurnKickCommand- unimplemented type!"); return 0; } if (com.turn_neck) { turn_neck(com.turn_neck_angle); } return 1; }
virtual void onDrawContent(SkCanvas* canvas) { static const char* gStr[] = { "11", "44", "112233", "411327463524", }; SkPaint paint; paint.setStrokeWidth(SkIntToScalar(1)); SkScalar x0 = SkIntToScalar(10); SkScalar y0 = SkIntToScalar(10); SkScalar x1 = x0 + SkIntToScalar(1000); for (size_t i = 0; i < SK_ARRAY_COUNT(gStr); i++) { SkScalar interval[12]; size_t len = SkMin32(strlen(gStr[i]), SK_ARRAY_COUNT(interval)); for (size_t j = 0; j < len; j++) { interval[j] = SkIntToScalar(gStr[i][j] - '0'); } SkDashPathEffect dash(interval, len, 0); paint.setPathEffect(&dash); canvas->drawLine(x0, y0, x1, y0, paint); paint.setPathEffect(NULL); y0 += paint.getStrokeWidth() * 3; } setBitmapDash(&paint, 3); canvas->drawLine(x0, y0, x1, y0, paint); }
int main(int argc, char ** argv) { char * string = argv[1]; char * morse_string; int current_char; wiringPiSetup () ; pinMode (OUTPUT_PIN, OUTPUT) ; puts(string); while(*string) { current_char = (*string | 32) - 'a'; if (current_char >= 0 && current_char < 26) { morse_string = conversion_map[current_char]; while(*morse_string) { if (*morse_string == '.') { dot(); } else if (*morse_string == '-') { dash(); } morse_string++; } } delay(CHAR_DELAY); string++; } return 0; }
static void validateTopicName(const QString& topic) { if (topic.isEmpty()) { throw std::invalid_argument("empty topic"); } // Can't start or end with a '/' but anywhere else is okay // Can't have "//" as that implies empty token if (topic.startsWith("/") || topic.endsWith("/") || topic.contains("//")) { throw std::invalid_argument(QString("invalid topic: %1").arg(topic).toStdString()); } QString::const_iterator topicEnd = topic.end(); QChar A('A'), Z('Z'), a('a'), z('z'), zero('0'), nine('9'); QChar dash('-'), slash('/'), underscore('_'); for (QString::const_iterator i = topic.begin(); i < topicEnd; ++i) { QChar c(*i); if ((A <= c) && (c <= Z)) continue; if ((a <= c) && (c <= z)) continue; if ((zero <= c) && (c <= nine)) continue; if ((c == underscore) || (c == dash) || (c == slash)) continue; throw std::invalid_argument(QString("invalid topic: %1").arg(topic).toStdString()); } }
DEF_TEST(DashPathEffectTest_crbug_348821, r) { SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f }; // Values from bug. const int count = 2; SkScalar phase = SK_ScalarInfinity; // Used to force a nonsense effect. sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, count, phase)); REPORTER_ASSERT(r, dash == nullptr); }
// Test out the asPoint culling behavior. DEF_TEST(DashPathEffectTest_asPoints, r) { const SkScalar intervals[] = { 1.0f, 1.0f }; const int count = 2; SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, count, 0.0f)); SkRect cull = SkRect::MakeWH(1.0f, 1.0f); const struct { SkPoint fPts[2]; bool fExpectedResult; } testCases[] = { { { { -5.0f, 0.5f }, { -4.0f, 0.5f } }, false }, // off to the left { { { 4.0f, 0.5f }, { 5.0f, 0.5f } }, false }, // off to the right { { { 0.5f, 4.0f }, { 0.5f, 5.0f } }, false }, // off the bottom { { { 0.5f, -5.0f }, { 0.5f, -4.0f } }, false }, // off the top { { { 0.5f, 0.2f }, { 0.5f, 0.8f } }, true }, // entirely inside vertical { { { 0.2f, 0.5f }, { 0.8f, 0.5f } }, true }, // entirely inside horizontal { { { 0.5f, -5.0f }, { 0.5f, 5.0f } }, true }, // straddles both sides vertically { { { -5.0f, 0.5f }, { 5.0f, 0.5f } }, true }, // straddles both sides horizontally { { { 0.5f, -5.0f }, { 0.5f, 0.5f } }, true }, // straddles top { { { 0.5f, 5.0f }, { 0.5f, 0.5f } }, true }, // straddles bottom { { { -5.0f, 0.5f }, { 0.5f, 0.5f } }, true }, // straddles left { { { 5.0f, 0.5f }, { 0.5f, 0.5f } }, true }, // straddles right { { { 0.5f, 0.5f }, { 0.5f, 0.5f } }, false }, // zero length }; SkPaint paint; paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(1.0f); SkStrokeRec rec(paint); static const int kNumMats = 3; SkMatrix mats[kNumMats]; mats[0].reset(); mats[1].setRotate(90, 0.5f, 0.5f); mats[2].setTranslate(10.0f, 10.0f); for (int i = 0; i < kNumMats; ++i) { for (int j = 0; j < (int)SK_ARRAY_COUNT(testCases); ++j) { for (int k = 0; k < 2; ++k) { // exercise alternating endpoints SkPathEffect::PointData results; SkPath src; src.moveTo(testCases[j].fPts[k]); src.lineTo(testCases[j].fPts[(k+1)%2]); bool actualResult = dash->asPoints(&results, src, rec, mats[i], &cull); if (i < 2) { REPORTER_ASSERT(r, actualResult == testCases[j].fExpectedResult); } else { // On the third pass all the lines should be outside the translated cull rect REPORTER_ASSERT(r, !actualResult); } } } } }
static void test_crbug_124652() { /* http://code.google.com/p/chromium/issues/detail?id=124652 This particular test/bug only applies to the float case, where large values can "swamp" small ones. */ SkScalar intervals[2] = {837099584, 33450}; SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, -10)); }
/* LITERE */ void A() { dot(); beep(100,25); space(1); dash(); beep(200,100); space(3); }
int agg2RenderLine(imageObj *img, shapeObj *p, strokeStyleObj *style) { AGG2Renderer *r = AGG_RENDERER(img); line_adaptor lines = line_adaptor(p); #ifdef AGG_ALIASED_ENABLED r->m_rasterizer_primitives.reset(); r->m_renderer_primitives.line_color(aggColor(style->color)); r->m_rasterizer_primitives.add_path(lines); return MS_SUCCESS; #endif r->m_rasterizer_aa.reset(); r->m_rasterizer_aa.filling_rule(mapserver::fill_non_zero); r->m_renderer_scanline.color(aggColor(style->color)); if (style->patternlength <= 0) { mapserver::conv_stroke<line_adaptor> stroke(lines); stroke.width(style->width); if(style->width>1) { applyCJC(stroke, style->linecap, style->linejoin); } else { stroke.inner_join(mapserver::inner_bevel); stroke.line_join(mapserver::bevel_join); } r->m_rasterizer_aa.add_path(stroke); } else { mapserver::conv_dash<line_adaptor> dash(lines); mapserver::conv_stroke<mapserver::conv_dash<line_adaptor> > stroke_dash(dash); int patt_length = 0; for (int i = 0; i < style->patternlength; i += 2) { if (i < style->patternlength - 1) { dash.add_dash(MS_MAX(1,MS_NINT(style->pattern[i])), MS_MAX(1,MS_NINT(style->pattern[i + 1]))); if(style->patternoffset) { patt_length += MS_MAX(1,MS_NINT(style->pattern[i])) + MS_MAX(1,MS_NINT(style->pattern[i + 1])); } } } if(style->patternoffset > 0) { dash.dash_start(patt_length - style->patternoffset); } stroke_dash.width(style->width); if(style->width>1) { applyCJC(stroke_dash, style->linecap, style->linejoin); } else { stroke_dash.inner_join(mapserver::inner_bevel); stroke_dash.line_join(mapserver::bevel_join); } r->m_rasterizer_aa.add_path(stroke_dash); } mapserver::render_scanlines(r->m_rasterizer_aa, r->sl_line, r->m_renderer_scanline); return MS_SUCCESS; }
int msHatchPolygon(imageObj *img, shapeObj *poly, double spacing, double width, double *pattern, int patternlength, double angle, colorObj *color) { assert(MS_RENDERER_PLUGIN(img->format)); msComputeBounds(poly); /* amount we should expand the bounding box by */ double exp = width * 0.7072; /* width and height of the bounding box we will be creating the hatch in */ int pw=(int)(poly->bounds.maxx-poly->bounds.minx+exp*2)+1; int ph=(int)(poly->bounds.maxy-poly->bounds.miny+exp*2)+1; /* position of the top-left corner of the bounding box */ double ox = poly->bounds.minx - exp; double oy = poly->bounds.miny - exp; //create a rectangular hatch of size pw,ph starting at 0,0 //the created hatch is of the size of the shape's bounding box mapserver::path_storage hatch = createHatch(ox,oy, img->refpt.x,img->refpt.y,pw,ph,angle,spacing); if(hatch.total_vertices()<=0) return MS_SUCCESS; //translate the hatch so it overlaps the current shape hatch.transform(mapserver::trans_affine_translation(ox,oy)); polygon_adaptor polygons(poly); if(patternlength>1) { //dash the hatch and render it clipped by the shape mapserver::conv_dash<mapserver::path_storage > dash(hatch); mapserver::conv_stroke<mapserver::conv_dash<mapserver::path_storage> > stroke(dash); for (int i=0; i<patternlength; i+=2) { if (i < patternlength-1) { dash.add_dash(pattern[i], pattern[i+1]); } } stroke.width(width); stroke.line_cap(mapserver::butt_cap); mapserver::conv_clipper<polygon_adaptor,mapserver::conv_stroke<mapserver::conv_dash<mapserver::path_storage> > > clipper(polygons,stroke, mapserver::clipper_and); renderPolygonHatches(img,clipper,color); } else { //render the hatch clipped by the shape mapserver::conv_stroke <mapserver::path_storage > stroke(hatch); stroke.width(width); stroke.line_cap(mapserver::butt_cap); mapserver::conv_clipper<polygon_adaptor,mapserver::conv_stroke<mapserver::path_storage> > clipper(polygons,stroke, mapserver::clipper_and); renderPolygonHatches(img,clipper,color); } //assert(prevCmd == mapserver::path_cmd_line_to); //delete lines; return MS_SUCCESS; }
void dashApp(Bool sh, App* app) { Int i; if (app->tag >= INVALID) error("dashApp(): invalid tag.\n"); for (i = 0; i < app->size; i++) app->atoms[i] = dash(sh, app->atoms[i]); }
void GraphicsMultiLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->setPen(pen()); for (auto line : lines) painter->drawLine(line); if (isSelected()) { QPen dash(Qt::black, 1, Qt::DashLine); painter->setPen(dash); painter->drawRect(boundingRect()); } }
static void test_crbug_124652(skiatest::Reporter* reporter) { #ifdef SK_SCALAR_IS_FLOAT /* http://code.google.com/p/chromium/issues/detail?id=124652 This particular test/bug only applies to the float case, where large values can "swamp" small ones. */ SkScalar intervals[2] = {837099584, 33450}; SkAutoTUnref<SkDashPathEffect> dash( new SkDashPathEffect(intervals, 2, -10, false)); #endif }
void letter(char a) { int i; //int idx = a-'a'; int idx = a; struct letter l = alphabet[idx]; printf("%c: ", a); for (i = 0; i < l.n; ++i) { if (l.a[i] == '.') dot(); else dash(); } printf("\n"); }
void upd(Atom top, Int sp, Int len, Int hp) { Int i, j; heap[hp].tag = AP; heap[hp].details.normalForm = 1; heap[hp].size = len; heap[hp].atoms[0] = top; for (i = 1, j = sp; i < len; i++, j--) { Atom a = dash(1, stack[j]); heap[hp].atoms[i] = a; stack[j] = a; } }
DEF_TEST(DashPathEffectTest_crbug_348821, r) { SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f }; // Values from bug. const int count = 2; SkScalar phase = SK_ScalarInfinity; // Used to force the bad fInitialDashLength = -1 path. SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, count, phase)); // nullptr -> refuses to work with flattening framework. REPORTER_ASSERT(r, dash->getFactory() != nullptr); SkWriteBuffer buffer; buffer.writeFlattenable(dash); REPORTER_ASSERT(r, buffer.bytesWritten() > 12); // We'd write 12 if broken, >=40 if not. }
void PrintLogo(void) { FIFO f; OS_InitSem(S_LOGO,1); f = OS_InitFiFo(); /* Print JoelOS in a convoluted way. */ OS_Wait(S_LOGO); OS_Create(WriteA, (int)f, PERIODIC, 10); OS_Create(Write1, (int)f, PERIODIC, 20); OS_Create(PrintFIFO, (int)f, PERIODIC, 30); /* Buzz SOS */ dot(); dot(); dot(); dash(); dash(); dash(); dot(); dot(); dot(); OS_Signal(S_BUZZ_OUTPUT); }
void TargetPhrase::SetAlignmentInfo(const StringPiece &alignString) { set<pair<size_t,size_t> > alignmentInfo; for (util::TokenIter<util::AnyCharacter, true> token(alignString, util::AnyCharacter(" \t")); token; ++token) { util::TokenIter<util::AnyCharacter, false> dash(*token, util::AnyCharacter("-")); MosesShouldUseExceptions(dash); size_t sourcePos = boost::lexical_cast<size_t>(*dash++); MosesShouldUseExceptions(dash); size_t targetPos = boost::lexical_cast<size_t>(*dash++); MosesShouldUseExceptions(!dash); alignmentInfo.insert(pair<size_t,size_t>(sourcePos, targetPos)); } SetAlignmentInfo(alignmentInfo); }