20.01.2015 Views

CAPITULO 12: DIBUJADO Los mecanismos de pintado de Java ...

CAPITULO 12: DIBUJADO Los mecanismos de pintado de Java ...

CAPITULO 12: DIBUJADO Los mecanismos de pintado de Java ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

La figura <strong>12</strong>.5 muestra un applet que en su método paint implementa la siguiente<br />

instrucción:<br />

g.fillRect( 20, 20, 100, 80 );<br />

Figura <strong>12</strong>.5<br />

fillRect()<br />

drawOval() and fillOval()<br />

Estos métodos se usan para dibujar óvalos simples y óvalos rellenos respectivamente.<br />

Un óvalo se especifica por medio <strong>de</strong> una caja rectangular .El ovalo se coloca <strong>de</strong>ntro <strong>de</strong><br />

una caja<br />

limitante y es tangente a cada lado <strong>de</strong> la caja limitante, como lo muestra la figura <strong>12</strong>.6<br />

Para dibujar un<br />

círculo se usa una caja limitante cuadrada.<br />

Figura <strong>12</strong>.6<br />

Caja limitante<br />

<strong>de</strong> un óvalo<br />

<strong>Los</strong> dos métodos para dibujar oválos requieren que usted especifica una caja limite <strong>de</strong> la<br />

misma manera<br />

como se especifica un rectángulo en los métodos drawRect() y fillRect().<br />

public void drawRect( int x, int y, int width, int height );<br />

public void fillRect( int x, int y, int width, int height );<br />

En estos métodos x y y son las coor<strong>de</strong>nadas <strong>de</strong> la esquina superior izquierda <strong>de</strong> la caja<br />

limite y los<br />

parámetros height y width son el alto y el ancho <strong>de</strong> la caja.<br />

La figura <strong>12</strong>.7 muestra un applet, que implementa la siguiente instrucción en su método<br />

paint();<br />

g.drawOval( 10, 10, 150, 100 );<br />

FIGURE <strong>12</strong>.7<br />

drawOval()<br />

La Figura <strong>12</strong>.8 muestra un applet que en su métod paint() implementa la siguiente<br />

instrucción<br />

g.fillOval( 10, 10, 150, 100 );<br />

FIGURE <strong>12</strong>.8<br />

drawArc() and fillArc()<br />

Un arco es un segmento <strong>de</strong> un ovalo. Para <strong>de</strong>finir un arco usted inicialmente <strong>de</strong>be<br />

especificar la caja

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!