Code example for ShapeDrawable

Methods: setBoundsdrawgetPaint

0
		gfx.endFill(); */ 
	} 
	 
	 
	public void drawEyes(Canvas canvas) {
        ShapeDrawable mDrawable = new ShapeDrawable(new OvalShape());
        mDrawable.getPaint().setColor(0xffffffff);
         
        double ypos = y-(Math.random()*xradius-(xradius*0.5d));
//        setOval(mDrawable, x-(xradius*0.3d), ypos, xradius*0.1d, xradius*0.2d); 
        setCircle(mDrawable, x-(xradius*0.3d), ypos, xradius*0.1d);
        setCircle(mDrawable, x-(xradius*0.3d), ypos, xradius*0.1d);
        mDrawable.draw(canvas);	//draws mDrawable to canvas
 
//        setOval(mDrawable, x+(xradius*0.3d), ypos, xradius*0.1d, xradius*0.2d); 
        setCircle(mDrawable, x+(xradius*0.3d), ypos+xradius*0.1d, xradius*0.1d);
        setCircle(mDrawable, x+(xradius*0.3d), ypos+xradius*0.1d, xradius*0.1d);
//        mDrawable.setBounds(x+radius, y-radius, x + radius*2, y + radius*2); 
        mDrawable.draw(canvas);	//draws mDrawable to canvas
 
//		gfx.drawCircle(-radius*0.5, Math.random()*radius, radius*(Math.random()*0.4+0.3)); 
//		gfx.drawCircle(radius*0.5, Math.random()*radius, radius*(Math.random()*0.4+0.3)); 
 
	} 
	 
	public static void setCircle(ShapeDrawable drawable, double x, double y, double r) {
//		drawable.setBounds((int)(x-r), (int)(y-r), (int)(x+r*2d), (int)(y+r*2d)); 
		drawable.setBounds((int)(x-r), (int)(y-r), (int)(x+r*2d), (int)(y+r*2d));
	} 
 
	public static void setOval(ShapeDrawable drawable, double x, double y, double xr, double yr) {
		drawable.setBounds((int)(x-xr), (int)(y-yr), (int)(x+xr*2d), (int)(y+yr*2d));
	} 
Stop searching for code, let great code find you!  Add Codota to your java IDE