- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 NSImageView 上绘制一条 NSBezierPath 线。我正在创建 NSBezierPath 对象,设置 moveToPoint
,设置 lineToPoint
,设置 setLineWidth:
,然后在 drawRect
中我的 NSImageView
子类我正在调用 [myNSBezierPath stroke]
。这一切都按照我想要的方式工作,但我似乎无法使用 containsPoint:
方法...我尝试实现
if([myNSBezierPath containsPoint:[theEvent locationInWindow]]{
//do something
}
在我的 NSImageView 子类的 -(void)mouseUp:(NSEvent*)theEvent
中,但它永远没有反应,我确信我正在点击那条线......我做错了什么吗?我只需要检测 NSBezierPath 是否被单击。
干杯。
最佳答案
确保将鼠标单击位置转换为 ImageView 子类的坐标系,而不是窗口的坐标系(除非它们相同)。您的贝塞尔路径不知道它所绘制的偏移量,因此在执行 HitTest 时必须考虑到这一点。
此外,来自containsPoint:
文档:
This method checks the point against the path itself and the area it encloses. When determining hits in the enclosed area, this method uses the non-zero winding rule (NSNonZeroWindingRule). It does not take into account the line width used to stroke the path.
强调我的。
关于macos - 单击 NSBezierPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18555380/
我通过创建圆形 NSBezierPath 并将其添加到图形上下文的剪切区域,在自定义 View 的中心绘制圆形图像。这工作得很好,但我想知道是否可以提高绘制 View 背景(圆角居中图像外部的区域)的
我正在 NSImageView 上绘制一条 NSBezierPath 线。我正在创建 NSBezierPath 对象,设置 moveToPoint,设置 lineToPoint,设置 setLineW
是否可以为 NSBezierPath 创建自定义破折号样式? 即我想要一条线,比如说,箭头全部指向笔划的方向。 例如,这样的事情...... ->--->--->--->---> 任何想法表示赞赏..
我有以下绘图代码: [[NSColor redColor] set]; NSRect fillRect = NSMakeRect(bounds.size.width - 20.0f, 0.0f, 20
我创建了一个 NSBezierPath ,并在其上调用了 -lines 。如何在不取消分配对象的情况下从 View 中删除/删除它? 最佳答案 -lines 消息告诉 NSBezierPath 在当前
我想在 DrawRect 中使用 NSBezierPath 在我的自定义 NSView 周围绘制一个 1px 宽的边框: BorderColor.Set(); var path = NSBezierP
我有一个 NSBezierPath 需要半透明填充。当我用纯色填充它时,我得到了预期的结果。然而,当填充半透明颜色时,我得到一 strip 有圆形笔划但奇怪的矩形填充的路径。它看起来像: 我没有填充整
在使用我的应用程序时,我遇到了一些绘图问题: 我想知道为什么,回到 Obj-c,-moveToPoint() 和 -lineToPoint() 可以毫无问题地绘制所有内容,而现在,通过 swift,可
我画了一个红色圆圈。然后我想删除它。我该怎么做? class Red: NSView { var red = 255 var green = 0 var blue = 0
我第一次在 macOS 应用程序中使用 NSBezierPath、CAShapeLayer 和 CABasicAnimation。我关注了this tutorial作为起点(它与 UIBezierPa
NSBezierPath 提供了一个名为 bounds 的 API,它返回没有控制点的边界。UIBezierPath 中是否有任何等效的 API 来返回不包括控制点的路径边界? 最佳答案 我得到了解决
我遇到以下问题。我正在编写自己的类,它必须绘制指定大小的圆,并用渐变填充它。 我用一个圆圈作为 NSBezierPath 来制作它,我使用它绘制渐变 [gradient drawInBezierPat
我正在尝试画一个简单的图表。我有由线连接的正方形。这些线条是用 NSBezierPath 绘制的。我对线条使用随机颜色,这样我就可以跟随它们。我的问题是线条颜色改变。 输出 - 代码 - 我删除了绘制
我想知道是否可以在绘制的 NSBezierPath 上设置工具提示。 我问这个问题的原因如下:我正在将 NSRect 形式的形状添加到 View 中。这些矩形代表了历史时期。看到该期间的开始年份和结束
我目前正在将我的 jruby/java2d 图形绘制/布局应用程序移植到 macruby/cocoa。因此我需要获取开放的 NSBezierPath 与封闭的 NSBezierPath 的交点。 在
我尝试使用 NSBezierPath 在 300x300 像素矩形中绘制幂函数曲线,如下所示: -(void)drawPowerCurve:(float)power points:(int)numbP
好的,所以我尝试绘制一个虚线框,该虚线框被分割为我要放置内容的部分。这是我的代码: NSBezierPath *path = [NSBezierPath bezierPathWithRect:dirt
我正在制作一个简单的绘图应用程序,并使用 NSBezierPath 来绘制线条。我正在对 NSView 进行子类化。我需要制定一种方法,允许用户更改下一条路径的颜色和大小(因此用户按下一个按钮,然后下
我想更改我绘制的按钮的填充(我将 NSButton 子类化) 这是我已经得到的代码: - (void)drawRect:(NSRect)dirtyRect { // Drawing code here
使用 NSBezierPath 绘制不同的线条(用于图表)时,我在更改线条颜色/宽度时遇到了一些非常基本的问题。下面的代码应该清楚地表明我想要做什么: #import "DrawTest.h" @im
我是一名优秀的程序员,十分优秀!