本文整理汇总了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;
}
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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()
);
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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()
);
}
示例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);
}
示例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);
}
}