Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>1-</strong> I guess that you only use a few points to draw graphs of signals. All graph/chart applications try to connect points with direct lines and then your chart will be shown. So if you only use three points, your graph will looks like a triangle! If you want your graph to be curved, you have to add more points. Then it comes out like a curve.</p> <p><strong>2-</strong> Or you can find any library that can draw <code>sin</code> graph, for example <a href="http://android-graphview.org/" rel="nofollow noreferrer"><code>GraphView Library</code></a>. Then try to draw this function:</p> <p><img src="https://i.stack.imgur.com/IWjyY.png" alt="Enter image description here"></p> <p>So it looks like to this:</p> <p><img src="https://i.stack.imgur.com/bdB49.png" alt="Enter image description here"></p> <p>Then translate it to <code>(a,0)</code>, so result seems like what you want.</p> <p><strong>3-</strong> And another way, you can use built in <code>Math.sin</code> in Java:</p> <p>Chose for example 1000 point in range <code>a</code> to <code>b</code> and compute value of above function for each point and finally create a <code>path</code> and show them in a canvas.</p> <p>You can use <a href="http://developer.android.com/reference/android/graphics/Path.html#quadTo%28float,%20float,%20float,%20float%29" rel="nofollow noreferrer">quadTo (float x1, float y1, float x2, float y2)</a> that simplify drawing <code>quad curves</code> for you. The documentation says:</p> <blockquote> <p>Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2). If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).</p> <p>Parameters <br/> <br/> x1 The x-coordinate of the control point on a quadratic curve <br/> y1 The y-coordinate of the control point on a quadratic curve <br/> x2 The x-coordinate of the end point on a quadratic curve <br/> y2 The y-coordinate of the end point on a quadratic curve <br/></p> </blockquote> <p>Finally, I add a simple class that extends <code>View</code> and can draw a curve that looks like what you want:</p> <pre><code>public class SinWave extends View { private float first_X = 50; private float first_Y = 230; private float end_X = 100; private float end_Y = 230; private float Max = 50; public SinWave(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint() { { setStyle(Paint.Style.STROKE); setStrokeCap(Paint.Cap.ROUND); setStrokeWidth(0.7f); setAntiAlias(true); setColor(0xFFFF00FF); } }; final Path path = new Path(); path.moveTo(first_X, first_Y); path.quadTo((first_X + end_X)/2, Max, end_X, end_Y); canvas.drawPath(path, paint); } } </code></pre> <p>The result must look like this:</p> <p><img src="https://i.stack.imgur.com/tWoO3.png" alt="Enter image description here"></p> <p>You can add more methods to the class and change it to increase performance!</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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