路径是绘制变化形状的最有效方法吗? [英] Are Paths the most efficient way to draw changing shapes?

查看:82
本文介绍了路径是绘制变化形状的最有效方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建的应用程序必须以流畅的帧频在屏幕上绘制大约400个四边形形状.形状为255个排列,并绘制为从0-360度旋转.考虑到需要的内存量,我认为预渲染它们不会很有效(不过我可能是错的).它们还具有24位颜色范围.现在,我正在用路径绘制它们,所有旋转和平移都由生成值的函数处理.尽管此实现有效(全部都在25左右的低帧速率下),但我只是感觉有一种更有效的方法.老实说,openGL和java看起来很令人困惑,但是如果这是唯一的选择,那么我会亲自学习.

The app I'm building has to draw around 400 quadrilateral shapes onto the screen with a fluent frame rate. The shapes 255 permutations and are drawn rotated anywhere from 0-360 degrees. I don't think pre-rendering them would efficient, given the amount of memory it would take (I could be wrong though). They also have a 24-bit color range. Right now I'm drawing them with paths and all the rotation and translation is handled by the function generating the values. Although this implementation is working (all be it at a low frame rate of like 25), I just feel like there's a more efficient way of doing it. To be honest, openGL and java looks quite confusing, but if it's the only option then I would man up and learn it.

TL; DR这段代码对于不断变化的形状最有效吗?

TL;DR Is this code the most efficient for constantly changing shapes?

        void quad(Canvas canvas,Paint paint, float x1,float y1, float x2,float y2, float x3,float y3,float x4,float y4,  float xoff, float yoff, int color){
        float[] hsvc = { map(color,0,100,0,360),.8f,1};
        paint.setColor(Color.HSVToColor(hsvc));
        Path path = new Path();
        path.moveTo(x1, y1);
        path.lineTo(x2, y2);
        path.lineTo(x3, y3);
        path.lineTo(x4, y4);
        path.close();
        path.offset(xoff, yoff);
        canvas.drawPath(path, paint);
    }

谢谢!

推荐答案

您的排列顺序是什么?如何旋转路径?

What are your permutations ans how do you rotate the paths?

由于 Path 在Android中似乎是可变的,因此您可以尝试重用实例并查看它是否为您提供更好的结果(例如,使用 Path.reset()).

As Path seems to be mutable in Android, you might try to reuse an instance and see if it gives you better results (using Path.reset() for instance).

这篇关于路径是绘制变化形状的最有效方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆