dmissud Posted September 13, 2010 Share Posted September 13, 2010 Bonjour à tous, Pour faire des essais de développement sur Android je veux faire un petit soft qui permette d'explorer l'ensemble de Mandelbrot. Quand je dessine les points, sur l'écran de mon HTC Desire, je vois les pixels (genre ça fait un quadrillage et c'est pas beau). Comment faire pour avoir une jolie image ??? Fonction onDraw de la View @Override protected void onDraw(Canvas canvas) { Paint paint = mPaint; float[] mPts = new float[2]; // canvas.translate(10, 10); canvas.drawColor(Color.BLACK); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setStrokeWidth(1); int h = canvas.getHeight(); int w = canvas.getWidth(); // paint.setColor(Color.RED); // paint.setStrokeWidth(0); // paint.setStrokeWidth(3); float a = -1.5f; float b; float step = 0.6f / w; for (int y = 0; y < h; y++) { b = -0.5f; for (int x = 0; x < w; x++) { mPts[0] = x; mPts[1] = y; int loop = 0; float z = 0.0f; float xn = 0.0f; float yn = 0.0f; float xn1 = 0.0f; float yn1 = 0.0f; while ((loop < 30) && (z < 4.0f)) { xn1 = xn * xn - yn * yn + a; yn1 = 2 * xn * yn + b; z = xn1 * xn1 + yn1 * yn1; xn = xn1; yn = yn1; loop = loop + 1; } if (z < 4.0f) { paint.setColor(Color.BLACK); canvas.drawPoints(mPts, paint); } else { paint.setColor(Color.rgb(255, 15+8*loop, 0)); canvas.drawPoints(mPts, paint); } b = b + step; } a = a + step; } } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.