标签: drawing

在 Swift 中绘制线条

UITableViewCell我使用以下代码在 a 上绘制一条水平线和一条垂直线,它在 iOS7 上运行良好。它在 Objective-C 中。

在 的子类中,

@property (strong, nonatomic) NSMutableArray *columns;

- (void)drawRect:(CGRect)rect
{
    // In iOS7, you have to set the cell's background color to clear otherwise the drawing lines won't appear
    self.backgroundColor = [UIColor clearColor];

    // Drawing the vertical line
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSetRGBStrokeColor(ctx, 0.5, 0.5, 0.5, 1.0);
    CGContextSetLineWidth(ctx, 0.75);
    for (int i = 0; i < self.columns.count; i++) {
        CGFloat f = [((NSNumber*) [self.columns objectAtIndex:i]) floatValue];
        CGContextMoveToPoint(ctx, f, 10);
        CGContextAddLineToPoint(ctx, f, self.bounds.size.height …
Run Code Online (Sandbox Code Playgroud)

drawing objective-c ios uigraphicscontext swift

1
推荐指数
1
解决办法
1万
查看次数

NSSearchField:如何隐藏图标和边框?

这是这个问题的重复。因为我对 Swift 的了解都是 Swift3,所以我想知道是否有人可以“翻译”这个答案中建议的解决方案。

\n\n

还:

\n\n

我制作了一个没有边框的 NSSearchfield,将其放入框架视图中,它仍然显示灰色边框。我很好奇如何禁用动画灰色边框,甚至如何更改灰色“搜索”线的颜色。

\n\n

我的丑陋结果现在看起来像这样:

\n\n

在此输入图像描述

\n\n

如果有人能告诉我如何管理这个困难的 NSSearchfield,那将是一个很大的帮助。

\n\n

//更新

\n\n

根据firstinq\xc2\xb4s的回答,图标现在消失了,这很棒。但仍然存在令人不安的动画灰色边框。我可以\xc2\xb4t理解:NSSearchFielt位于NSView(蓝色边框)内。所以 NSView 之外的所有内容都应该隐藏,对吧?那么为什么我仍然看到灰色边框?cell.isBordered = false没有效果。\n有什么建议如何处理吗?

\n\n

在此输入图像描述

\n\n

这就是我绘制 NSView 边框的方法:

\n\n
class SearchFieldBorder: NSView {\n\n    override func draw(_ dirtyRect: NSRect) {\n        super.draw(dirtyRect)\n\n        self.layer?.borderWidth = 1\n        self.layer?.borderColor = NSColor.blue.cgColor\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

cocoa drawing subclass nssearchfield swift

1
推荐指数
1
解决办法
1357
查看次数

将原始像素数组绘制到窗口上(C++ WinAPI)

我有两个缓冲区,大小和类型都相同 ( uint32_t*)。这些缓冲区应该代表渲染/绘图系统的前缓冲区和后缓冲区。它们存储 32 位像素数据。

我使用以下方式声明并初始化这些缓冲区:

private:
    ...
    uint32_t* frontBuf;
    uint32_t* backBuf;
    size_t    gbufSize;
    ...
public:
    void Initialize() {
        ...  
        // prepare for rendering
        gbufSize = sizeof(uint32_t) * w * h;
        backBuf  = (uint32_t*)malloc(gbufSize);
        frontBuf = (uint32_t*)malloc(gbufSize);
        ...
    }
Run Code Online (Sandbox Code Playgroud)

我还使用以下方法获取控制台的输出、窗口和设备句柄Initialize()

        // get handles
        cwd = GetDC(GetConsoleWindow());
        chd = GetStdHandle(STD_OUTPUT_HANDLE);
        cwn = GetConsoleWindow();
Run Code Online (Sandbox Code Playgroud)

然后我有几个绘图方法,比如一个SetPixel方法:

    size_t GFlatten(int x, int y) {
        return y * h + x;
    }

    void GSetPixel(int x, int y, uint32_t color) {
        backBuf[GFlatten(x, …
Run Code Online (Sandbox Code Playgroud)

c++ graphics winapi buffer drawing

1
推荐指数
1
解决办法
2423
查看次数

0
推荐指数
1
解决办法
1794
查看次数

将填充更改为已绘制的NSBezierPath

我想改变我画的按钮的填充(我将NSButton子类化)

这是我已经得到的代码:

- (void)drawRect:(NSRect)dirtyRect {
// Drawing code here.
// Create the Gradient 
NSGradient *fillGradient = [[NSGradient alloc] initWithStartingColor:[NSColor lightGrayColor] endingColor:[NSColor darkGrayColor]];
// Create the path
aPath = [NSBezierPath bezierPath];

[aPath moveToPoint:NSMakePoint(10.0, 0.0)];
[aPath lineToPoint:NSMakePoint(85.0, 0.0)];
[aPath lineToPoint:NSMakePoint(85.0, 20.0)];
[aPath lineToPoint:NSMakePoint(10.0, 20.0)];
[aPath lineToPoint:NSMakePoint(0.0, 10.0)];
[aPath lineToPoint:NSMakePoint(10.0, 0.0)];

[fillGradient drawInBezierPath:aPath angle:90.0];
[fillGradient release];
}

- (void)mouseDown:(NSEvent *)theEvent {
    NSGradient *fillGradient = [[NSGradient alloc] initWithStartingColor:[NSColor lightGrayColor] endingColor:[NSColor darkGrayColor]];
    [fillGradient drawInBezierPath:aPath angle:-90.0];
}
Run Code Online (Sandbox Code Playgroud)

我收到一个EXC_BAD_ACCESS信号 我该怎么做?

cocoa drawing objective-c

0
推荐指数
1
解决办法
2041
查看次数

将图像从工具栏拖放到视图画布

我想制作一个应用程序,我需要一个工具栏.工具栏将具有各种数量的对象(图像).这些对象应该是可拖动的,并放置在它正上方的视图上.

这是一种绘图应用程序,用户可以在画布上选择任何形状和位置.谁能告诉我最好的方法呢?

提前致谢.

iphone drawing drag-and-drop ipad

0
推荐指数
1
解决办法
1106
查看次数

silverlight中的交叉线程访问无效

我正在使用silverlight 3.0进行申请.在那个应用程序中,我有一个公共方法

public void DrawWavform()
{
     Line[,] line = new Line[10,200];
     line[i,j]= new Line();//i am getting error here of invalid thread access
    //some operation

}
Run Code Online (Sandbox Code Playgroud)

在应用程序中,我根据用户输入创建不同的线程,并从新创建的线程调用DrawWaveform方法.我想并行操作.请建议我解决.谢谢提前.

silverlight multithreading drawing line visual-studio-2010

0
推荐指数
1
解决办法
6657
查看次数

使用CSS绘制圆角三角形

我想围绕这个三角形:

http://jsfiddle.net/RNsW2/

是这样的:

在此输入图像描述

有没有办法用CSS做到这一点?我不想使用图像.

css drawing

0
推荐指数
1
解决办法
5622
查看次数

将HTML5 Canvas.arc移植到Android和逆时针

我正在将Skycons移植到Android上,我的大部分工作都在工作,除了月亮使用Canvas.arc带有逆时针参数的HTML5 .

我试图这样实现:

RectF rect = new RectF();

public void arcR( Path path, float x, float y, float radius, double startAngle, double endAngle, boolean anticlockwise ){
    // Set bounds
    rect.set( x - radius, y - radius, x + radius, y + radius );

    // Convert to degrees
    startAngle = Math.toDegrees(startAngle);
    endAngle = Math.toDegrees(endAngle);

    if(anticlockwise){
        startAngle = 360 - startAngle;
        endAngle = 360 - endAngle;
    }

    endAngle = endAngle - startAngle;

    path.addArc(rect, (float)startAngle, (float)endAngle);
}
Run Code Online (Sandbox Code Playgroud)

我认为我没有正确实施逆时针,因为在我的设备上绘制月球(基于Skycons)看起来像这样:

截图

android drawing android-canvas

0
推荐指数
1
解决办法
1089
查看次数

gluPerspective不工作

我使用gluPerspective主要增加绘制距离,但它似乎不起作用.

这是它在我的代码中显示的方式:

gluPerspective(0, 70/70, 0, 4333);
Run Code Online (Sandbox Code Playgroud)

ratio:窗口Width和Height都是700,它们是常数,如果想知道的话.

fovy:我把0,因为,"他们"说使用45是非常好画,但它停止在屏幕上绘图.

这是完整的代码:

#include <Windows.h>
#include <gl\GL.h>
#include <gl/glut.h>

    WNDCLASSEX wclass;
    MSG msg;
    HWND hwnd;
    HDC hdc;

    HDC p_hdc;

    float t;
    int red, green, blue, x, y, z;
    void update()
    {
        RECT rec;
        GetClientRect(hwnd, &rec);
        InvalidateRect(hwnd, &rec, false);
        UpdateWindow(hwnd);
        t += 0.5f;
    }
    void game()
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glClearColor(0, 0, 0, 0);
        float norm = 1;
        float z = 0;
        red = 255;
        green = 255;
        glPushMatrix();
        glRotatef(t, 0, 1, 1);
        glBegin(GL_TRIANGLES);
        glColor3f(255, …
Run Code Online (Sandbox Code Playgroud)

c++ opengl drawing

0
推荐指数
1
解决办法
1635
查看次数