1 / 6

Grafik – Crayon-objekter

Grafik – Crayon-objekter. Model. (0,0). Position : (x,y) Vinkel : v Farve : color Bredde: positivt tal. 270. Tavle. 0 (360). 180. 90. (400,500). En pens tilstand : - (position, vinkel, farve, bredde) - starttilstand: ((0, 0), 0, Color.black, 1).

mayten
Download Presentation

Grafik – Crayon-objekter

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Grafik – Crayon-objekter IntroJava2006 - AAU

  2. Model (0,0) • Position: (x,y) • Vinkel: v • Farve: color • Bredde: positivt tal 270 Tavle 0 (360) 180 90 (400,500) ... En pens tilstand: - (position, vinkel, farve, bredde) - starttilstand: ((0, 0), 0, Color.black, 1) Eller ((midt, midt), 0, Color.black, down) IntroJava2006 - AAU

  3. Metoder • public void move(double d) Flyt d enheder i aktuel tegneretning, mens der tegnes • public void moveto(double x, double y)Flyt til position (x,y), mens der tegnes • public void jump(double d)Flyt d enheder i aktuel tegneretning uden at tegne • public void jumpto(double x, double y)Flyt til (x,y) uden at tegne • public void turn(double a)Drej a grader med uret • public void turnto(double a) Drej til tegneretning a (x-aksens retning er 0 grader) • public void erase()Slet alt på tavlen IntroJava2006 - AAU

  4. I BlueJ Skal bruges – ikke ændres Skal kodes IntroJava2006 - AAU

  5. Eksempel import java.awt.*; public class CrayonSquares { public void main() { Crayon blue_pencil = new Crayon(Color.BLUE, 1); Crayon red_pencil = new Crayon(Color.RED, 1); //tegn det blå kvadrat: blue_pencil.jumpto(100, 100); blue_pencil.turnto(0); blue_pencil.move(100); blue_pencil.turn(90); blue_pencil.move(100); blue_pencil.turn(90); blue_pencil.move(100); blue_pencil.turn(90); blue_pencil.move(100); blue_pencil.turn(90); //Tegn det røde kvadrat: IntroJava2006 - AAU

  6. Øvelser • Hent projektet opgCrayon. Åben det og kør det. • Tegn et grønt kvadrat uden om de to andre. • Tegn en ligesidet trekant inden i en ligesidet sekskant. • Eksperimenter med Crayon-objekter og lav nogle ”kunstneriske” tegninger. IntroJava2006 - AAU

More Related