bool setPen(const GiContext* ctx) { bool changed = !_ctxused[0]; if (ctx && !ctx->isNullLine()) { if (_gictx.getLineColor() != ctx->getLineColor()) { _gictx.setLineColor(ctx->getLineColor()); changed = true; } if (_gictx.getLineWidth() != ctx->getLineWidth()) { _gictx.setLineWidth(ctx->getLineWidth(), ctx->isAutoScale()); changed = true; } if (_gictx.getLineStyle() != ctx->getLineStyle()) { _gictx.setLineStyle(ctx->getLineStyle()); changed = true; } } if (!ctx) ctx = &_gictx; if (!ctx->isNullLine() && changed) { _ctxused[0] = true; GiColor color = ctx->getLineColor(); if (gs()) color = gs()->calcPenColor(color); CGContextSetRGBStrokeColor(getContext(), toFloat(color.r), toFloat(color.g), toFloat(color.b), toFloat(color.a)); float w = ctx->getLineWidth(); w = gs() ? gs()->calcPenWidth(w, ctx->isAutoScale()) : (w < 0 ? -w : 1); CGContextSetLineWidth(getContext(), _fast && w > 1 ? w - 1 : w); // 不是反走样就细一点 int style = ctx->getLineStyle(); CGFloat pattern[6]; if (style >= 0 && style < sizeof(lpats)/sizeof(lpats[0])) { if (lpats[style].arr && !_fast) { // 快速画时不要线型 makeLinePattern(pattern, lpats[style].arr, lpats[style].n, w); CGContextSetLineDash(getContext(), 0, pattern, lpats[style].n); } else { CGContextSetLineDash(getContext(), 0, NULL, 0); } CGContextSetLineCap(getContext(), style > 0 ? kCGLineCapButt : kCGLineCapRound); } } return !ctx->isNullLine(); }
static void quartzgen_path(GVJ_t *job, int filled) { CGContextRef context = (CGContextRef)job->context; /* set up colors */ if (filled) CGContextSetRGBFillColor(context, job->obj->fillcolor.u.RGBA [0], job->obj->fillcolor.u.RGBA [1], job->obj->fillcolor.u.RGBA [2], job->obj->fillcolor.u.RGBA [3]); CGContextSetRGBStrokeColor(context, job->obj->pencolor.u.RGBA [0], job->obj->pencolor.u.RGBA [1], job->obj->pencolor.u.RGBA [2], job->obj->pencolor.u.RGBA [3]); /* set up line style */ const CGFloat *segments; size_t segment_count; switch (job->obj->pen) { case PEN_DASHED: segments = dashed; segment_count = sizeof(dashed)/sizeof(CGFloat); break; case PEN_DOTTED: segments = dotted; segment_count = sizeof(dotted)/sizeof(CGFloat); break; default: segments = NULL; segment_count = 0; break; } CGContextSetLineDash(context, 0.0, segments, segment_count); /* set up line width */ CGContextSetLineWidth(context, job->obj->penwidth); // *job->scale.x); /* draw the path */ CGContextDrawPath(context, filled ? kCGPathFillStroke : kCGPathStroke); }
static void quartzPrepareLine (GraphicsScreen me) { CGContextSetLineJoin (my d_macGraphicsContext, kCGLineJoinRound); if (my duringXor) { CGContextSetBlendMode (my d_macGraphicsContext, kCGBlendModeDifference); CGContextSetAllowsAntialiasing (my d_macGraphicsContext, false); CGContextSetRGBStrokeColor (my d_macGraphicsContext, 1.0, 1.0, 1.0, 1.0); } else { CGContextSetRGBStrokeColor (my d_macGraphicsContext, my d_macColour.red / 65536.0, my d_macColour.green / 65536.0, my d_macColour.blue / 65536.0, 1.0); } double lineWidth_pixels = LINE_WIDTH_IN_PIXELS (me); CGContextSetLineWidth (my d_macGraphicsContext, lineWidth_pixels); CGFloat lengths [4]; if (my lineType == Graphics_DOTTED) lengths [0] = my resolution > 192 ? my resolution / 100.0 : 2, lengths [1] = my resolution > 192 ? my resolution / 75.0 + lineWidth_pixels : 2; if (my lineType == Graphics_DASHED) lengths [0] = my resolution > 192 ? my resolution / 25 : 6, lengths [1] = my resolution > 192 ? my resolution / 50.0 + lineWidth_pixels : 2; if (my lineType == Graphics_DASHED_DOTTED) lengths [0] = my resolution > 192 ? my resolution / 25 : 6, lengths [1] = my resolution > 192 ? my resolution / 50.0 + lineWidth_pixels : 2; lengths [2] = my resolution > 192 ? my resolution / 100.0 : 2; lengths [3] = my resolution > 192 ? my resolution / 50.0 + lineWidth_pixels : 2; CGContextSetLineDash (my d_macGraphicsContext, 0.0, my lineType == Graphics_DRAWN ? NULL : lengths, my lineType == 0 ? 0 : my lineType == Graphics_DASHED_DOTTED ? 4 : 2); }
//----------------------------------------------------------------------------- void CGDrawContext::applyLineStyle (CGContextRef context) { switch (currentState.lineStyle.getLineCap ()) { case CLineStyle::kLineCapButt: CGContextSetLineCap (context, kCGLineCapButt); break; case CLineStyle::kLineCapRound: CGContextSetLineCap (context, kCGLineCapRound); break; case CLineStyle::kLineCapSquare: CGContextSetLineCap (context, kCGLineCapSquare); break; } switch (currentState.lineStyle.getLineJoin ()) { case CLineStyle::kLineJoinMiter: CGContextSetLineJoin (context, kCGLineJoinMiter); break; case CLineStyle::kLineJoinRound: CGContextSetLineJoin (context, kCGLineJoinRound); break; case CLineStyle::kLineJoinBevel: CGContextSetLineJoin (context, kCGLineJoinBevel); break; } if (currentState.lineStyle.getDashCount () > 0) { CGFloat* dashLengths = new CGFloat [currentState.lineStyle.getDashCount ()]; for (int32_t i = 0; i < currentState.lineStyle.getDashCount (); i++) { dashLengths[i] = currentState.frameWidth * currentState.lineStyle.getDashLengths ()[i]; } CGContextSetLineDash (context, currentState.lineStyle.getDashPhase (), dashLengths, currentState.lineStyle.getDashCount ()); delete [] dashLengths; } }
void CGContextSetLineDash_wrap(CGContext* con, float phase, objVectorOop lengthsOop, void *FH ) { ResourceMark rm; uint32 count; float* lengths; if (convertFloatObjVector( lengthsOop, "CGContextSetLineDash", FH, lengths, count)) CGContextSetLineDash( con, phase, lengths, count); }
void NAContextSetLineDash(const CGContextRef aContext, const NADashingStyle dashStyle) { switch (dashStyle) { case kDashingSolid: CGContextSetLineDash(aContext, 0., NULL, 0); break; case kDashingDotted: CGContextSetLineDash(aContext, 0., kStyleDot, 2); break; case kDashingDashed: CGContextSetLineDash(aContext, 0., kStyleDash, 2); break; case kDashingDashDotted: CGContextSetLineDash(aContext, 0., kStyleDot, 4); break; default: break; } }
static void Quartz_SetLineDash(int newlty, double lwd, NewDevDesc *dd) { QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific; float dashlist[8]; int i, ndash = 0; lwd *= 0.75; /* kludge from postscript/pdf */ for(i = 0; i < 8 && newlty & 15 ; i++) { dashlist[ndash++] = (lwd >= 1 ? lwd: 1) * (newlty & 15); newlty = newlty >> 4; } CGContextSetLineDash( GetContext(xd), 0, dashlist, ndash); xd->lineType = newlty; }
// --------------------------------------------------------------------------- // // ----------- void bToolPrintArea::update(bool global){ if(!global){ clearTempPathContext(false); } if(_draw||get_on_drag()){ ivx_rect vxr=*(_gapp->printMgr()->get_print_area()); if(ivr_ok(&vxr)){ CGContextRef ctx=getTempPathContext(); if(ctx){ CGFloat dsh[2]={5,5}; CGContextSaveGState(ctx); CGContextSetLineDash(ctx,0,dsh,2); hilite_rect(ctx,ivr2cgr(_gapp,vxr),false,true); CGContextRestoreGState(ctx); } } } if(!global){ validTempPathContext(); } }
void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) { CGContextSetLineDash(platformContext(), dashOffset, dashes.data(), dashes.size()); }
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan) { if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f) return; CGContextRef context = platformContext(); CGContextSaveGState(context); CGContextBeginPath(context); CGContextSetShouldAntialias(context, false); int x = rect.x(); int y = rect.y(); float w = (float)rect.width(); float h = (float)rect.height(); float scaleFactor = h / w; float reverseScaleFactor = w / h; if (w != h) scale(FloatSize(1, scaleFactor)); float hRadius = w / 2; float vRadius = h / 2; float fa = startAngle; float falen = fa + angleSpan; float start = -fa * piFloat / 180.0f; float end = -falen * piFloat / 180.0f; CGContextAddArc(context, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, start, end, true); if (w != h) scale(FloatSize(1, reverseScaleFactor)); float width = strokeThickness(); int patWidth = 0; switch (strokeStyle()) { case DottedStroke: patWidth = (int)(width / 2); break; case DashedStroke: patWidth = 3 * (int)(width / 2); break; default: break; } if (patWidth) { // Example: 80 pixels with a width of 30 pixels. // Remainder is 20. The maximum pixels of line we could paint // will be 50 pixels. int distance; if (hRadius == vRadius) distance = static_cast<int>((piFloat * hRadius) / 2.0f); else // We are elliptical and will have to estimate the distance distance = static_cast<int>((piFloat * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.0f)) / 2.0f); int remainder = distance % patWidth; int coverage = distance - remainder; int numSegments = coverage / patWidth; float patternOffset = 0.0f; // Special case 1px dotted borders for speed. if (patWidth == 1) patternOffset = 1.0f; else { bool evenNumberOfSegments = !(numSegments % 2); if (remainder) evenNumberOfSegments = !evenNumberOfSegments; if (evenNumberOfSegments) { if (remainder) { patternOffset += patWidth - remainder; patternOffset += remainder / 2.0f; } else patternOffset = patWidth / 2.0f; } else { if (remainder) patternOffset = (patWidth - remainder) / 2.0f; } } const CGFloat dottedLine[2] = { patWidth, patWidth }; CGContextSetLineDash(context, patternOffset, dottedLine, 2); } CGContextStrokePath(context); CGContextRestoreGState(context); }
// This is only used to draw borders. void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) { if (paintingDisabled()) return; if (strokeStyle() == NoStroke) return; float width = strokeThickness(); FloatPoint p1 = point1; FloatPoint p2 = point2; bool isVerticalLine = (p1.x() == p2.x()); // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic // works out. For example, with a border width of 3, KHTML will pass us (y1+y2)/2, e.g., // (50+53)/2 = 103/2 = 51 when we want 51.5. It is always true that an even width gave // us a perfect position, but an odd width gave us a position that is off by exactly 0.5. if (strokeStyle() == DottedStroke || strokeStyle() == DashedStroke) { if (isVerticalLine) { p1.move(0, width); p2.move(0, -width); } else { p1.move(width, 0); p2.move(-width, 0); } } if (((int)width) % 2) { if (isVerticalLine) { // We're a vertical line. Adjust our x. p1.move(0.5f, 0.0f); p2.move(0.5f, 0.0f); } else { // We're a horizontal line. Adjust our y. p1.move(0.0f, 0.5f); p2.move(0.0f, 0.5f); } } int patWidth = 0; switch (strokeStyle()) { case NoStroke: case SolidStroke: break; case DottedStroke: patWidth = (int)width; break; case DashedStroke: patWidth = 3 * (int)width; break; } CGContextRef context = platformContext(); if (shouldAntialias()) CGContextSetShouldAntialias(context, false); if (patWidth) { CGContextSaveGState(context); // Do a rect fill of our endpoints. This ensures we always have the // appearance of being a border. We then draw the actual dotted/dashed line. setCGFillColor(context, strokeColor(), strokeColorSpace()); // The save/restore make it safe to mutate the fill color here without setting it back to the old color. if (isVerticalLine) { CGContextFillRect(context, FloatRect(p1.x() - width / 2, p1.y() - width, width, width)); CGContextFillRect(context, FloatRect(p2.x() - width / 2, p2.y(), width, width)); } else { CGContextFillRect(context, FloatRect(p1.x() - width, p1.y() - width / 2, width, width)); CGContextFillRect(context, FloatRect(p2.x(), p2.y() - width / 2, width, width)); } // Example: 80 pixels with a width of 30 pixels. // Remainder is 20. The maximum pixels of line we could paint // will be 50 pixels. int distance = (isVerticalLine ? (point2.y() - point1.y()) : (point2.x() - point1.x())) - 2*(int)width; int remainder = distance % patWidth; int coverage = distance - remainder; int numSegments = coverage / patWidth; float patternOffset = 0.0f; // Special case 1px dotted borders for speed. if (patWidth == 1) patternOffset = 1.0f; else { bool evenNumberOfSegments = !(numSegments % 2); if (remainder) evenNumberOfSegments = !evenNumberOfSegments; if (evenNumberOfSegments) { if (remainder) { patternOffset += patWidth - remainder; patternOffset += remainder / 2; } else patternOffset = patWidth / 2; } else { if (remainder) patternOffset = (patWidth - remainder)/2; } } const CGFloat dottedLine[2] = { patWidth, patWidth }; CGContextSetLineDash(context, patternOffset, dottedLine, 2); } CGContextBeginPath(context); CGContextMoveToPoint(context, p1.x(), p1.y()); CGContextAddLineToPoint(context, p2.x(), p2.y()); CGContextStrokePath(context); if (patWidth) CGContextRestoreGState(context); if (shouldAntialias()) CGContextSetShouldAntialias(context, true); }
static void MusicBoxDrawIndicator(HIViewRef view, CGContextRef mboxctx) { if (!showIndicator) return; // Bar const double length[] = { 1.0, 1.0 }; CGContextSetLineWidth(mboxctx, mbxBarWidth); CGContextSetLineDash(mboxctx, 0, length, 2); CGContextSetLineJoin(mboxctx, kCGLineJoinMiter); CGContextBeginPath(mboxctx); double x = mbxOffsetX + mbxMarginX + mbxBarWidth / 2.0; for (int h = 0; h < 8; h++) { // Inactive CGContextSetRGBStrokeColor(mboxctx, (196.0 / 256.0), (200.0 / 256.0), (176.0 / 256.0), 1.0); CGContextMoveToPoint (mboxctx, x, mbxOffsetY + mbxMarginY); CGContextAddLineToPoint(mboxctx, x, mbxOffsetY + mbxMarginY + mbxBarHeight); CGContextMoveToPoint (mboxctx, x + mbxRightBarX, mbxOffsetY + mbxMarginY); CGContextAddLineToPoint(mboxctx, x + mbxRightBarX, mbxOffsetY + mbxMarginY + mbxBarHeight); CGContextStrokePath(mboxctx); // Max Channel *ch = &SoundData.channels[h]; ch->envx = ch->xenvx >> 4; ch-> left_vol_level = (ch->xenvx * ch->volume_left ) >> 11; ch->right_vol_level = (ch->xenvx * ch->volume_right) >> 11; short vl = ch-> left_vol_level; short vr = ch->right_vol_level; long long currentTime; if (vl <= 0) vl = 0; else if (vl > 64) vl = 64; else vl = (short) (yyscale * sqrt((double) vl)) & (~0 << 1); if (vr <= 0) vr = 0; else if (vr > 64) vr = 64; else vr = (short) (yyscale * sqrt((double) vr)) & (~0 << 1); if (vl < prevLVol[h]) vl = ((prevLVol[h] + vl) >> 1); if (vr < prevRVol[h]) vr = ((prevRVol[h] + vr) >> 1); Microseconds((UnsignedWide *) ¤tTime); // left if ((vl >= prevLMax[h]) && (vl > prevLVol[h])) { barTimeL[h] = currentTime; prevLMax[h] = vl; } else if ((prevLMax[h] > 0) && (barTimeL[h] + 1000000 > currentTime)) { CGContextSetRGBStrokeColor(mboxctx, (22.0 / 256.0), (156.0 / 256.0), (20.0 / 256.0), (double) (barTimeL[h] + 1000000 - currentTime) / 1000000.0); CGContextMoveToPoint (mboxctx, x, mbxOffsetY + mbxMarginY + (double) (prevLMax[h] - 2)); CGContextAddLineToPoint(mboxctx, x, mbxOffsetY + mbxMarginY + (double) (prevLMax[h] )); CGContextStrokePath(mboxctx); } else prevLMax[h] = 0; prevLVol[h] = vl; // right if ((vr >= prevRMax[h]) && (vr > prevRVol[h])) { barTimeR[h] = currentTime; prevRMax[h] = vr; } else if ((prevRMax[h] > 0) && (barTimeR[h] + 1000000 > currentTime)) { CGContextSetRGBStrokeColor(mboxctx, (22.0 / 256.0), (156.0 / 256.0), (20.0 / 256.0), (double) (barTimeR[h] + 1000000 - currentTime) / 1000000.0); CGContextMoveToPoint (mboxctx, x + mbxRightBarX, mbxOffsetY + mbxMarginY + (double) (prevRMax[h] - 2)); CGContextAddLineToPoint(mboxctx, x + mbxRightBarX, mbxOffsetY + mbxMarginY + (double) (prevRMax[h] )); CGContextStrokePath(mboxctx); } else prevRMax[h] = 0; prevRVol[h] = vr; // Active CGContextSetRGBStrokeColor(mboxctx, (22.0 / 256.0), (22.0 / 256.0), (20.0 / 256.0), 1.0); CGContextMoveToPoint (mboxctx, x, mbxOffsetY + mbxMarginY); CGContextAddLineToPoint(mboxctx, x, mbxOffsetY + mbxMarginY + (double) vl); CGContextStrokePath(mboxctx); CGContextMoveToPoint (mboxctx, x + mbxRightBarX, mbxOffsetY + mbxMarginY); CGContextAddLineToPoint(mboxctx, x + mbxRightBarX, mbxOffsetY + mbxMarginY + (double) vr); CGContextStrokePath(mboxctx); x += (mbxBarWidth + mbxBarSpace); } }
void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& point, int width, bool grammar) { if (paintingDisabled()) return; // These are the same for misspelling or bad grammar const int patternHeight = 3; // 3 rows ASSERT(cMisspellingLineThickness == patternHeight); const int patternWidth = 4; // 4 pixels ASSERT(patternWidth == cMisspellingLinePatternWidth); // Make sure to draw only complete dots. // NOTE: Code here used to shift the underline to the left and increase the width // to make sure everything gets underlined, but that results in drawing out of // bounds (e.g. when at the edge of a view) and could make it appear that the // space between adjacent misspelled words was underlined. // allow slightly more considering that the pattern ends with a transparent pixel int widthMod = width % patternWidth; if (patternWidth - widthMod > cMisspellingLinePatternGapWidth) width -= widthMod; // Draw the underline CGContextRef context = platformContext(); CGContextSaveGState(context); const Color& patternColor = grammar ? grammarPatternColor() : spellingPatternColor(); setCGStrokeColor(context, patternColor); wkSetPatternPhaseInUserSpace(context, point); CGContextSetBlendMode(context, kCGBlendModeNormal); // 3 rows, each offset by half a pixel for blending purposes const CGPoint upperPoints [] = {{point.x(), point.y() + patternHeight - 2.5 }, {point.x() + width, point.y() + patternHeight - 2.5}}; const CGPoint middlePoints [] = {{point.x(), point.y() + patternHeight - 1.5 }, {point.x() + width, point.y() + patternHeight - 1.5}}; const CGPoint lowerPoints [] = {{point.x(), point.y() + patternHeight - 0.5 }, {point.x() + width, point.y() + patternHeight - 0.5 }}; // Dash lengths for the top and bottom of the error underline are the same. // These are magic. static const float edge_dash_lengths[] = {2.0f, 2.0f}; static const float middle_dash_lengths[] = {2.76f, 1.24f}; static const float edge_offset = -(edge_dash_lengths[1] - 1.0f) / 2.0f; static const float middle_offset = -(middle_dash_lengths[1] - 1.0f) / 2.0f; // Line opacities. Once again, these are magic. const float upperOpacity = 0.33f; const float middleOpacity = 0.75f; const float lowerOpacity = 0.88f; //Top line CGContextSetLineDash(context, edge_offset, edge_dash_lengths, sizeof(edge_dash_lengths) / sizeof(edge_dash_lengths[0])); CGContextSetAlpha(context, upperOpacity); CGContextStrokeLineSegments(context, upperPoints, 2); // Middle line CGContextSetLineDash(context, middle_offset, middle_dash_lengths, sizeof(middle_dash_lengths) / sizeof(middle_dash_lengths[0])); CGContextSetAlpha(context, middleOpacity); CGContextStrokeLineSegments(context, middlePoints, 2); // Bottom line CGContextSetLineDash(context, edge_offset, edge_dash_lengths, sizeof(edge_dash_lengths) / sizeof(edge_dash_lengths[0])); CGContextSetAlpha(context, lowerOpacity); CGContextStrokeLineSegments(context, lowerPoints, 2); CGContextRestoreGState(context); }
void doClippedEllipse(CGContextRef context) { CGPoint theCenterPoint = { 120., 120. }; CGSize theEllipseSize = { 100., 200. }; float dash[1] = { 2 }; static CGColorRef opaqueBrownColor = NULL, opaqueOrangeColor = NULL; // Initialize the CGColorRefs if necessary. if(opaqueBrownColor == NULL){ // The initial value of the color array is an // opaque brown in an RGB color space. float color[4] = { 0.325, 0.208, 0.157, 1.0 }; CGColorSpaceRef theColorSpace = getTheCalibratedRGBColorSpace(); // Create a CGColorRef for opaque brown. opaqueBrownColor = CGColorCreate(theColorSpace, color); // Make the color array correspond to an opaque orange. color[0] = 0.965 ; color[1] = 0.584; color[2] = 0.059; // Create another CGColorRef for opaque orange. opaqueOrangeColor = CGColorCreate(theColorSpace, color); } // Draw two ellipses centered about the same point, one // rotated 45 degrees from the other. CGContextSaveGState(context); // Ellipse 1 createEllipsePath(context, theCenterPoint, theEllipseSize); CGContextSetFillColorWithColor(context, opaqueBrownColor); CGContextFillPath(context); // Translate and rotate about the center point of the ellipse. CGContextTranslateCTM(context, theCenterPoint.x, theCenterPoint.y); // Rotate by 45 degrees. CGContextRotateCTM(context, DEGREES_TO_RADIANS(45)); // Ellipse 2 // CGPointZero is a pre-defined Quartz point corresponding to // the coordinate (0,0). createEllipsePath(context, CGPointZero, theEllipseSize); CGContextSetFillColorWithColor(context, opaqueOrangeColor); CGContextFillPath(context); CGContextRestoreGState(context); CGContextTranslateCTM(context, 170., 0.); // Now use the first ellipse as a clipping area prior to // painting the second ellipse. CGContextSaveGState(context); // Ellipse 3 createEllipsePath(context, theCenterPoint, theEllipseSize); CGContextSetStrokeColorWithColor(context, opaqueBrownColor); CGContextSetLineDash(context, 0, dash, 1); // Stroke the path with a dash. CGContextStrokePath(context); // Ellipse 4 createEllipsePath(context, theCenterPoint, theEllipseSize); // Clip to the elliptical path. CGContextClip(context); CGContextTranslateCTM(context, theCenterPoint.x, theCenterPoint.y); // Rotate by 45 degrees. CGContextRotateCTM(context, DEGREES_TO_RADIANS(45)); // Ellipse 5 createEllipsePath(context, CGPointZero, theEllipseSize); CGContextSetFillColorWithColor(context, opaqueOrangeColor); CGContextFillPath(context); CGContextRestoreGState(context); }
void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, FX_ARGB argb, FX_FLOAT lineWidth) { if (NULL == graphState) { return; } CGContextSetLineWidth(_context, lineWidth); CGLineCap cap; switch (graphState->m_LineCap) { case CFX_GraphStateData::LineCapRound: { cap = kCGLineCapRound; break; } case CFX_GraphStateData::LineCapSquare: { cap = kCGLineCapSquare; break; } case CFX_GraphStateData::LineCapButt: default: { cap = kCGLineCapButt; } } CGContextSetLineCap(_context, cap); CGLineJoin join; switch (graphState->m_LineJoin) { case CFX_GraphStateData::LineJoinRound: { join = kCGLineJoinRound; break; } case CFX_GraphStateData::LineJoinBevel: { join = kCGLineJoinBevel; break; } case CFX_GraphStateData::LineJoinMiter: default: { join = kCGLineJoinMiter; } } CGContextSetLineJoin(_context, join); if (graphState->m_DashCount) { #if CGFLOAT_IS_DOUBLE CGFloat* dashArray = new CGFloat[graphState->m_DashCount]; if (!dashArray) { return; } for (int index = 0; index < graphState->m_DashCount; ++index) { dashArray[index] = graphState->m_DashArray[index]; } #else CGFloat* dashArray = (CGFloat*)graphState->m_DashArray; #endif CGContextSetLineDash(_context, graphState->m_DashPhase, dashArray, graphState->m_DashCount); #if CGFLOAT_IS_DOUBLE delete[] dashArray; #endif } FX_INT32 a, r, g, b; ArgbDecode(argb, a, r, g, b); CGContextSetRGBStrokeColor(_context, r / 255.f, g / 255.f, b / 255.f, a / 255.f); }
// --------------------------------------------------------------------------- // // ------------ void bToolPrintAreaParams::apply(CGContextRef ctx){ if(_dash){ CGContextSetLineDash(ctx,0,_dash,_ndash); } bGraphicParams::apply(ctx); }