Giter Site home page Giter Site 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);
GLPaintView *paintView = [[GLPaintView alloc] initWithFrame:self.view.bounds
                                                textureSize:textureSize
                                     textureBackgroundColor:[UIColor whiteColor]];
paintView.delegate = self;
[self.view addSubview:paintView];

接口说明

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

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

- (instancetype)initWithFrame:(CGRect)frame
                  textureSize:(CGSize)textureSize
       textureBackgroundColor:(UIColor *)textureBackgroundColor;
  • frame 很好理解,就是 view 的尺寸和位置。
  • textureSize 指实际生成的画布的大小,画布尺寸可以比 view 的尺寸大得多,会影响最终导出的图片的分辨率。
  • textureBackgroundColor 指画布的背景色,当使用橡皮擦的时候,实际上也只是把画笔切换成了背景色而已。

更多介绍

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

glpaintview's People

Contributors

lmf12 avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar  avatar

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.