您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CGContextRestoreGState函数代码示例

51自学网 2021-06-01 19:59:44
  C++
这篇教程C++ CGContextRestoreGState函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CGContextRestoreGState函数的典型用法代码示例。如果您正苦于以下问题:C++ CGContextRestoreGState函数的具体用法?C++ CGContextRestoreGState怎么用?C++ CGContextRestoreGState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CGContextRestoreGState函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: doStrokeWithCTM

void doStrokeWithCTM(CGContextRef context){	CGContextTranslateCTM(context, 150., 180.);	CGContextSetLineWidth(context, 10);	// Draw ellipse 1 with a uniform stroke.	CGContextSaveGState(context);		// Scale the CTM so the circular arc will be elliptical.		CGContextScaleCTM(context, 2, 1);		CGContextBeginPath(context);		// Create an arc that is a circle.		CGContextAddArc(context, 0., 0., 45., 0., 2*M_PI, 0);	// Restore the context parameters prior to stroking the path.	// CGContextRestoreGState does not affect the path in the context.	CGContextRestoreGState(context);	CGContextStrokePath(context);		// *** was 0, -120	CGContextTranslateCTM(context, 220., 0.);	// Draw ellipse 2 with non-uniform stroke.	CGContextSaveGState(context);		// Scale the CTM so the circular arc will be elliptical.		CGContextScaleCTM(context, 2, 1);		CGContextBeginPath(context);		// Create an arc that is a circle.		CGContextAddArc(context, 0., 0., 45., 0., 2*M_PI, 0);		// Stroke the path with the scaled coordinate system in effect.		CGContextStrokePath(context);	CGContextRestoreGState(context);}
开发者ID:yarshure,项目名称:ProgrammingWithQuartz-Code,代码行数:29,


示例2: strokeBoundingBox

FloatRect strokeBoundingBox(const Path& path, RenderStyle* style, const RenderObject* object){    // the bbox might grow if the path is stroked.    // and CGPathGetBoundingBox doesn't support that, so we'll have    // to make an alternative call...    // FIXME: since this is mainly used to decide what to repaint,    // perhaps it would be sufficient to just outset the fill bbox by    // the stroke width - that should be way cheaper and simpler than    // what we do here.    CGPathRef cgPath = path.platformPath();    CGContextRef context = scratchContext();    CGContextSaveGState(context);    CGContextBeginPath(context);    CGContextAddPath(context, cgPath);    GraphicsContext gc(context);    applyStrokeStyleToContext(&gc, style, object);    CGContextReplacePathWithStrokedPath(context);    if (CGContextIsPathEmpty(context)) {        // CGContextReplacePathWithStrokedPath seems to fail to create a path sometimes, this is not well understood.        // returning here prevents CG from logging to the console from CGContextGetPathBoundingBox        CGContextRestoreGState(context);        return FloatRect();    }    CGRect box = CGContextGetPathBoundingBox(context);    CGContextRestoreGState(context);    return FloatRect(box);}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:35,


示例3: CGContextSaveGState

void WKCACFLayer::display(PlatformGraphicsContext* context){    if (!m_owner)        return;    CGContextSaveGState(context);    CGRect layerBounds = bounds();    if (m_owner->contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {        CGContextScaleCTM(context, 1, -1);        CGContextTranslateCTM(context, 0, -layerBounds.size.height);    }    if (m_owner->client()) {        GraphicsContext graphicsContext(context);        // It's important to get the clip from the context, because it may be significantly        // smaller than the layer bounds (e.g. tiled layers)        CGRect clipBounds = CGContextGetClipBoundingBox(context);        IntRect clip(enclosingIntRect(clipBounds));        m_owner->paintGraphicsLayerContents(graphicsContext, clip);    }#ifndef NDEBUG    else {        ASSERT_NOT_REACHED();        // FIXME: ideally we'd avoid calling -setNeedsDisplay on a layer that is a plain color,        // so CA never makes backing store for it (which is what -setNeedsDisplay will do above).        CGContextSetRGBFillColor(context, 0.0f, 1.0f, 0.0f, 1.0f);        CGContextFillRect(context, layerBounds);    }#endif    if (m_owner->showRepaintCounter()) {        char text[16]; // that's a lot of repaints        _snprintf(text, sizeof(text), "%d", m_owner->incrementRepaintCount());        CGContextSaveGState(context);        CGContextSetRGBFillColor(context, 1.0f, 0.0f, 0.0f, 0.8f);                CGRect aBounds = layerBounds;        aBounds.size.width = 10 + 12 * strlen(text);        aBounds.size.height = 25;        CGContextFillRect(context, aBounds);                CGContextSetRGBFillColor(context, 0.0f, 0.0f, 0.0f, 1.0f);        CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0f, -1.0f));        CGContextSelectFont(context, "Helvetica", 25, kCGEncodingMacRoman);        CGContextShowTextAtPoint(context, aBounds.origin.x + 3.0f, aBounds.origin.y + 20.0f, text, strlen(text));                CGContextRestoreGState(context);            }    CGContextRestoreGState(context);}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:57,


示例4: CGContextRestoreGState

CFX_QuartzDeviceDriver::~CFX_QuartzDeviceDriver(){    CGContextRestoreGState(_context);    m_saveCount--;    for (int i = 0; i < m_saveCount; ++i) {        CGContextRestoreGState(_context);    }    if (_context) {        CGContextRelease(_context);    }}
开发者ID:151706061,项目名称:PDFium,代码行数:11,


示例5: wxRect

wxBitmap wxScreenDCImpl::DoGetAsBitmap(const wxRect *subrect) const{    wxRect rect = subrect ? *subrect : wxRect(0, 0, m_width, m_height);    wxBitmap bmp(rect.GetSize(), 32);#if !wxOSX_USE_IPHONE    CGRect srcRect = CGRectMake(rect.x, rect.y, rect.width, rect.height);    CGContextRef context = (CGContextRef)bmp.GetHBITMAP();    CGContextSaveGState(context);    CGContextTranslateCTM( context, 0,  m_height );    CGContextScaleCTM( context, 1, -1 );    if ( subrect )        srcRect = CGRectOffset( srcRect, -subrect->x, -subrect->y ) ;    CGImageRef image = grabViaOpenGL(kCGNullDirectDisplay, srcRect);    wxASSERT_MSG(image, wxT("wxScreenDC::GetAsBitmap - unable to get screenshot."));    CGContextDrawImage(context, srcRect, image);        CGImageRelease(image);    CGContextRestoreGState(context);#else    // TODO implement using UIGetScreenImage, CGImageCreateWithImageInRect, CGContextDrawImage#endif    return bmp;}
开发者ID:erwincoumans,项目名称:wxWidgets,代码行数:33,


示例6: paintRepaintRectOverlay

static void paintRepaintRectOverlay(CGContextRef context, WKImageRef image, WKArrayRef repaintRects){    WKSize imageSize = WKImageGetSize(image);    CGContextSaveGState(context);    // Using a transparency layer is easier than futzing with clipping.    CGContextBeginTransparencyLayer(context, 0);        // Flip the context.    CGContextScaleCTM(context, 1, -1);    CGContextTranslateCTM(context, 0, -imageSize.height);        CGContextSetRGBFillColor(context, 0, 0, 0, static_cast<CGFloat>(0.66));    CGContextFillRect(context, CGRectMake(0, 0, imageSize.width, imageSize.height));    // Clear the repaint rects.    size_t count = WKArrayGetSize(repaintRects);    for (size_t i = 0; i < count; ++i) {        WKRect rect = WKRectGetValue(static_cast<WKRectRef>(WKArrayGetItemAtIndex(repaintRects, i)));        CGRect cgRect = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);        CGContextClearRect(context, cgRect);    }        CGContextEndTransparencyLayer(context);    CGContextRestoreGState(context);}
开发者ID:ZeusbaseWeb,项目名称:webkit,代码行数:27,


示例7: beginCGContext

//-----------------------------------------------------------------------------void CGDrawContext::fillLinearGradient (CGraphicsPath* _path, const CGradient& gradient, const CPoint& startPoint, const CPoint& endPoint, bool evenOdd, CGraphicsTransform* t){	QuartzGraphicsPath* path = dynamic_cast<QuartzGraphicsPath*> (_path);	if (path == 0)		return;	const QuartzGradient* cgGradient = dynamic_cast<const QuartzGradient*> (&gradient);	if (cgGradient == 0)		return;	CGContextRef cgContext = beginCGContext (true, currentState.drawMode.integralMode ());	if (cgContext)	{		if (t)		{			CGContextSaveGState (cgContext);			CGAffineTransform transform = QuartzGraphicsPath::createCGAfflineTransform (*t);			CGContextConcatCTM (cgContext, transform);			CGContextAddPath (cgContext, path->getCGPathRef ());			CGContextRestoreGState (cgContext);		}		else			CGContextAddPath (cgContext, path->getCGPathRef ());		if (evenOdd)			CGContextEOClip (cgContext);		else			CGContextClip (cgContext);		CGContextDrawLinearGradient (cgContext, *cgGradient, CGPointMake (startPoint.x, startPoint.y), CGPointMake (endPoint.x, endPoint.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);				releaseCGContext (cgContext);	}}
开发者ID:DaniM,项目名称:lyngo,代码行数:35,


示例8: drawRoundedRect

void drawRoundedRect(CGContextRef context, int x, int y){        struct CGRect cgRect;	struct CGPoint cgPoint;	cgRect.size.width = 640;	cgRect.size.height = y+30;	cgPoint.x = 0;	cgPoint.y = 5;	cgRect.origin = cgPoint;            //printf("Drawing %f, %f, %f, %f", cgPoint.x, cgPoint.y, cgRect.size.width, cgRect.size.height);            CGContextBeginPath(context);        float ovalWidth = 10;    float ovalHeight = 10;        float fw, fh;    // If the width or height of the corner oval is zero, then it reduces to a right angle,    // so instead of a rounded rectangle we have an ordinary one.    if (ovalWidth == 0 || ovalHeight == 0) {        CGContextAddRect(context, cgRect);        return;    }        //  Save the context's state so that the translate and scale can be undone with a call    //  to CGContextRestoreGState.    CGContextSaveGState(context);        //  Translate the origin of the contex to the lower left corner of the rectangle.    CGContextTranslateCTM(context, CGRectGetMinX(cgRect), CGRectGetMinY(cgRect));        //Normalize the scale of the context so that the width and height of the arcs are 1.0    CGContextScaleCTM(context, ovalWidth, ovalHeight);        // Calculate the width and height of the rectangle in the new coordinate system.    fw = CGRectGetWidth(cgRect) / ovalWidth;    fh = CGRectGetHeight(cgRect) / ovalHeight;        // CGContextAddArcToPoint adds an arc of a circle to the context's path (creating the rounded    // corners).  It also adds a line from the path's last point to the begining of the arc, making    // the sides of the rectangle.    CGContextMoveToPoint(context, fw, fh/2);  // Start at lower right corner    CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1);  // Top right corner    CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1); // Top left corner    CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1); // Lower left corner    CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); // Back to lower right        // Close the path    CGContextClosePath(context);        CGContextSetRGBFillColor (context, 1, 1, 1, 0.7);        CGContextFillPath(context);        CGContextRestoreGState(context);    }
开发者ID:BenPorebski,项目名称:QuickLookPDB,代码行数:60,


示例9: focusRingOffset

void GraphicsContext::drawFocusRing(const Color& color){    if (paintingDisabled())        return;    float radius = (focusRingWidth() - 1) / 2.0f;    int offset = radius + focusRingOffset();    CGColorRef colorRef = color.isValid() ? cgColor(color) : 0;    CGMutablePathRef focusRingPath = CGPathCreateMutable();    const Vector<IntRect>& rects = focusRingRects();    unsigned rectCount = rects.size();    for (unsigned i = 0; i < rectCount; i++)        CGPathAddRect(focusRingPath, 0, CGRectInset(rects[i], -offset, -offset));    CGContextRef context = platformContext();    CGContextSaveGState(context);    CGContextBeginPath(context);    CGContextAddPath(context, focusRingPath);    wkDrawFocusRing(context, colorRef, radius);    CGColorRelease(colorRef);    CGPathRelease(focusRingPath);    CGContextRestoreGState(context);}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:29,


示例10: pathForArc

void pathForArc(CGContextRef context, CGRect r, int startAngle, int arcAngle){    float start, end;    CGAffineTransform matrix;		// Save the context's state because we are going to scale it    CGContextSaveGState(context);		// Create a transform to scale the context so that a radius of 1 maps to the bounds	// of the rectangle, and transform the origin of the context to the center of	// the bounding rectangle.    matrix = CGAffineTransformMake(r.size.width/2, 0,								   0, r.size.height/2,								   r.origin.x + r.size.width/2,								   r.origin.y + r.size.height/2);								   	// Apply the transform to the context    CGContextConcatCTM(context, matrix);			// Calculate the start and ending angles    if (arcAngle > 0) {		start = (90 - startAngle - arcAngle) * M_PI / 180;		end = (90 - startAngle) * M_PI / 180;    } else {		start = (90 - startAngle) * M_PI / 180;		end = (90 - startAngle - arcAngle) * M_PI / 180;    }		// Add the Arc to the path    CGContextAddArc(context, 0, 0, 1, start, end, false);		// Restore the context's state. This removes the translation and scaling	// but leaves the path, since the path is not part of the graphics state.    CGContextRestoreGState(context);}
开发者ID:DannyDeng2014,项目名称:CocoaSampleCode,代码行数:35,


示例11: CGRectMake

wxBitmap wxScreenDCImpl::DoGetAsBitmap(const wxRect *subrect) const{    CGRect srcRect = CGRectMake(0, 0, m_width, m_height);    if (subrect)    {        srcRect.origin.x = subrect->GetX();        srcRect.origin.y = subrect->GetY();        srcRect.size.width = subrect->GetWidth();        srcRect.size.height = subrect->GetHeight();    }    wxBitmap bmp = wxBitmap(srcRect.size.width, srcRect.size.height, 32);#if wxOSX_USE_IPHONE#else    CGContextRef context = (CGContextRef)bmp.GetHBITMAP();        CGContextSaveGState(context);        CGContextTranslateCTM( context, 0,  m_height );    CGContextScaleCTM( context, 1, -1 );        if ( subrect )        srcRect = CGRectOffset( srcRect, -subrect->x, -subrect->y ) ;        CGImageRef image = grabViaOpenGL(kCGNullDirectDisplay, srcRect);        wxASSERT_MSG(image, wxT("wxScreenDC::GetAsBitmap - unable to get screenshot."));        CGContextDrawImage(context, srcRect, image);        CGContextRestoreGState(context);#endif    return bmp;}
开发者ID:jonntd,项目名称:dynamica,代码行数:33,


示例12: ScratchContext

RectPathCG::GetStrokedBounds(const StrokeOptions &aStrokeOptions,                         const Matrix &aTransform) const{  // 10.7 has CGPathCreateCopyByStrokingPath which we could use  // instead of this scratch context business  CGContextRef cg = ScratchContext();  CGContextSaveGState(cg);  CGContextBeginPath(cg);  CGContextAddPath(cg, mPath);  SetStrokeOptions(cg, aStrokeOptions);  CGContextReplacePathWithStrokedPath(cg);  Rect bounds = CGRectToRect(CGContextGetPathBoundingBox(cg));  CGContextRestoreGState(cg);  if (!bounds.IsFinite()) {    return Rect();  }  return aTransform.TransformBounds(bounds);}
开发者ID:70599,项目名称:Waterfox,代码行数:26,


示例13: AddRoundedRectToPath

static void AddRoundedRectToPath(CGContextRef context, CGRect rect,                                 float ovalWidth, float ovalHeight){    float fw, fh;    if (ovalWidth == 0 || ovalHeight == 0)    {        CGContextAddRect(context, rect);        return;    }    CGContextSaveGState(context);    CGContextTranslateCTM (context, CGRectGetMinX(rect),                           CGRectGetMinY(rect));    CGContextScaleCTM (context, ovalWidth, ovalHeight);    fw = CGRectGetWidth (rect) / ovalWidth;    fh = CGRectGetHeight (rect) / ovalHeight;    CGContextMoveToPoint(context, fw, fh / 2);    CGContextAddArcToPoint(context, fw, fh, fw / 2, fh, 1);    CGContextAddArcToPoint(context, 0, fh, 0, fh / 2, 1);    CGContextAddArcToPoint(context, 0, 0, fw / 2, 0, 1);    CGContextAddArcToPoint(context, fw, 0, fw, fh / 2, 1);    CGContextClosePath(context);    CGContextRestoreGState(context);}
开发者ID:AdamDiment,项目名称:CocoaSampleCode,代码行数:28,


示例14: snprintf

void PlatformCALayer::drawRepaintIndicator(CGContextRef context, PlatformCALayer* platformCALayer, int repaintCount, CGColorRef customBackgroundColor){    char text[16]; // that's a lot of repaints    snprintf(text, sizeof(text), "%d", repaintCount);        CGRect indicatorBox = platformCALayer->bounds();    CGContextSaveGState(context);    indicatorBox.size.width = 12 + 10 * strlen(text);    indicatorBox.size.height = 27;        CGContextSetAlpha(context, 0.5f);    CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);        if (customBackgroundColor)        CGContextSetFillColorWithColor(context, customBackgroundColor);    else        CGContextSetRGBFillColor(context, 0, 0.5f, 0.25f, 1);        CGContextFillRect(context, indicatorBox);        if (platformCALayer->acceleratesDrawing())        CGContextSetRGBFillColor(context, 1, 0, 0, 1);    else        CGContextSetRGBFillColor(context, 1, 1, 1, 1);        platformCALayer->drawTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, CGSizeMake(1, -1), 22, text, strlen(text));        CGContextEndTransparencyLayer(context);    CGContextRestoreGState(context);}
开发者ID:rhythmkay,项目名称:webkit,代码行数:32,


示例15: CGContextRestoreGState

//-----------------------------------------------------------------------------void CGDrawContext::releaseCGContext (CGContextRef context){	if (context)	{		CGContextRestoreGState (context);	}}
开发者ID:DaniM,项目名称:lyngo,代码行数:8,


示例16: CGContextRestoreGState

void GraphicsContext::restorePlatformState(){    // Note: Do not use this function within this class implementation, since we want to avoid the extra    // restore of the secondary context (in GraphicsContextPlatformPrivate.h).    CGContextRestoreGState(platformContext());    m_data->restore();}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:7,


示例17: SkCreateCGImageRef

void SkOSWindow::doPaint(void* ctx){#if 0	this->update(NULL);    const SkBitmap& bm = this->getBitmap();    CGImageRef img = SkCreateCGImageRef(bm);    if (img) {        CGRect r = CGRectMake(0, 0, bm.width(), bm.height());        CGContextRef cg = reinterpret_cast<CGContextRef>(ctx);        CGContextSaveGState(cg);        CGContextTranslateCTM(cg, 0, r.size.height);        CGContextScaleCTM(cg, 1, -1);        CGContextDrawImage(cg, r, img);        CGContextRestoreGState(cg);        CGImageRelease(img);    }#endif}
开发者ID:AliFarahnak,项目名称:XobotOS,代码行数:25,


示例18: platformContext

void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias){    if (paintingDisabled())        return;    if (npoints <= 1)        return;    CGContextRef context = platformContext();    CGContextSaveGState(context);    CGContextSetShouldAntialias(context, shouldAntialias);        CGContextBeginPath(context);    CGContextMoveToPoint(context, points[0].x(), points[0].y());    for (size_t i = 1; i < npoints; i++)        CGContextAddLineToPoint(context, points[i].x(), points[i].y());    CGContextClosePath(context);    if (fillColor().alpha())        CGContextEOFillPath(context);    if (strokeStyle() != NoStroke)        CGContextStrokePath(context);    CGContextRestoreGState(context);}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:28,


示例19: QDPictGetBounds

bool wxMetaFile::Play(wxDC *dc){    if (!m_refData)        return false;    if (!dc->Ok() )        return false;    {#if wxMAC_USE_CORE_GRAPHICS        QDPictRef cgPictRef = M_METAFILEDATA->m_qdPictRef ;        CGContextRef cg = ((wxMacCGContext*)(dc->GetGraphicContext()))->GetNativeContext() ;        CGRect bounds = QDPictGetBounds( cgPictRef ) ;        CGContextSaveGState(cg);        CGContextTranslateCTM(cg, 0 , bounds.size.width );        CGContextScaleCTM(cg, 1, -1);        QDPictDrawToCGContext( cg , bounds , cgPictRef ) ;        CGContextRestoreGState( cg ) ;#else        PicHandle pict = (PicHandle) GetHMETAFILE() ;        wxMacPortSetter helper( dc ) ;        DrawPicture( pict , &(**pict).picFrame ) ;#endif    }    return true;}
开发者ID:HackLinux,项目名称:chandler-1,代码行数:27,


示例20: platformContext

void GraphicsContext::fillPath(const Path& path){    if (paintingDisabled())        return;    CGContextRef context = platformContext();    CGContextBeginPath(context);    CGContextAddPath(context, path.platformPath());    if (m_state.fillGradient) {        CGContextSaveGState(context);        if (fillRule() == RULE_EVENODD)            CGContextEOClip(context);        else            CGContextClip(context);        CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());        m_state.fillGradient->paint(this);        CGContextRestoreGState(context);        return;    }    if (m_state.fillPattern)        applyFillPattern();    fillPathWithFillRule(context, fillRule());}
开发者ID:dslab-epfl,项目名称:warr,代码行数:26,


示例21: _cairo_quartz_surface_release_dest_image

static void_cairo_quartz_surface_release_dest_image(void                    *abstract_surface,        cairo_rectangle_int16_t *intersect_rect,        cairo_image_surface_t   *image,        cairo_rectangle_int16_t *image_rect,        void                    *image_extra){    cairo_quartz_surface_t *surface = abstract_surface;    CGImageRef image_ref;    CGRect rect;    image_ref = create_image_from_surface (image, image_extra);    rect = CGRectMake (image_rect->x, image_rect->y, image_rect->width, image_rect->height);    if (surface->y_grows_down) {        CGContextSaveGState (surface->context);        CGContextTranslateCTM (surface->context, 0, image_rect->height + 2 * image_rect->y);        CGContextScaleCTM (surface->context, 1, -1);    }    CGContextDrawImage(surface->context, rect, image_ref);    CFRelease (image_ref);    if (surface->y_grows_down) {        CGContextRestoreGState (surface->context);    }    cairo_surface_destroy ((cairo_surface_t *)image);    free (image_extra);}
开发者ID:nihed,项目名称:magnetism,代码行数:31,


示例22: snprintf

void PlatformCALayer::drawRepaintIndicator(CGContextRef context, PlatformCALayer* platformCALayer, int repaintCount, CGColorRef customBackgroundColor){    char text[16]; // that's a lot of repaints    snprintf(text, sizeof(text), "%d", repaintCount);    CGRect indicatorBox = platformCALayer->bounds();    indicatorBox.size.width = 12 + 10 * strlen(text);    indicatorBox.size.height = 27;    CGContextSaveGState(context);    CGContextSetAlpha(context, 0.5f);    CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);    if (customBackgroundColor)        CGContextSetFillColorWithColor(context, customBackgroundColor);    else        CGContextSetRGBFillColor(context, 0, 0.5f, 0.25f, 1);    CGContextFillRect(context, indicatorBox);    if (platformCALayer->acceleratesDrawing())        CGContextSetRGBFillColor(context, 1, 0, 0, 1);    else        CGContextSetRGBFillColor(context, 1, 1, 1, 1);#pragma clang diagnostic push#pragma clang diagnostic ignored "-Wdeprecated-declarations"    CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));    CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);    CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));#pragma clang diagnostic pop    CGContextEndTransparencyLayer(context);    CGContextRestoreGState(context);}
开发者ID:highweb-project,项目名称:highweb-parallelwebkit,代码行数:35,


示例23: CGContextSetRGBFillColor

void TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds) const{    CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 1);    CGContextFillRect(context, layerBounds);    CGFloat scaleFactor = layerBounds.size.width / m_controller.bounds().width();    CGFloat contextScale = scaleFactor / m_scale;    CGContextScaleCTM(context, contextScale, contextScale);    for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {        const TileInfo& tileInfo = it->value;        PlatformCALayer* tileLayer = tileInfo.layer.get();        CGFloat red = 1;        CGFloat green = 1;        CGFloat blue = 1;        CGFloat alpha = 1;        if (tileInfo.hasStaleContent) {            red = 0.25;            green = 0.125;            blue = 0;        } else if (m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort) {            red = 0.8;            green = 0.8;            blue = 0.8;        }        TileCohort newestCohort = newestTileCohort();        TileCohort oldestCohort = oldestTileCohort();        if (!m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort)            alpha = 1 - (static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort));        CGContextSetRGBFillColor(context, red, green, blue, alpha);        if (tileLayer->superlayer()) {            CGContextSetLineWidth(context, 0.5 / contextScale);            CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);        } else {            CGContextSetLineWidth(context, 1 / contextScale);            CGContextSetRGBStrokeColor(context, 0.2, 0.1, 0.9, 1);        }        CGRect frame = CGRectMake(tileLayer->position().x(), tileLayer->position().y(), tileLayer->bounds().size().width(), tileLayer->bounds().size().height());        CGContextFillRect(context, frame);        CGContextStrokeRect(context, frame);        CGContextSetRGBFillColor(context, 0, 0, 0, 0.5);        String repaintCount = String::number(m_tileRepaintCounts.get(tileLayer));        CGContextSaveGState(context);        tileLayer->drawTextAtPoint(context, frame.origin.x + 64, frame.origin.y + 192, CGSizeMake(3, -3), 58,                                   repaintCount.ascii().data(), repaintCount.length());        CGContextRestoreGState(context);    }}
开发者ID:hnney,项目名称:webkit,代码行数:60,


示例24: addRoundedRectToPath

static void addRoundedRectToPath(CGContextRef context, CGRect rect,										float ovalWidth,										float ovalHeight){	float fw, fh;	// If either ovalWidth or ovalHeight is 0, draw a regular rectangle.	if (ovalWidth == 0 || ovalHeight == 0) {		CGContextAddRect(context, rect);	}else{        CGContextSaveGState(context);		// Translate to lower-left corner of rectangle.        CGContextTranslateCTM(context, CGRectGetMinX(rect),										 CGRectGetMinY(rect));		// Scale by the oval width and height so that		// each rounded corner is 0.5 units in radius.		CGContextScaleCTM(context, ovalWidth, ovalHeight);		// Unscale the rectangle width by the amount of the X scaling.		fw = CGRectGetWidth(rect) / ovalWidth;		// Unscale the rectangle height by the amount of the Y scaling.		fh = CGRectGetHeight(rect) / ovalHeight;		// Start at the right edge of the rect, at the midpoint in Y.		CGContextMoveToPoint(context, fw, fh/2);		// Segment 1		CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 0.5);		// Segment 2		CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 0.5);		// Segment 3		CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 0.5);		// Segment 4		CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 0.5);		// Closing the path adds the last segment.		CGContextClosePath(context);		CGContextRestoreGState(context);	}}
开发者ID:yarshure,项目名称:ProgrammingWithQuartz-Code,代码行数:35,


示例25: quartzgen_end_page

static void quartzgen_end_page(GVJ_t *job){	/* end the page (if this is a paged context) and graphics state */	CGContextRef context = (CGContextRef)job->context;	CGContextRestoreGState(context);	CGContextEndPage(context);}
开发者ID:nyue,项目名称:graphviz-cmake,代码行数:7,


示例26: doRotatedEllipses

void doRotatedEllipses(CGContextRef context){	int i, totreps = 144;	float  tint = 1.0, tintIncrement = 1.0/totreps;	// Create a new transform consisting of a 45 degrees rotation.	CGAffineTransform theTransform = CGAffineTransformMakeRotation(M_PI/4);	// Apply a scale to the transform just created.	theTransform = CGAffineTransformScale(theTransform, 1, 2);	// Place the first ellipse at a good location.	CGContextTranslateCTM(context, 100., 100.);		for(i=0 ; i < totreps ; i++){		// Make a snapshot the coordinate system.		CGContextSaveGState(context);			// Set up the coordinate system for the rotated ellipse.			CGContextConcatCTM(context, theTransform);			CGContextBeginPath(context);			CGContextAddArc(context, 0., 0., 45., 0., 2*M_PI, 0); 			// Set the fill color for this instance of the ellipse.			CGContextSetRGBFillColor(context, tint, 0., 0., 1.0);			CGContextDrawPath(context, kCGPathFill);		// Restore the coordinate system to that of the snapshot.		CGContextRestoreGState(context);		// Compute the next tint color.		tint -= tintIncrement;		// Move over by 1 unit in x for the next ellipse.		CGContextTranslateCTM(context, 1.0, 0.0);	}}
开发者ID:yarshure,项目名称:ProgrammingWithQuartz-Code,代码行数:29,



注:本文中的CGContextRestoreGState函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CGContextSaveGState函数代码示例
C++ CGContextRelease函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。