adamwulf / JotUI

OpenGL based drawing view built for and used by Loose Leaf for iPad
http://getlooseleaf.com/opensource/
MIT License
268 stars 28 forks source link

How to customize a pen style? #35

Open CoderMaurice opened 5 years ago

CoderMaurice commented 5 years ago

Hi, Thank you very much for this great project,

wx20181222-180459

How to get a pen like this, help~~~

adamwulf commented 5 years ago

Look into how the highlighter pen is currently implemented. setting its color to black and opacity to 1.0 should get you very close. Then edit the rotation to be locked to pi/4 and i think that'll get you 99% of the way there.

adamwulf commented 5 years ago

Be sure and re-pull master. I just pushed up some fixes to jotuiexample and added that Highlighter class

CoderMaurice commented 5 years ago

Thanks for your quick reply

  1. I used that highlighter pen, although I set both MinAlpha and MaxAlpha to 1.0, it still has opacity, how to solve it? 2. I checked the source code and didn't find a way to edit the rotation( ,,Ծ.Ծ,, ) 2.I can't open the highlighter.png, I can see it is a trace of highlighter, how to customize a png I need? (I can't open it in photoshop ,,( ͡° ͜ʖ ͡°),,)

image

adamwulf commented 5 years ago

Ah right, for the rotation, you'll need to customize JotView.m. I don't actually expose rotation angle like i remembered.

In JotView.m, line 1502, you'll see:

                    CGFloat rot = atan2(diff.y, diff.x);

change that to:

                    CGFloat rot = M_PI_4;

I think that'll do what you want. You can play with different values there to get the effect you want.

For the opacity, you can try darkening the highlighter.png texture so that it's more opaque. The included one is fairly transparent I believe. You can also edit the alpha directly in CurveToPathElement.m on line 213.

change the following:

CGFloat alpha = _colorComponents[3] / kDivideStepBy;

to

CGFloat alpha = 1.0;

both of those source edits should do what you want. the 2nd source edit will affect all brushes though, so if you want to support more than just your custom brush it might need a bit more surgery to get only that brush darker. I'd try the texture edit first, I think there's a high chance that'll do what you need.

CoderMaurice commented 5 years ago

Thank you so much, I will try.