|
@@ -0,0 +1,708 @@
|
|
|
+//
|
|
|
+// KMDrawView.h
|
|
|
+// KMDrawViewDemo
|
|
|
+//
|
|
|
+// Created by zhudongyong on 13-9-23.
|
|
|
+// Copyright (c) 2013年 kdanmobile. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+#import <Foundation/Foundation.h>
|
|
|
+#import "LineProcessTypes.h"
|
|
|
+#import "Recognise.h"
|
|
|
+#import "ESRenderTypes.h"
|
|
|
+#import "KMDrawViewTypes.h"
|
|
|
+#import "ESContextTypes.h"
|
|
|
+#import "TextureTypes.h"
|
|
|
+#import "ESShaderTools.h"
|
|
|
+
|
|
|
+#if TARGET_OS_IOS
|
|
|
+#import <UIKit/UIKit.h>
|
|
|
+#if kDigitPenEnable
|
|
|
+#import "PenManager.h"
|
|
|
+#endif//kDigitPenEnable
|
|
|
+#else
|
|
|
+#import <AppKit/AppKit.h>
|
|
|
+#import "UIImage+Mac.h"
|
|
|
+#import "UIColor+Mac.h"
|
|
|
+#import "UIView+Mac.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+@protocol KMDrawViewDelegate;
|
|
|
+
|
|
|
+//控制参数校准
|
|
|
+typedef float (^ParameterAdjust)(float originValue);
|
|
|
+
|
|
|
+@interface KMDrawView : UIView
|
|
|
+#if kDigitPenEnable
|
|
|
+<PenManagerTouchEventDelegate>
|
|
|
+#endif
|
|
|
+
|
|
|
+#if TARGET_OS_IOS
|
|
|
+@property (nonatomic, readonly) UIView *touchRefView;//手势点转换View
|
|
|
+#endif
|
|
|
+
|
|
|
+#pragma mark - Normal
|
|
|
+/** 当前控件被缩放比例
|
|
|
+ */
|
|
|
+@property (nonatomic, readonly) CGSize scale;
|
|
|
+
|
|
|
+/** 当前控件初始数据大小
|
|
|
+ */
|
|
|
+@property (nonatomic, readonly) CGSize bufferSize;
|
|
|
+
|
|
|
+/** 默认自动校准被Cancel的Line,Default is true.
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL adjustCancelLine;
|
|
|
+
|
|
|
+/** 触点越界(超过KMDrawView边界),是否需要关闭线条渲染,Default is true.
|
|
|
+ */
|
|
|
+@property (nonatomic, readwrite) BOOL shoudCancelDrawForPointBounds;
|
|
|
+
|
|
|
+/** 触点是否越界
|
|
|
+ */
|
|
|
+@property (nonatomic, readonly) BOOL pointBounds;
|
|
|
+
|
|
|
+#if PreModelEnable
|
|
|
+/** 效果预览模式,涂抹等效果时也能看到相应笔刷效果
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL isDebug;
|
|
|
+#endif
|
|
|
+
|
|
|
+/** 硬件压感控制
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL enableDevicePress;
|
|
|
+
|
|
|
+/** 压感常规值 (0,1), `enableDevicePress` 为YES时生效。
|
|
|
+ */
|
|
|
+@property (nonatomic) float normalPress; //default is 0.9
|
|
|
+
|
|
|
+#if EnableRecogition
|
|
|
+#pragma mark - Shape Recognize
|
|
|
+/** 设置是否开启图形识别功能,默认为关闭状态。
|
|
|
+ @note 目前该功能尚不可用,建议不要开启。
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+@property (nonatomic, readwrite) BOOL enableRecogition; //图形识别开关
|
|
|
+
|
|
|
+@property (nonatomic, readwrite) float recogPointScale; //Scale
|
|
|
+
|
|
|
+/** 设置图形识别种类`ShapeType`,默认支持ShapeTypeLine(直线)、ShapeTypeTriangle(三角形)、ShapeTypeCircle(圆)、
|
|
|
+ ShapeTypeEllipse(椭圆)、ShapeTypeDiarec(矩形)、ShapeTypeArrow(箭头)、ShapeTypeParallelogram(平行四边形)
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+@property (nonatomic, readwrite) ShapeType shapesMark; //图形种类
|
|
|
+#endif//EnableRecogition
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/// 笔刷类型
|
|
|
+#pragma mark - Brush Type Setting
|
|
|
+//铅笔笔刷
|
|
|
+@property (nonatomic) ESBrushType brushType;
|
|
|
+
|
|
|
+#pragma mark - 柳叶笔高斯模糊边缘半径
|
|
|
+@property (nonatomic) float gaussianRadius;
|
|
|
+
|
|
|
+/// 混合模式
|
|
|
+#pragma mark - Blend Type Setting
|
|
|
+//混合模式
|
|
|
+@property (nonatomic) ESLayerBlendType blendType;
|
|
|
+
|
|
|
+//混合着色器
|
|
|
+@property (nonatomic, copy) NSString *blendFragmentShaderString;
|
|
|
+#if TARGET_OS_IOS
|
|
|
+#pragma mark Shaders
|
|
|
+//主线 顶点着色器
|
|
|
+@property (nonatomic, copy) NSString *baselineVertexShaderString;
|
|
|
+//主线 片段着色器
|
|
|
+@property (nonatomic, copy) NSString *baselineFragmentShaderString;
|
|
|
+//子线 顶点着色器
|
|
|
+@property (nonatomic, copy) NSString *sublineVertexShaderString;
|
|
|
+//子线 片段着色器
|
|
|
+@property (nonatomic, copy) NSString *sublineFragmentShaderString;
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+/// 常用参数
|
|
|
+#pragma mark - Common Parameters Setting
|
|
|
+//颜色
|
|
|
+@property (nonatomic, retain) UIColor *renderColor;
|
|
|
+//不透明度, [0, 1], default is 1.
|
|
|
+@property (nonatomic) float opacity;
|
|
|
+/** 线半径
|
|
|
+ */
|
|
|
+@property (nonatomic) float radius;
|
|
|
+//流量, [0, 1], default is 1.
|
|
|
+@property (nonatomic) float flow;
|
|
|
+/** 点延迟
|
|
|
+ */
|
|
|
+@property (nonatomic) NSUInteger trackNum;
|
|
|
+
|
|
|
+///涂抹类型笔刷
|
|
|
+#pragma mark - Smudge Parameters
|
|
|
+//潮湿
|
|
|
+@property (nonatomic) float moistQuantity;
|
|
|
+//载入
|
|
|
+@property (nonatomic) float loadQuantity;
|
|
|
+//混合
|
|
|
+@property (nonatomic) float mixQuantity;
|
|
|
+//涂抹渐隐控制
|
|
|
+@property (nonatomic) BOOL smudgeControl;
|
|
|
+//控制值
|
|
|
+@property (nonatomic) float smudgeControlValue;
|
|
|
+
|
|
|
+
|
|
|
+/// 笔刷纹理
|
|
|
+#pragma mark - Texture
|
|
|
+//纹理类型,除TextureTypeNormal外均为矢量纹理
|
|
|
+@property (nonatomic) TextureType textureType;
|
|
|
+
|
|
|
+//硬度
|
|
|
+@property (nonatomic) float hardness;
|
|
|
+
|
|
|
+/** 矢量笔刷相关控制参数
|
|
|
+ TextureTypeNormal 无
|
|
|
+ TextureTypeCircle 无
|
|
|
+ TextureTypeRing 圆环半径
|
|
|
+ TextureTypeRectangle 宽高比
|
|
|
+ */
|
|
|
+@property (nonatomic) float textureControlValue;
|
|
|
+
|
|
|
+/**笔刷贴图,纹理
|
|
|
+ */
|
|
|
+//@property (nonatomic, retain) UIImage *textureImage;
|
|
|
+@property (nonatomic, retain) NSArray *textureImages;
|
|
|
+
|
|
|
+///Flip
|
|
|
+/** X 方向翻转
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL flipX;
|
|
|
+/** Y 方向翻转
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL flipY;
|
|
|
+
|
|
|
+#pragma mark - Mask
|
|
|
+/// 遮罩
|
|
|
+/** 是否允许遮罩
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL needMaskTexture;
|
|
|
+/** 遮罩纹理
|
|
|
+ */
|
|
|
+@property (nonatomic) float maskScale;
|
|
|
+/** 遮罩纹理
|
|
|
+ */
|
|
|
+@property (nonatomic, strong) UIImage *maskImage;
|
|
|
+
|
|
|
+
|
|
|
+///常规参数设置
|
|
|
+#pragma mark - Base Setting
|
|
|
+
|
|
|
+/** 是否开启点间距控制,关闭则仅画获取到的Touch点
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL pointsDistanceEnabled;
|
|
|
+/** 点间距 [0.01, n]
|
|
|
+ */
|
|
|
+@property (nonatomic) float pointsDistance;
|
|
|
+//Smooth:平滑
|
|
|
+@property (nonatomic) BOOL smoothEnabled;
|
|
|
+/** 速度敏感因子
|
|
|
+ */
|
|
|
+@property (nonatomic) float speedSencitive;
|
|
|
+/** 触控灵敏度
|
|
|
+ */
|
|
|
+@property (nonatomic) float sensitivity;
|
|
|
+//真彩纹理
|
|
|
+@property (nonatomic) BOOL colorFul;
|
|
|
+//细尺寸处理方式
|
|
|
+@property (nonatomic, readwrite) ESLineProcessType lineProcessType;
|
|
|
+
|
|
|
+
|
|
|
+///控制
|
|
|
+#pragma mark - 控制
|
|
|
+#pragma mark 尺寸控制
|
|
|
+/** 最小半径
|
|
|
+ */
|
|
|
+@property (nonatomic) float minRadius;
|
|
|
+/** 最小半径
|
|
|
+ */
|
|
|
+@property (nonatomic) float maxRadius;
|
|
|
+/** 初始半径
|
|
|
+ */
|
|
|
+@property (nonatomic) float startRadius;
|
|
|
+/** 起始点控制
|
|
|
+ */
|
|
|
+@property (nonatomic) float strokeControlValue;
|
|
|
+/** 线条结束点半径
|
|
|
+ */
|
|
|
+@property (nonatomic) float endRadius;
|
|
|
+/** 半径抖动,(0, 1]
|
|
|
+ */
|
|
|
+@property (nonatomic) float radiusTingle;
|
|
|
+/** 半径控制
|
|
|
+ */
|
|
|
+@property (nonatomic) LPControlParams radiusControl;
|
|
|
+
|
|
|
+#pragma mark 位置控制
|
|
|
+//两轴
|
|
|
+@property (nonatomic) BOOL disTwoAxes;
|
|
|
+//散布
|
|
|
+@property (nonatomic) float distribution;
|
|
|
+/** 散布控制
|
|
|
+ */
|
|
|
+@property (nonatomic) LPControlParams distributionControl;
|
|
|
+
|
|
|
+#pragma mark 渲染数量控制
|
|
|
+//数量
|
|
|
+@property (nonatomic) float distributionCount;
|
|
|
+//数量抖动
|
|
|
+@property (nonatomic) float distributionCountTingle;
|
|
|
+//散布数量控制
|
|
|
+@property (nonatomic) LPControlParams distributionCountControl;
|
|
|
+
|
|
|
+#pragma mark - 角度控制
|
|
|
+//***************** 线半径 *****************
|
|
|
+/** 纹理角度, [-M_PI, M_PI], default is 0.0 .
|
|
|
+ */
|
|
|
+@property (nonatomic) float radian;
|
|
|
+/** 线条初始方向
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL startRadianEnable;
|
|
|
+/** 纹理方向跟随线条方向
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL moveRadianEnable;
|
|
|
+
|
|
|
+//***************** Flip Tingle *****************
|
|
|
+/** X 方向翻转抖动
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL flipXTingle;
|
|
|
+/** Y 方向翻转抖动
|
|
|
+ */
|
|
|
+@property (nonatomic) BOOL flipYTingle;
|
|
|
+///角度控制
|
|
|
+//***************** 角度控制 *****************
|
|
|
+/** 角度抖动, [0, 1], default is 0.0 .
|
|
|
+ */
|
|
|
+@property (nonatomic) float radianTingle;
|
|
|
+//角度控制
|
|
|
+@property (nonatomic) LPControlParams radianControl;
|
|
|
+
|
|
|
+#pragma mark - 圆度控制
|
|
|
+/** 圆度, (0.1, 1], default is 1.0 .
|
|
|
+ */
|
|
|
+@property (nonatomic) float roundness;
|
|
|
+/** 圆度抖动,(0, 1],default is 0.0 .
|
|
|
+ */
|
|
|
+@property (nonatomic) float roundnessTingle;
|
|
|
+/** 最小圆度,[0, 1], default is 0.
|
|
|
+ */
|
|
|
+@property (nonatomic) float minRoundness;
|
|
|
+/** 圆度控制
|
|
|
+ */
|
|
|
+@property (nonatomic) LPControlParams roundnessControl;
|
|
|
+
|
|
|
+#pragma mark - 流量控制
|
|
|
+/** 最小流量, [0, 1], default is 0.01
|
|
|
+ */
|
|
|
+@property (nonatomic) float minFlow;
|
|
|
+/** 最大流量, [0, 1], default is 0.01
|
|
|
+ */
|
|
|
+@property (nonatomic) float maxFlow;
|
|
|
+/** 流量抖动, [0, 1], default is 0.
|
|
|
+ */
|
|
|
+@property (nonatomic) float flowTingle;
|
|
|
+/** 流量控制
|
|
|
+ */
|
|
|
+@property (nonatomic) LPControlParams flowControl;
|
|
|
+/** 衰减,[0,1000]
|
|
|
+ */
|
|
|
+@property (nonatomic) float decay;
|
|
|
+
|
|
|
+#pragma mark - 纹理控制
|
|
|
+//纹理抖动
|
|
|
+@property (nonatomic) BOOL textureTingleEnabled;
|
|
|
+//纹理控制
|
|
|
+@property (nonatomic) LPControlParams textureControl;
|
|
|
+
|
|
|
+#pragma mark - 颜色控制
|
|
|
+//背景色
|
|
|
+@property (nonatomic, retain) UIColor *backRenderColor;
|
|
|
+/** 前景/背景动态, [0, 1], default is 0
|
|
|
+ */
|
|
|
+@property (nonatomic) float colorTingle;
|
|
|
+/** 颜色抖动控制
|
|
|
+ */
|
|
|
+@property (nonatomic) LPControlParams colorControl;
|
|
|
+
|
|
|
+#pragma mark - HSB 抖动
|
|
|
+/** hue 抖动, [0, 1], default is 0.
|
|
|
+ */
|
|
|
+@property (nonatomic) float hueTingle;
|
|
|
+/** 饱和度抖动, [0, 1], default is 0.
|
|
|
+ */
|
|
|
+@property (nonatomic) float saturationTingle;
|
|
|
+/** 亮度抖动, [0, 1], default is 0.
|
|
|
+ */
|
|
|
+@property (nonatomic) float brightnessTingle;
|
|
|
+
|
|
|
+#pragma mark - 双重画笔
|
|
|
+@property (nonatomic) BOOL repeatedlyRenderEnabled;
|
|
|
+@property (nonatomic, retain) UIImage *slTextureImage;
|
|
|
+// radius
|
|
|
+@property (nonatomic) float slRadius;
|
|
|
+// pointsDistance
|
|
|
+@property (nonatomic) float slPointsDistance;
|
|
|
+// distribution
|
|
|
+@property (nonatomic) float slDistribution;
|
|
|
+//两轴
|
|
|
+@property (nonatomic) BOOL slDistbTwoAxes;
|
|
|
+//数量
|
|
|
+@property (nonatomic) float slDistbCount;
|
|
|
+//半径关联类型
|
|
|
+@property (nonatomic) ESRadiusRelationType slRadiusRelationType;
|
|
|
+//关联值
|
|
|
+@property (nonatomic) float relationValue;
|
|
|
+
|
|
|
+#pragma mark - Undo
|
|
|
+/** 被修改过的标志(自上次保存后,是否有执行过编辑、画点、贴图等操作)
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+@property (nonatomic, readonly) BOOL edited; //上次Mark后是否被编辑过
|
|
|
+
|
|
|
+/** 是否开启自动Mark功能,默认为NO
|
|
|
+ @note 开启后,`EAGLView`将自动保存每一笔操作
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+@property (nonatomic, readwrite) BOOL autoMark; //是否自动Mark,默认为NO
|
|
|
+
|
|
|
+/** 是否需要绘制Touches Cancel的线条
|
|
|
+ */
|
|
|
+@property (nonatomic, readwrite) BOOL needCancelLine; //AutoMark为真是起作用
|
|
|
+
|
|
|
+/** Mark 图片的时间间隔,默认为0,即每一笔结束都将执行
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+@property (nonatomic, readwrite) float markTimeInterval;//保存时间间隔,默认为0秒
|
|
|
+
|
|
|
+/** 设定Undo 缓存文件目录,默认为“/Library/Cache/TempDirectory”,在Reset/变更目录/程序结束后,将清空该目录
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+@property (nonatomic, assign) NSString *tempDirectory;//undo redo缓存文件存储目录
|
|
|
+
|
|
|
+
|
|
|
+@property (nonatomic, assign) id<KMDrawViewDelegate> delegate;
|
|
|
+
|
|
|
+
|
|
|
+#if TARGET_OS_IOS
|
|
|
+- (void)setBaselineVertexShaderString:(NSString *)baselineVertexShaderString
|
|
|
+ fragmentShaderString:(NSString *)baselineFragmentShaderString;
|
|
|
+- (void)setSublineVertexShaderString:(NSString *)sublineVertexShaderString
|
|
|
+ fragmentShaderString:(NSString *)sublineFragmentShaderString;
|
|
|
+#endif
|
|
|
+
|
|
|
+//Draw
|
|
|
+- (void)clear;
|
|
|
+- (void)clearOnline:(BOOL)online;
|
|
|
+- (void)clearWithColor:(UIColor*)color online:(BOOL)online;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+
|
|
|
+@interface KMDrawView (KMDrawViewDrawing)
|
|
|
+
|
|
|
+- (BOOL)isLining;
|
|
|
+
|
|
|
+/// 画线
|
|
|
+/** 绘制指定数目的一组点
|
|
|
+ */
|
|
|
+- (CGRect)drawPoints:(LPPoint*)points count:(NSUInteger)count;
|
|
|
+- (CGRect)drawPoints:(LPPoint*)points count:(NSUInteger)count layerType:(ESRenderLayerType)layerType;
|
|
|
+
|
|
|
+/** 开始绘一条线
|
|
|
+ @param point CGPoint类型,所捕获的点坐标
|
|
|
+ @param pressure float类型,所捕获的点对应的压力值
|
|
|
+ @param altitude float类型,所捕获的点对应的触控笔斜度值
|
|
|
+ @param online 是否在线渲染,当为YES时,渲染出来即可见
|
|
|
+ */
|
|
|
+- (void)drawingWithBeginPoint:(CGPoint)point
|
|
|
+ pressure:(float)pressure
|
|
|
+ altitude:(float)altitude
|
|
|
+ online:(BOOL)online;
|
|
|
+- (void)drawingWithBeginPoint:(CGPoint)point;
|
|
|
+- (void)drawingWithBeginPoint:(CGPoint)point
|
|
|
+ online:(BOOL)online;
|
|
|
+- (void)drawingWithBeginPoint:(CGPoint)point
|
|
|
+ pressure:(float)pressure
|
|
|
+ online:(BOOL)online;
|
|
|
+
|
|
|
+/** 获取到一个TouchMove消息
|
|
|
+ @param point CGPoint类型,所捕获的点坐标
|
|
|
+ @param pressure float类型,所捕获的点对应的压力值
|
|
|
+ @param altitude float类型,所捕获的点对应的触控笔斜度值
|
|
|
+ @param online 是否在线渲染,当为YES时,渲染出来即可见
|
|
|
+ */
|
|
|
+- (void)drawingWithMoveToPoint:(CGPoint)point
|
|
|
+ pressure:(float)pressure
|
|
|
+ altitude:(float)altitude
|
|
|
+ online:(BOOL)online;
|
|
|
+- (void)drawingWithMoveToPoint:(CGPoint)point;
|
|
|
+- (void)drawingWithMoveToPoint:(CGPoint)point
|
|
|
+ online:(BOOL)online;
|
|
|
+- (void)drawingWithMoveToPoint:(CGPoint)point
|
|
|
+ pressure:(float)pressure
|
|
|
+ online:(BOOL)online;
|
|
|
+
|
|
|
+/** 获取到一个TouchEnd消息
|
|
|
+ @param point CGPoint类型,所捕获的点坐标
|
|
|
+ @param pressure float类型,所捕获的点对应的压力值
|
|
|
+ @param altitude float类型,所捕获的点对应的触控笔斜度值
|
|
|
+ @param online 是否在线渲染,当为YES时,渲染出来即可见
|
|
|
+ */
|
|
|
+- (void)drawingWithEndPoint:(CGPoint)point
|
|
|
+ pressure:(float)pressure
|
|
|
+ altitude:(float)altitude
|
|
|
+ online:(BOOL)online;
|
|
|
+- (void)drawingWithEndPoint:(CGPoint)point;
|
|
|
+- (void)drawingWithEndPoint:(CGPoint)point
|
|
|
+ online:(BOOL)online;
|
|
|
+- (void)drawingWithEndPoint:(CGPoint)point
|
|
|
+ pressure:(float)pressure
|
|
|
+ online:(BOOL)online;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark - Image
|
|
|
+@interface KMDrawView (Image)
|
|
|
+
|
|
|
+/// 获取图片
|
|
|
+
|
|
|
+//获取已绘制图片
|
|
|
+- (UIImage*)image;
|
|
|
+
|
|
|
+/** 获取指定区域图片
|
|
|
+ @param rect 设定待获取图片的区域
|
|
|
+ @return 获取指定区域的图片
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (UIImage*)imageWithRect:(CGRect)rect;
|
|
|
+
|
|
|
+/** 获取指定区域图片
|
|
|
+ @param rect 设定待获取图片的区域
|
|
|
+ @return 获取指定区域的图片
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (CGImageRef)newCGImageWithRect:(CGRect)rect;
|
|
|
+
|
|
|
+/** 获取指定区域图片数据,获取指定区域的图片数据,RGBA类型
|
|
|
+ @param data Input 指定待读入的数据地址
|
|
|
+ @param rect 设定待获取图片数据的区域
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (void)readData:(void*)data rect:(CGRect)rect;
|
|
|
+- (void)readData:(void*)data bufferRect:(CGRect)rect;
|
|
|
+//
|
|
|
+///** 获取RGB数据, pix * 3
|
|
|
+// @param data Input 指定待读入的数据地址
|
|
|
+// @param rect 设定待获取图片数据的区域
|
|
|
+// @return 获取指定区域的图片数据,RGBA类型
|
|
|
+// @since Available in iOS 4.3 and later.
|
|
|
+// */
|
|
|
+//- (void)readRGBData:(void*)data rect:(CGRect)rect;
|
|
|
+//
|
|
|
+///** 获取Alpha数据 pix * 1
|
|
|
+// @param data Input 指定待读入的数据地址
|
|
|
+// @param rect 设定待获取图片数据的区域
|
|
|
+// @return 获取指定区域的图片数据,RGBA类型
|
|
|
+// @since Available in iOS 4.3 and later.
|
|
|
+// */
|
|
|
+//- (void)readAlphaData:(void*)data rect:(CGRect)rect;
|
|
|
+//
|
|
|
+
|
|
|
+/// 贴(设置)图片
|
|
|
+
|
|
|
+/** 用Cover方式在原有图像上面贴图
|
|
|
+ @param image 待贴图的图片,如果图片为空,则不会做任何事情。
|
|
|
+ @param rect 待贴图的位置及区域
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (void)drawImage:(UIImage*)image inRect:(CGRect)rect;
|
|
|
+
|
|
|
+/** 采用Cover方式使用Image数据在原有图像上面贴图
|
|
|
+ @param imageData 待贴图的图片的数据,是从`CGContextRef`拿出来的RGBA bytes数据,如果数据为空,则不会做任何事情。
|
|
|
+ @param dataSize 待贴图的图片的尺寸(宽、高)。
|
|
|
+ @param rect 待贴图的位置及区域
|
|
|
+ @note 在不考虑其它(图片转数据)因素,同样大小的图片,采用`drawData:dataSize:rect:`方法效率比`drawImage:rect:`更好。例如内嵌的`ImageUndoManager`采用数据比采用`UIImage`快近20倍。
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (void)drawData:(unsigned char*)imageData dataSize:(CGSize)dataSize inRect:(CGRect)rect;
|
|
|
+
|
|
|
+/** 采用Cover方式使用Image在原有图像上面贴旋转图
|
|
|
+ @param image 待贴图的图片,如果image为空,则不会做任何事情。
|
|
|
+ @param size 待贴图的区域的大小。
|
|
|
+ @param center 待贴图的中心位置。
|
|
|
+ @param radian 图片旋转角度。如果角度为 0 时,效果同`drawImage:rect:`。
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (void)drawImage:(UIImage *)image inSize:(CGSize)size atCenter:(CGPoint)center radian:(float)radian;
|
|
|
+
|
|
|
+- (void)drawImage:(UIImage *)image inSize:(CGSize)size atCenter:(CGPoint)center radian:(float)radian anchorPoint:(CGPoint)archoPoint;
|
|
|
+
|
|
|
+/** 采用Cover方式使用Image数据在原有图像上面贴旋转图
|
|
|
+ @param imageData 待贴图的图片的数据,是从`CGContextRef`拿出来的RGBA bytes数据,如果数据为空,则不会做任何事情。
|
|
|
+ @param dataSize 待贴图的图片的尺寸(宽、高)。
|
|
|
+ @param size 待贴图的区域的大小。
|
|
|
+ @param center 待贴图的中心位置。
|
|
|
+ @param radian 图片旋转角度。如果角度为0时,效果同`drawData:dataSize:rect:`。
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (void)drawData:(unsigned char*)imageData dataSize:(CGSize)dataSize inSize:(CGSize)size atCenter:(CGPoint)center radian:(float)radian;
|
|
|
+
|
|
|
+/** 用Replace方式替换原图
|
|
|
+ @param image 待贴图的图片,如果图片为空,则不会做任何事情。
|
|
|
+ @param rect 待替换的位置及区域
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (void)setImage:(UIImage*)image inRect:(CGRect)rect;
|
|
|
+- (void)setImage:(UIImage*)image inBufferRect:(CGRect)bufferRect;
|
|
|
+
|
|
|
+/** 采用Replace方式使用Image数据替换指定区域的图片
|
|
|
+ @param imageData 待贴图的图片的数据,是从`CGContextRef`拿出来的RGBA bytes数据,如果数据为空,则不会做任何事情。
|
|
|
+ @param dataSize 待贴图的图片的尺寸(宽、高)。
|
|
|
+ @param rect 待贴图的位置及区域
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (void)setData:(unsigned char*)imageData dataSize:(CGSize)dataSize inRect:(CGRect)rect;
|
|
|
+- (void)setData:(unsigned char*)imageData
|
|
|
+ dataSize:(CGSize)dataSize
|
|
|
+ inRect:(CGRect)rect
|
|
|
+ isUndo:(BOOL)undo;
|
|
|
+
|
|
|
+/** 采用Replace方式使用Image替换原有旋转矩形区域内的图
|
|
|
+ @param image 待贴图的图片,如果image为空,则不会做任何事情。
|
|
|
+ @param size 待贴图的区域的大小。
|
|
|
+ @param center 待贴图的中心位置。
|
|
|
+ @param radian 图片旋转角度。如果角度为0时,效果同`setImage:rect:`。
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (void)setImage:(UIImage *)image inSize:(CGSize)size atCenter:(CGPoint)center radian:(float)radian;
|
|
|
+
|
|
|
+/** 采用Replace方式使用Image数据替换旋转矩形区域内的图
|
|
|
+ @param imageData 待贴图的图片的数据,是从`CGContextRef`拿出来的RGBA bytes数据,如果数据为空,则不会做任何事情。
|
|
|
+ @param dataSize 待贴图的图片的尺寸(宽、高)。
|
|
|
+ @param size 待贴图的区域的大小。
|
|
|
+ @param center 待贴图的中心位置。
|
|
|
+ @param radian 图片旋转角度。如果角度为0时,效果同`setData:dataSize:rect:`。
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (void)setData:(unsigned char *)imageData dataSize:(CGSize)dataSize inSize:(CGSize)size atCenter:(CGPoint)center radian:(float)radian;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+#pragma mark - UndoManager
|
|
|
+@interface KMDrawView (UndoManager)
|
|
|
+
|
|
|
+/* 标记当前图片
|
|
|
+ */
|
|
|
+- (NSData*)markAction;
|
|
|
+
|
|
|
+/* 最新Mark的图片
|
|
|
+ */
|
|
|
+- (UIImage*)currentImage;
|
|
|
+
|
|
|
+/** 检测是否可以Undo
|
|
|
+ @return 可以Undo则返回YES,反之返回NO
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (BOOL)canUndo;
|
|
|
+
|
|
|
+/** 撤销上一步操作
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (NSData*)undo;
|
|
|
+
|
|
|
+/** 检测是否可以Redo
|
|
|
+ @return 可以Redo则返回YES,反之返回NO
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (BOOL)canRedo;
|
|
|
+
|
|
|
+/** 重做最后一次撤销的操作
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (NSData*)redo;
|
|
|
+
|
|
|
+/** 重置 Undo Manager
|
|
|
+ @since Available in iOS 4.3 and later.
|
|
|
+ */
|
|
|
+- (NSData*)resetUndoManager;
|
|
|
+
|
|
|
+- (NSData*)loadUndoManager;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+
|
|
|
+#if EnableRecogition
|
|
|
+#pragma mark - Recogition
|
|
|
+@interface KMDrawView (Recogition)
|
|
|
+
|
|
|
+- (void)freeShapeMemory:(OutputShape)shape;
|
|
|
+
|
|
|
+- (BOOL)drawShape:(OutputShape)shape;
|
|
|
+
|
|
|
+@end
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark - DataSave
|
|
|
+@interface KMDrawView (DataSave)
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark - Radius Adjust
|
|
|
+@interface KMDrawView (Radius)
|
|
|
+
|
|
|
+- (float)inRadiusForRadius:(float)radius;
|
|
|
+
|
|
|
+- (float)radiusForInRadius:(float)inRadius;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@interface KMDrawView (BrushSetting)
|
|
|
+
|
|
|
+- (void)resetParams;
|
|
|
+
|
|
|
+- (BOOL)resetWithParams:(NSArray*)params
|
|
|
+ version:(int32_t)version;
|
|
|
+
|
|
|
+- (BOOL)resetWithKBRPath:(NSString*)kbrPath;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+#pragma mark - KMDrawViewDelegate
|
|
|
+@protocol KMDrawViewDelegate <NSObject>
|
|
|
+@optional
|
|
|
+/// 触控点控制
|
|
|
+//Begin 点修正
|
|
|
+- (CGPoint)drawView:(KMDrawView *)drawView shouldDrawBegin:(CGPoint)point;
|
|
|
+//Move 点修正
|
|
|
+- (CGPoint)drawView:(KMDrawView *)drawView shouldDrawMove:(CGPoint)point;
|
|
|
+//End 点修正
|
|
|
+- (CGPoint)drawView:(KMDrawView *)drawView shouldDrawEnd:(CGPoint)point;
|
|
|
+
|
|
|
+/// 触控点反馈
|
|
|
+- (void)drawView:(KMDrawView *)drawView willDrawBegin:(CGPoint)point;
|
|
|
+- (void)drawView:(KMDrawView *)drawView didDrawBegin:(CGPoint)point;
|
|
|
+
|
|
|
+- (void)drawView:(KMDrawView *)drawView willDrawMove:(CGPoint)point;
|
|
|
+- (void)drawView:(KMDrawView *)drawView didDrawMove:(CGPoint)point;
|
|
|
+
|
|
|
+- (void)drawView:(KMDrawView *)drawView willDrawEnd:(CGPoint)point;
|
|
|
+- (void)drawView:(KMDrawView *)drawView didDrawEnd:(CGPoint)point;
|
|
|
+
|
|
|
+/// Undo/Redo 状态反馈
|
|
|
+- (void)drawView:(KMDrawView *)drawView didUpdateUndoStatus:(BOOL)enable;
|
|
|
+- (void)drawView:(KMDrawView *)drawView didUpdateRedoStatus:(BOOL)enable;
|
|
|
+
|
|
|
+@end
|