krzysztofzablocki / LineDrawing

Beatiful and fast smooth line drawing algorithm for iOS - as seen in Foldify.
http://twitter.com/merowing_
Other
1.29k stars 213 forks source link

Coordinates displaced #31

Closed Volodymyr-13 closed 7 years ago

Volodymyr-13 commented 8 years ago

Using provided example I changed size like that:

lineDrawer.contentSize = CGSizeMake([CCDirector sharedDirector].viewSize.width*0.5,[CCDirector sharedDirector].viewSize.height*0.5);

As result, drawing coordinates do not match and are displaced.

richardgroves commented 8 years ago

I've seen this before, and can easily re-create with the current repo. The version of the LineDrawer class I use in my app is very changed, but I think the thing that fixed this problem was deferring the setup of the rendertexture until it was needed.

In the current code it is created in the LineDrawer init, and so when you change the contentSize of the lineDrawer the backing texture is still full size and it makes a mess.

You also need to constrain the touch point by a) checking it hits the non-full screen node, b) converting the coordinate to node space.

There is a further wrinkle in that only one LineDrawer can be active at once due to contention for the GestureRecognizer input...

Take a look at the last couple of commits in https://github.com/richardgroves/KZLineDrawer which will give you a demo where you can have up to 4 LineDrawer nodes on screen, but only the last added one will work, but they do work properly when moved around the screen and less than full screen in size.

Volodymyr-13 commented 8 years ago

Thanks. Only one LineDrawer on the scene is ok for me.

Volodymyr-13 commented 8 years ago

One more problem, I just set height to 5 screen sizes:

lineDrawer.contentSize = CGSizeMake([CCDirector sharedDirector].viewSize.width*0.5,[CCDirector sharedDirector].viewSize.height*5.0);

*\ Assertion failure in -[CCFrameBufferObjectGL initWithTexture:depthStencilFormat:], ../Source/libs/cocos2d-iphone/CCRendererGLSupport.m:350

richardgroves commented 8 years ago

Yeah well, that is asking for it - 5 * screen height probably blows the texture size limit (2k or 4k depending on device), and I've no idea if you can have render target as large as textures anyway - might well be a smaller limit on an RT (but am guessing there).

Volodymyr-13 commented 8 years ago

I see, just in my game I wanted to have a large drawing canvas...