当前位置: 首页>>代码示例>>C++>>正文


C++ Paint类代码示例

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


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

示例1: RI_DELETE

void VGContext::releasePaint(VGbitfield paintModes)
{
	if(paintModes & VG_FILL_PATH)
	{
		//release previous paint
		Paint* prev = (Paint*)m_fillPaint;
		if(prev)
		{
			if(!prev->removeReference())
				RI_DELETE(prev);
		}
		m_fillPaint = VG_INVALID_HANDLE;
	}
	if(paintModes & VG_STROKE_PATH)
	{
		//release previous paint
		Paint* prev = (Paint*)m_strokePaint;
		if(prev)
		{
			if(!prev->removeReference())
				RI_DELETE(prev);
		}
		m_strokePaint = VG_INVALID_HANDLE;
	}
}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:25,代码来源:riContext.cpp

示例2: OnDraw

  virtual void OnDraw(const Context &context) override {
    using wiztk::graphic::Canvas;
    using wiztk::graphic::Paint;

    const RectF &rect = GetBounds();
    int scale = context.surface()->GetScale();

    Canvas *canvas = context.canvas();
    canvas->Save();
    canvas->Scale(scale, scale);

    Paint paint;
    paint.SetColor(ColorF(0.855f, 0.855f, 0.165f, .9f));
    canvas->DrawRect(rect, paint);

    canvas->Restore();

    SkCanvas *sk_canvas = canvas->GetSkCanvas();

    SkImageInfo info = SkImageInfo::MakeN32(400, 400, kPremul_SkAlphaType);
    sk_sp<SkSurface> surface = sk_canvas->makeSurface(info);

    SkCanvas *top_canvas = surface->getCanvas();
    SkRect top_rect = SkRect::MakeXYWH(50, 50, 100, 100);
    SkPaint top_paint;
    top_paint.setColor(0xFFFF0000);

    top_canvas->drawRect(top_rect, top_paint);
    top_canvas->flush();

    surface->draw(sk_canvas, 100, 100, nullptr);

    canvas->Flush();
  }
开发者ID:lineCode,项目名称:framework,代码行数:34,代码来源:frameless.cpp

示例3: drawBitmap

static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jlong bitmapHandle,
                       jfloat left, jfloat top, jlong paintHandle, jint canvasDensity,
                       jint screenDensity, jint bitmapDensity) {
    Canvas* canvas = get_canvas(canvasHandle);
    const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
    const Paint* paint = reinterpret_cast<Paint*>(paintHandle);

    if (canvasDensity == bitmapDensity || canvasDensity == 0 || bitmapDensity == 0) {
        if (screenDensity != 0 && screenDensity != bitmapDensity) {
            Paint filteredPaint;
            if (paint) {
                filteredPaint = *paint;
            }
            filteredPaint.setFilterLevel(Paint::kLow_FilterLevel);
            canvas->drawBitmap(*bitmap, left, top, &filteredPaint);
        } else {
            canvas->drawBitmap(*bitmap, left, top, paint);
        }
    } else {
        canvas->save(SkCanvas::kMatrixClip_SaveFlag);
        SkScalar scale = canvasDensity / (float)bitmapDensity;
        canvas->translate(left, top);
        canvas->scale(scale, scale);

        Paint filteredPaint;
        if (paint) {
            filteredPaint = *paint;
        }
        filteredPaint.setFilterLevel(Paint::kLow_FilterLevel);

        canvas->drawBitmap(*bitmap, 0, 0, &filteredPaint);
        canvas->restore();
    }
}
开发者ID:lovelifer,项目名称:graduate,代码行数:34,代码来源:android_graphics_Canvas.cpp

示例4: android_view_DisplayListCanvas_drawRegionAsRects

static void android_view_DisplayListCanvas_drawRegionAsRects(JNIEnv* env, jobject clazz,
        jlong rendererPtr, jlong regionPtr, jlong paintPtr) {
    DisplayListCanvas* renderer = reinterpret_cast<DisplayListCanvas*>(rendererPtr);
    SkRegion* region = reinterpret_cast<SkRegion*>(regionPtr);
    Paint* paint = reinterpret_cast<Paint*>(paintPtr);
    if (paint->getStyle() != Paint::kFill_Style ||
            (paint->isAntiAlias() && !renderer->isCurrentTransformSimple())) {
        SkRegion::Iterator it(*region);
        while (!it.done()) {
            const SkIRect& r = it.rect();
            renderer->drawRect(r.fLeft, r.fTop, r.fRight, r.fBottom, *paint);
            it.next();
        }
    } else {
        int count = 0;
        Vector<float> rects;
        SkRegion::Iterator it(*region);
        while (!it.done()) {
            const SkIRect& r = it.rect();
            rects.push(r.fLeft);
            rects.push(r.fTop);
            rects.push(r.fRight);
            rects.push(r.fBottom);
            count += 4;
            it.next();
        }
        renderer->drawRects(rects.array(), count, paint);
    }
}
开发者ID:Flhawker,项目名称:platform_frameworks_base,代码行数:29,代码来源:android_view_DisplayListCanvas.cpp

示例5: nAddStyleRun

// Regular JNI
static void nAddStyleRun(JNIEnv* /* unused */, jclass /* unused */, jlong builderPtr,
                         jlong paintPtr, jint start, jint end, jboolean isRtl) {
    Paint* paint = toPaint(paintPtr);
    const Typeface* typeface = Typeface::resolveDefault(paint->getAndroidTypeface());
    minikin::MinikinPaint minikinPaint = MinikinUtils::prepareMinikinPaint(paint, typeface);
    toBuilder(builderPtr)->addStyleRun(start, end, std::move(minikinPaint), isRtl);
}
开发者ID:AlanCheen,项目名称:platform_frameworks_base,代码行数:8,代码来源:android_text_MeasuredParagraph.cpp

示例6: main

int main(int argc, char* argv[])
{   
	string input;
	Scan scan;
	Paint print;

	

	if (argc == 2)//无-a -f
	{
		
		input = argv[1];
		scan.ToStringQueue(input);
		print.Printqueue();
	}

	else if (argc == 3 )//第二个参数-a
	{
		input = argv[2];
		cout << input << " ";
		scan.ToStringQueue(input);
		print.Printqueue();
	}
	
	else// -f的情况
	{
		
		fout.open(argv[3]);
		flag = 4;
		ifstream fin;
		fin.open(argv[2]);
		if (fin.is_open())
		{

			while (fin.good() && !fin.eof())//读取到文件尾停止读入
			{
				
				string message;//先将运算式存入message 再转存如input进行操作
				fin >> message;
				input = message;
				ssss = argv[3];
				scan.ToStringQueue(input);
				print.Printqueue();

			}
		}	
	}
	system("pause");
	return 0;
	
}
开发者ID:hsh1234,项目名称:object-oriented,代码行数:51,代码来源:Calculator.cpp

示例7: drawAtlas

void Canvas::drawAtlas(CanvasImage* atlas,
    const Vector<RSTransform>& transforms, const Vector<Rect>& rects,
    const Vector<SkColor>& colors, TransferMode mode,
    const Rect& cullRect, const Paint& paint)
{
  if (!m_canvas)
    return;

  RefPtr<SkImage> skImage = atlas->image();

  Vector<SkRSXform> skXForms;
  skXForms.reserveInitialCapacity(transforms.size());
  for (const RSTransform& transform : transforms)
    skXForms.append(transform.sk_xform);

  Vector<SkRect> skRects;
  skRects.reserveInitialCapacity(rects.size());
  for (const Rect& rect : rects)
    skRects.append(rect.sk_rect);

  m_canvas->drawAtlas(
      skImage.get(),
      skXForms.data(),
      skRects.data(),
      colors.isEmpty() ? nullptr : colors.data(),
      skXForms.size(),
      mode,
      cullRect.is_null ? nullptr : &cullRect.sk_rect,
      paint.paint()
  );
}
开发者ID:zbowling,项目名称:engine,代码行数:31,代码来源:Canvas.cpp

示例8: saveLayer

void Canvas::saveLayer(const Rect& bounds, const Paint& paint)
{
    if (!m_canvas)
        return;
    m_canvas->saveLayer(!bounds.is_null ? &bounds.sk_rect : nullptr,
                        paint.paint());
}
开发者ID:emembrives,项目名称:engine,代码行数:7,代码来源:Canvas.cpp

示例9: drawImageNine

void Canvas::drawImageNine(const CanvasImage* image, Rect& center, Rect& dst, const Paint& paint) {
    if (!m_canvas)
        return;
    ASSERT(image);
    SkIRect icenter;
    center.sk_rect.round(&icenter);
    m_canvas->drawImageNine(image->image(), icenter, dst.sk_rect, paint.paint());
}
开发者ID:emembrives,项目名称:engine,代码行数:8,代码来源:Canvas.cpp

示例10: proprietor

void Spinner::Private::Draw(const Context &context) {
  angle += 5.f;
  if (angle > 360.f) angle = 0.f;

  Canvas *canvas = context.canvas();
  int scale = context.surface()->GetScale();
  canvas->Scale(scale, scale);

  const RectF &rect = proprietor()->GetBounds();
  float radius = base::Clamp(std::min(rect.width(), rect.height()) / 2.f - 50.f,
                             50.f, 200.f);

  Paint paint;
  paint.SetAntiAlias(true);

  paint.SetColor(background);
  paint.SetStyle(Paint::Style::kStyleFill);
  canvas->DrawRect(rect, paint);

  paint.SetColor(ColorF(foreground));
  paint.SetStyle(Paint::Style::kStyleStroke);
  paint.SetStrokeWidth(6.f);

  canvas->DrawArc(RectF(rect.center_x() - radius,
                        rect.center_y() - radius,
                        rect.center_x() + radius,
                        rect.center_y() + radius),
                  angle, 300.f, false, paint);

  frame_callback.Setup(context.surface());
}
开发者ID:lineCode,项目名称:framework,代码行数:31,代码来源:spinner.cpp

示例11: doFrame

    void doFrame(int frameNr) override {
        const char* text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

        std::unique_ptr<Canvas> canvas(
                Canvas::create_recording_canvas(container->stagingProperties().getWidth(),
                                                container->stagingProperties().getHeight(),
                                                container.get()));

        Paint paint;
        paint.setAntiAlias(true);
        paint.setColor(Color::Black);
        for (int i = 0; i < 5; i++) {
            paint.setTextSize(10 + (frameNr % 20) + i * 20);
            TestUtils::drawUtf8ToCanvas(canvas.get(), text, paint, 0, 100 * (i + 2));
        }

        container->setStagingDisplayList(canvas->finishRecording());
    }
开发者ID:AlanCheen,项目名称:platform_frameworks_base,代码行数:18,代码来源:GlyphStressAnimation.cpp

示例12: saveLayer

void Canvas::saveLayer(double left,
                       double top,
                       double right,
                       double bottom,
                       const Paint& paint)
{
    if (!m_canvas)
        return;
    SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom);
    m_canvas->saveLayer(&bounds, paint.paint());
}
开发者ID:colin3dmax,项目名称:engine-1,代码行数:11,代码来源:Canvas.cpp

示例13: drawVertices

void Canvas::drawVertices(SkCanvas::VertexMode vertexMode,
        const Vector<Point>& vertices,
        const Vector<Point>& textureCoordinates,
        const Vector<SkColor>& colors,
        SkXfermode::Mode transferMode,
        const Vector<int>& indices,
        const Paint& paint,
        ExceptionState& es)
{
    if (!m_canvas)
        return;
    size_t vertexCount = vertices.size();

    if (textureCoordinates.size() && textureCoordinates.size() != vertexCount)
        return es.ThrowRangeError("vertices and textureCoordinates lengths must match");
    if (colors.size() && colors.size() != vertexCount)
        return es.ThrowRangeError("vertices and colors lengths must match");

    Vector<SkPoint> skVertices;
    for (size_t x = 0; x < vertices.size(); x++) {
        const Point& point = vertices[x];
        if (point.is_null)
            return es.ThrowRangeError("vertices contained a null");
        skVertices.append(point.sk_point);
    }

    Vector<SkPoint> skTextureCoordinates;
    for (size_t x = 0; x < textureCoordinates.size(); x++) {
        const Point& point = textureCoordinates[x];
        if (point.is_null)
            return es.ThrowRangeError("textureCoordinates contained a null");
        skTextureCoordinates.append(point.sk_point);
    }

    Vector<uint16_t> skIndices;
    for (size_t x = 0; x < indices.size(); x++) {
        uint16_t i = indices[x];
        skIndices.append(i);
    }

    RefPtr<SkXfermode> transferModePtr = adoptRef(SkXfermode::Create(transferMode));

    m_canvas->drawVertices(
        vertexMode,
        skVertices.size(),
        skVertices.data(),
        skTextureCoordinates.isEmpty() ? nullptr : skTextureCoordinates.data(),
        colors.isEmpty() ? nullptr : colors.data(),
        transferModePtr.get(),
        skIndices.isEmpty() ? nullptr : skIndices.data(),
        skIndices.size(),
        *paint.paint()
    );
}
开发者ID:hj3938,项目名称:engine,代码行数:54,代码来源:Canvas.cpp

示例14: doFrame

    void doFrame(int frameNr) override {
        std::unique_ptr<uint16_t[]> text = TestUtils::asciiToUtf16(
                "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
        ssize_t textLength = 26 * 2;

        TestCanvas canvas(
                container->stagingProperties().getWidth(),
                container->stagingProperties().getHeight());
        Paint paint;
        paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
        paint.setAntiAlias(true);
        paint.setColor(Color::Black);
        for (int i = 0; i < 5; i++) {
            paint.setTextSize(10 + (frameNr % 20) + i * 20);
            canvas.drawText(text.get(), 0, textLength, textLength,
                    0, 100 * (i + 2), kBidi_Force_LTR, paint, nullptr);
        }

        container->setStagingDisplayList(canvas.finishRecording(), nullptr);
    }
开发者ID:rockinroyle,项目名称:platform_frameworks_base,代码行数:20,代码来源:GlyphStressAnimation.cpp

示例15: drawBitmapRect

static void drawBitmapRect(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHandle,
                           float srcLeft, float srcTop, float srcRight, float srcBottom,
                           float dstLeft, float dstTop, float dstRight, float dstBottom,
                           jlong paintHandle, jint screenDensity, jint bitmapDensity) {
    Canvas* canvas = get_canvas(canvasHandle);
    const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
    const Paint* paint = reinterpret_cast<Paint*>(paintHandle);

    if (screenDensity != 0 && screenDensity != bitmapDensity) {
        Paint filteredPaint;
        if (paint) {
            filteredPaint = *paint;
        }
        filteredPaint.setFilterLevel(Paint::kLow_FilterLevel);
        canvas->drawBitmap(*bitmap, srcLeft, srcTop, srcRight, srcBottom,
                           dstLeft, dstTop, dstRight, dstBottom, &filteredPaint);
    } else {
        canvas->drawBitmap(*bitmap, srcLeft, srcTop, srcRight, srcBottom,
                           dstLeft, dstTop, dstRight, dstBottom, paint);
    }
}
开发者ID:lovelifer,项目名称:graduate,代码行数:21,代码来源:android_graphics_Canvas.cpp


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