- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在制作一个简单的绘图应用程序,并使用 NSBezierPath
来绘制线条。我正在对 NSView 进行子类化。我需要制定一种方法,允许用户更改下一条路径的颜色和大小(因此用户按下一个按钮,然后下次他们绘制路径时,它就是指定的颜色/大小),但现在当我尝试时这样做会改变所有现有路径的颜色和大小。可以这么说,我怎样才能使它们成为“个体”呢?这是我的代码:
- (void)drawRect:(NSRect)dirtyRect
{
[path setLineWidth:5];
[path setLineJoinStyle:NSRoundLineJoinStyle];
[path setLineCapStyle:NSRoundLineCapStyle];
[path stroke];
}
- (void)mouseDown:(NSEvent *)theEvent {
NSPoint location = [theEvent locationInWindow];
NSLog(@"%f, %f", location.x, location.y);
[path moveToPoint:location];
[self setNeedsDisplay:YES];
}
- (void)mouseUp:(NSEvent *)theEvent {
}
- (void)mouseDragged:(NSEvent *)theEvent {
NSPoint location = [theEvent locationInWindow];
[path lineToPoint:location];
[self setNeedsDisplay:YES];
}
- (void)changeBrushColor:(NSString *)color {
// change color of the next path
[self setNeedsDisplay:YES]; // show it
}
所以我需要创建一个单独的 NSBezierPath 路径。
最佳答案
你必须使用2个可变数组(贝塞尔路径和颜色),一个整数变量(画笔大小)。和一个用于 BrushColor 的 UIColor 变量
-(IBAction) brushsizeFun
{
brushSize = 30; // any brush size here. better use a slider here to select size
}
-(IBAction) brushColorFun
{
brushColor = [UIColor redColor]; // Any color here. better use a color picker
}
- (void)mouseDown:(NSEvent *)theEvent {
NSPoint location = [theEvent locationInWindow];
NSLog(@"%f, %f", location.x, location.y);
[path release];
path = [[UIBezierpath alloc]init];
path.lineWidth = brushSize;
[path moveToPoint:location];
[bezierArray addObject:path];
[colorArray addObject:brushPattern];
[self setNeedsDisplay:YES];
}
- (void)drawRect:(NSRect)dirtyRect
{
int q=0;
//Draw the bezierpath and corresonding colors from array
for (UIBezierPath *_path in bezierArray)
{
UIColor *_color = [colorArray objectAtIndex:q];
[_color setStroke];
[_path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
q++;
}
}
关于objective-c - NSBezierPath 独特的线条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8108479/
对于 Prometheus 指标集合,如标题,我真的找不到只能通过 type Summary 完成的用例。 ,似乎它们都可以通过 type Histogram 以某种方式完成还。 让我们以请求并发度量
这个问题在这里已经有了答案: Ignore case while using duplicated (1 个回答) 关闭 9 个月前。 使用不区分大小写的 unique(tolower(x)) 删除
应用程序监控服务的一个有用功能是每次发生新的、独特的错误/问题/异常时发送警报(例如电子邮件)(即不是每次发生)。要么只是第一次,要么最多每次 X 次(一天或一周等)。例如,这可以通过 Visual
应用程序监控服务的一个有用功能是每次发生新的、独特的错误/问题/异常时发送警报(例如电子邮件)(即不是每次发生)。要么只是第一次,要么最多每次 X 次(一天或一周等)。例如,这可以通过 Visual
我想要相当于 DB2 中 MySql 的 GROUP_CONCAT 功能。 我尝试过 DB2 的 XML Aggrigate 函数来合并 murows。 SELECT a.ID, sub
我正在运行 python 数据库迁移脚本 (Flask-Migrate) 并添加了 alembic.ddl.imp import DefaultImpl 来解决第一组错误,但现在我收到以下错误。我正在
我有一个逗号分隔的文件“myfile.csv”,其中第 5 列是日期/时间戳。 (mm/dd/yyyy hh:mm)。 我需要列出所有包含重复日期的行(有很多) 我正在通过 cygwin 为 WinX
我使用的是 MySQL 5.7。 我有一个表格如下: -------------------------------------------------- | id | currentcy_id |
所以我有一个像这样的 ng-repeat: Join Ride /md-switch> 但是,每个 md-switch 都有相同的模型,因此当我在 Control
据我了解, Mongoose 预保存 Hook 在将文档插入集合之前但在验证发生之后触发。因此,如果一次验证失败,则不会调用预保存 Hook 。 就我而言,无论如何都会调用它们: 下面的简单代码的作用
如果我对我的目标文件执行此 grep,我会得到例如 275 作为结果。 但是我想学习 awk,所以在 awk 中尝试了这个: awk 'BEGIN { count=0 } /my pattern/
我是一名优秀的程序员,十分优秀!