*/}}

ourpaint.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. #include "la_5.h"
  2. #define OUR_AT_CROP_CENTER 0
  3. #define OUR_AT_CROP_L 1
  4. #define OUR_AT_CROP_R 2
  5. #define OUR_AT_CROP_U 3
  6. #define OUR_AT_CROP_B 4
  7. #define OUR_AT_CROP_UL 5
  8. #define OUR_AT_CROP_UR 6
  9. #define OUR_AT_CROP_BL 7
  10. #define OUR_AT_CROP_BR 8
  11. #define OUR_VERSION_MAJOR 0
  12. #define OUR_VERSION_MINOR 1
  13. STRUCTURE(OurCanvasDraw){
  14. laCanvasExtra Base;
  15. int HideBrushCircle;
  16. int AtCrop;
  17. real CanvasLastX,CanvasLastY;
  18. real CanvasDownX,CanvasDownY;
  19. real LastPressure;
  20. real LastTilt[2];
  21. };
  22. #define OUR_TILE_W 1024
  23. #define OUR_TILES_PER_ROW 100
  24. #define OUR_TILE_CTR (OUR_TILES_PER_ROW/2)
  25. #define OUR_TILE_SEAM 12
  26. #define OUR_TILE_W_USE (OUR_TILE_W-OUR_TILE_SEAM*2)
  27. STRUCTURE(OurTexTile){
  28. tnsTexture* Texture;
  29. uint16_t* Data;
  30. int l,r,u,b;
  31. uint16_t* FullData;
  32. uint16_t* CopyBuffer;
  33. int cl,cr,cu,cb;
  34. };
  35. STRUCTURE(OurLayer){
  36. laListItem Item;
  37. laSafeString Name;
  38. int OffsetX,OffsetY;
  39. OurTexTile** TexTiles[OUR_TILES_PER_ROW];
  40. };
  41. STRUCTURE(OurLayerWrite){
  42. unsigned char* data;
  43. size_t NextData, MaxData;
  44. };
  45. STRUCTURE(OurLayerRead){
  46. unsigned char* data;
  47. size_t NextData;
  48. };
  49. STRUCTURE(OurBrushSettingsNode){
  50. laBaseNode Base;
  51. laNodeOutSocket* CanvasScale; real rCanvasScale;
  52. laNodeOutSocket* Size; real rSize;
  53. laNodeOutSocket* Transparency; real rTransparency;
  54. laNodeOutSocket* Hardness; real rHardness;
  55. laNodeOutSocket* Smudge; real rSmudge;
  56. laNodeOutSocket* DabsPerSize; real rDabsPerSize;
  57. laNodeOutSocket* SmudgeLength; real rSmudgeLength;
  58. laNodeOutSocket* Slender; real rSlender;
  59. laNodeOutSocket* Angle; real rAngle;
  60. laNodeOutSocket* Color;
  61. };
  62. STRUCTURE(OurBrushOutputsNode){
  63. laBaseNode Base;
  64. laNodeInSocket* Offset;
  65. laNodeInSocket* Size;
  66. laNodeInSocket* Transparency;
  67. laNodeInSocket* Hardness;
  68. laNodeInSocket* Smudge;
  69. laNodeInSocket* DabsPerSize;
  70. laNodeInSocket* SmudgeLength;
  71. laNodeInSocket* Slender;
  72. laNodeInSocket* Angle;
  73. laNodeInSocket* Color;
  74. };
  75. STRUCTURE(OurBrushDeviceNode){
  76. laBaseNode Base;
  77. laNodeOutSocket* Pressure; real rPressure;
  78. laNodeOutSocket* Position; real rPosition[2];
  79. laNodeOutSocket* Tilt; real rTilt[2];
  80. laNodeOutSocket* IsEraser; int rIsEraser;
  81. laNodeOutSocket* Speed; real rSpeed;
  82. laNodeOutSocket* Angle; real rAngle;
  83. laNodeOutSocket* Length; real rLength;
  84. laNodeOutSocket* LengthAccum; real rLengthAccum;
  85. };
  86. STRUCTURE(OurBrush){
  87. laListItem Item;
  88. laSafeString Name;
  89. real Size;
  90. real DabsPerSize;
  91. real Hardness;
  92. real Transparency;
  93. real Smudge;
  94. real SmudgeResampleLength; real SmudgeAccum; int SmudgeRestart; real BrushRemainingDist;
  95. real Slender;
  96. real Angle;
  97. real Smoothness;
  98. real MaxStrokeLength;
  99. int PressureSize,PressureHardness,PressureTransparency,PressureSmudge; // the simple way
  100. int Binding,DefaultAsEraser;
  101. int UseNodes; // the flexible way
  102. laRackPage* Rack;
  103. real LastX,LastY,LastAngle;
  104. real EvalColor[3];
  105. real EvalOffset[2];
  106. real EvalSize;
  107. real EvalDabsPerSize;
  108. real EvalHardness;
  109. real EvalTransparency;
  110. real EvalSmudge;
  111. real EvalSmudgeLength;
  112. real EvalSlender;
  113. real EvalAngle;
  114. real EvalSpeed;
  115. real EvalStrokeLength;
  116. real EvalStrokeLengthAccum;
  117. real EvalPressure;
  118. real EvalPosition[2];
  119. real EvalTilt[2];
  120. real EvalStrokeAngle;
  121. int EvalIsEraser;
  122. };
  123. STRUCTURE(OurDab){
  124. float X,Y;
  125. float Size;
  126. float Hardness;
  127. float Smudge; int ResampleSmudge;
  128. float Color[4];
  129. float Slender;
  130. float Angle;
  131. float Recentness;
  132. };
  133. STRUCTURE(OurUndoTile){
  134. laListItem Item;
  135. int col,row;
  136. uint16_t* CopyData;
  137. int l,r,u,b;
  138. };
  139. STRUCTURE(OurUndo){
  140. OurLayer* Layer;
  141. laListHandle Tiles;
  142. };
  143. #define OUR_TOOL_PAINT 0
  144. #define OUR_TOOL_CROP 1
  145. #define OUR_PNG_READ_INPUT_FLAT 0
  146. #define OUR_PNG_READ_INPUT_ICC 1
  147. #define OUR_PNG_READ_INPUT_SRGB 2
  148. #define OUR_PNG_READ_INPUT_LINEAR_SRGB 3
  149. #define OUR_PNG_READ_INPUT_CLAY 4
  150. #define OUR_PNG_READ_INPUT_LINEAR_CLAY 5
  151. #define OUR_PNG_READ_OUTPUT_CANVAS 0
  152. #define OUR_PNG_READ_OUTPUT_LINEAR_SRGB OUR_PNG_READ_INPUT_LINEAR_SRGB
  153. #define OUR_PNG_READ_OUTPUT_LINEAR_CLAY OUR_PNG_READ_INPUT_LINEAR_CLAY
  154. #define OUR_CANVAS_INTERPRETATION_SRGB 0
  155. #define OUR_CANVAS_INTERPRETATION_CLAY 1
  156. #define OUR_EXPORT_BIT_DEPTH_8 0
  157. #define OUR_EXPORT_BIT_DEPTH_16 1
  158. #define OUR_EXPORT_COLOR_MODE_SRGB 0
  159. #define OUR_EXPORT_COLOR_MODE_CLAY 1
  160. #define OUR_EXPORT_COLOR_MODE_FLAT 2
  161. STRUCTURE(OurPNGReadExtra){
  162. int Confirming;
  163. laSafeString* FilePath;
  164. laSafeString* iccName;
  165. int HassRGB;
  166. int HasProfile;
  167. int InputMode;
  168. int OutputMode;
  169. };
  170. STRUCTURE(OurPNGWriteExtra){
  171. int Confirming;
  172. laSafeString* FilePath;
  173. int BitDepth;
  174. int ColorProfile;
  175. };
  176. STRUCTURE(OurPaint){
  177. real pad;
  178. laListHandle CanvasSaverDummyList;
  179. laProp* CanvasSaverDummyProp;
  180. laListHandle Layers;
  181. OurLayer* CurrentLayer;
  182. laListHandle Brushes;
  183. OurBrush* CurrentBrush;
  184. OurDab* Dabs; int NextDab,MaxDab;
  185. laListHandle BrushEval;
  186. real CurrentScale;
  187. int Tool,ActiveTool,Erasing,EventErasing;
  188. int PenID,EraserID;
  189. int X,Y,W,H; //border
  190. int ColorInterpretation;
  191. int ShowBorder,UseBorder;
  192. int ShowTiles;
  193. int LockRadius;
  194. int EnableBrushCircle;
  195. int DefaultBitDepth;
  196. int DefaultColorProfile;
  197. tnsTexture* SmudgeTexture;
  198. GLuint CanvasShader; GLuint CanvasProgram;
  199. GLuint CompositionShader; GLuint CompositionProgram;
  200. GLint uBrushCorner;
  201. GLint uBrushCenter;
  202. GLint uBrushSize;
  203. GLint uBrushHardness;
  204. GLint uBrushSmudge;
  205. GLint uBrushRecentness;
  206. GLint uBrushColor;
  207. GLint uBrushSlender;
  208. GLint uBrushAngle;
  209. GLint uBrushRoutineSelection;
  210. GLint uBrushErasing;
  211. GLint RoutineDoDabs;
  212. GLint RoutineDoSample;
  213. GLint uMode;
  214. real CurrentColor[3];
  215. real BackgroundColor[3];
  216. uint16_t BColorU16[4];
  217. real BorderAlpha;
  218. real xmin,xmax,ymin,ymax; // stroke bbox for undo region
  219. int ResetBrush;
  220. uint16_t *ImageBuffer;
  221. int ImageW,ImageH,ImageX,ImageY,LoadX,LoadY,TempLoadX,TempLoadY;
  222. void* icc_LinearsRGB; int iccsize_LinearsRGB;
  223. void* icc_LinearClay; int iccsize_LinearClay;
  224. void* icc_sRGB; int iccsize_sRGB;
  225. void* icc_Clay; int iccsize_Clay;
  226. };
  227. int ourInit();
  228. void ourRegisterNodes();
  229. int ourRebuildBrushEval();
  230. int ourEvalBrush();