Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><P> I have tried a different approach to implement my functionality of scribbling over a glSurfaceView and simultaneously be able to zoom in and zoom out. I have done all the scribbling over normal android provided canvas. In the background I have a GLSurfaceView. On top of it i have a scribbble view (http://www.java2s.com/Code/Android/2D-Graphics/Classforthescribblememopad.htm). I have set the background of ScribbleView as TRANSPARENT. When I am done Scribbling I put scribbling off using onClickListener of a Button (when scribbling is off user can zoom in and zoom out). I can zoom in or out using ScaleGestureDetector.SimpleOnScaleGestureListener. In its <code>onScale()</code> I am using <code>mScaleFactor=(mScaleFactor * detector.getScaleFactor());</code> Where mScaleFactor is initlised to 1f and mScaleFactor is used to track the current ScalingFactor. For scaling of glSurface I use <code>glScalef(mScaleFactor,mScaleFactor)</code> and for canvas scaling I use <code>canvas.scale(mScaleFactor,mScaleFactor,getWidth()/2,getHeight()/2)</code>. I have set the pivot point to middle of the view as the coordinates of the canvas is such that its origin is at top left. After I scale up or scale down the canvas Then for correct scribbling I have in onTouchEvent(Event event) of Scribble view I have done the below mapping for the </p> <pre><code>event.getX() and event.getY(). &lt;br&gt; x=(event.getX()- getWidth() / 2) / getmScaleFactor() + getWidth() / 2;&lt;br&gt; y=(event.getX()- getWidth() / 2) / getmScaleFactor() + getWidth() / 2;&lt;br&gt; &lt;br&gt; </code></pre> <p>Now when I do scribbling on the zoomed in or out canvas I can scribble at the point where I touch the screen correctly. <br> I hope I have been able to give you all some insight of my approach.</p> <p><br> Thanks Krishna. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload