
()
Newbie
    
Messaggi:
Iscritto:
|
Volevo sapere se c'è un modo per disegnare su un Graphics linee spesse.
Io ho trovato un modo, non credo sia il migliore , per farlo:
Disegnare due circonferenze e riempire il poligono con i vertici sulle tangenti .
Codice sorgente - presumibilmente Java |
//(x, y) = primo punto //(lx, ly) = secondo punto //s = spessore double d = Math. sqrt(Math. pow((lx - x ), 2 ) + Math. pow((ly - y ), 2 )); double kx = (ly - y)*s/2/d; double ky = (lx - x)*s/2/d; int PX [] = {(int)Math. round(x - kx ), (int)Math. round(lx - kx ), (int)Math. round(lx + kx ), (int)Math. round(x + kx )}; int PY [] = {(int)Math. round(y + ky ), (int)Math. round(ly + ky ), (int)Math. round(ly - ky ), (int)Math. round(y - ky )}; g.fillOval(x - s/2, y - s/2, s, s); g.fillOval(lx - s/2, ly - s/2, s, s); g.fillPolygon(PX, PY, 4);
|
Questo è l'unico modo
Se non lo è qualcuno mi può suggerire qualcosa di più funzionale
Grazie in anticipo per le risposte
|