首页 \ 问答 \ DrawArc上的图像,定位问题(DrawArc on image, positioning issue)

DrawArc上的图像,定位问题(DrawArc on image, positioning issue)

我有一个可测量的标尺,我试图在它上面画一条线。 (固定位置,不是固定值)

不幸的是,我没有任何绘画经验。 (我认为它很难理解)

目前看起来像这样: https : //i.stack.imgur.com/5tkXEl.png

正如你所看到的,它没有定位正确,我很害怕在其他设备上看它。

代码(Class extends View):

private void init(Context context) {
    bounds = new Rect();
    gaugeBackground = ContextCompat.getDrawable(context, R.drawable.gauge);
    arcPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    arcPaint.setColor(Color.RED);
    arcPaint.setStyle(Paint.Style.STROKE);
    arcPaint.setStrokeWidth(7f);
}

protected void onDraw(Canvas canvas) {
    canvas.getClipBounds(bounds);
    gaugeBackground.setBounds(bounds);
    gaugeBackground.draw(canvas);

    float padding = 5;
    float size = getWidth() < getHeight() ? getWidth() : getHeight();
    float width = size - (2 * padding);
    float height = size - (2 * padding);
    float radius = (width < height ? width /2 : height /2);

    float rectLeft = (width /2) - radius + padding;
    float rectTop = (getHeight() /2) - radius + padding;
    float rectRight = (getWidth() /2) - radius + padding + width;
    float rectBottom = (getHeight() /2) - radius + padding + height;

    RectF mRect = new RectF(rectLeft, rectTop, rectRight, rectBottom);
    canvas.drawArc(mRect, 119f, 300f, false, arcPaint);
}

有人能提供有用的信息吗? 我希望我终于得到整个RectF /绘图的东西..


I have a drawable of a gauge and I try to draw a line on it. (Fixed position, not fixed value)

Unfortunately I don't have any experience with drawing. (And I think its hard to understand)

At the moment it looks like this: https://i.stack.imgur.com/5tkXEl.png

As you can see, its not positioned right and I'm quite afraid of looking at it on other devices.

Code (Class extends View):

private void init(Context context) {
    bounds = new Rect();
    gaugeBackground = ContextCompat.getDrawable(context, R.drawable.gauge);
    arcPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    arcPaint.setColor(Color.RED);
    arcPaint.setStyle(Paint.Style.STROKE);
    arcPaint.setStrokeWidth(7f);
}

protected void onDraw(Canvas canvas) {
    canvas.getClipBounds(bounds);
    gaugeBackground.setBounds(bounds);
    gaugeBackground.draw(canvas);

    float padding = 5;
    float size = getWidth() < getHeight() ? getWidth() : getHeight();
    float width = size - (2 * padding);
    float height = size - (2 * padding);
    float radius = (width < height ? width /2 : height /2);

    float rectLeft = (width /2) - radius + padding;
    float rectTop = (getHeight() /2) - radius + padding;
    float rectRight = (getWidth() /2) - radius + padding + width;
    float rectBottom = (getHeight() /2) - radius + padding + height;

    RectF mRect = new RectF(rectLeft, rectTop, rectRight, rectBottom);
    canvas.drawArc(mRect, 119f, 300f, false, arcPaint);
}

Can someone provide helpful information? I hope I finally get the whole RectF/Drawing stuff..


原文:https://stackoverflow.com/questions/41675246
更新时间:2022-02-04 13:02

最满意答案

这完全是完全下载。 这严格依靠端点。

你不能真正推断像安装/恢复等事情

原因在于NuGet客户使用的优化,以及开发人员的开发环境。

  • NuGet客户端拥有全局包文件夹 ,这基本上意味着理想情况下每个机器只能下载一个包(人们可以为不同项目配置不同的全局包文件夹等)。

  • 接下来,项目有CI设置,那里的配置也很重要。

    • 他们是否重新生成构建机器?
    • 他们在每次运行之前清理全局包文件夹吗?
  • 另一个需要注意的是,你不能推断你的软件包的直接使用情况,还有一个更受欢迎的软件包依赖于它。

基本上,不幸的是,目前没有办法了解每个项目/每个唯一用户使用您的软件包的情况。


It's quite literally total downloads. This is strictly counting on the endpoint side.

You can't really infer things like installations/restore etc.

The reason for that is the optimizations that the NuGet clients employ, and simply the development environment of the developer.

  • The NuGet client has the global packages folder which basically means that a package would be downloaded only 1 per machine ideally (people may configure different global packages folders for different projects etc).

  • Next, projects have CI set-up, the configuration there matters as well.

    • Do they reimage the build machine?
    • Do they clean the global packages folder before each run?
  • Another caveat is that you can't infer direct usage of your package vs having a significantly more popular package depend on it.

Basically, the gist is, unfortunately no, there's currently no way you can understand the per project/per unique user usage of your package.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。