GithubHelp home page GithubHelp logo

glpaintview's Introduction

简介

本项目是基于 OpenGL ES 实现的绘画板,实现了平滑曲线、自定义笔触、画笔大小调节、画笔颜色调节、撤销重做、橡皮擦等功能。

如果你正在寻找一个非 OpenGL ES 实现的版本,或许可以参考一下我的 另一个项目

效果预览

如何导入

  1. GLPaintView 文件夹拷贝到工程中
  2. 引入头文件 #import "GLPaintView.h"

如何使用

初始化一个 GLPaintView 的代码大概长这样:

CGFloat ratio = self.view.frame.size.height / self.view.frame.size.width;
CGFloat width = 1500;
CGSize textureSize = CGSizeMake(width, width * ratio);
UIImage *image = [UIImage imageNamed:@"paper.jpg"];
self.paintView = [[GLPaintView alloc] initWithFrame:self.view.bounds
                                        textureSize:textureSize
                                    backgroundImage:image];
paintView.delegate = self;
[self.view addSubview:paintView];

接口说明

建议只通过 GLPaintView.h 提供的接口来改变绘画板的功能和行为。

GLPaintView.h 头文件中,各种接口功能已经做了详尽的注释,这里再额外解释一下初始化方法。

- (instancetype)initWithFrame:(CGRect)frame
                  textureSize:(CGSize)textureSize
              backgroundColor:(UIColor *)backgroundColor
              backgroundImage:(UIImage *)backgroundImage;
  • frame 很好理解,就是 view 的尺寸和位置。
  • textureSize 指实际生成的画布的大小,画布尺寸可以比 view 的尺寸大得多,会影响最终导出的图片的分辨率。
  • backgroundColor 指画布的背景色,传 nil 的时候,会设置成白色。
  • backgroundImage 指背景图片,当比例与 textureSize 不同时会被拉伸。

更多介绍

在 iOS 中使用 OpenGL ES 实现绘画板

glpaintview's People

Contributors

lmf12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

glpaintview's Issues

求指导:关于橡皮功能和opengl的一些使用问题。(已经得到邮件回复还会更新,谢谢作者)

非常感谢作者的分享,非常稀少的openGLES demo。
1.从代码来看,橡皮功能是把画笔颜色设置成背景色,我的画板有需求需要画板背景。这种情况需要把glpaintview设置成透明色,如此该如何完成橡皮功能呢。
2.我有个蓝牙硬件画板,保存着离线笔记的point,可否不打开GLPaintView,直接代码生成图片呢。小白望指教。非常感谢

present到另一个含glpaintview的vc返回后重设笔刷尺寸不正常

含有glpaintview的vc1 present到另一个有glpaintview的vc2,vc2返回vc1时候用一个block重设vc1里的笔刷尺寸。
这时候vc1里的画板继续画,笔刷宽度和透明度都变得不正常,但是撤销 再重做后, 又变回block设定的正常尺寸。十分不解。

前几月问您类似问题返回后不能画,您回复过我是图形上下文,那个问题好了,现在又不懂了。。。
[email protected]给您邮箱发了附件。感激不尽

补充:只要从vc2回来,即使不用block传值,例如在vc1的viewwillappear里设随机brushsize,也会引起vc1的画板异常。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.