• Keine Ergebnisse gefunden

2ZeichnenmitJavaScript 1HTML-Element Canvas

N/A
N/A
Protected

Academic year: 2022

Aktie "2ZeichnenmitJavaScript 1HTML-Element Canvas"

Copied!
1
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

JavaScript http://kohnlehome.de/html/canvas.pdf

Canvas

1 HTML-Element

< c a n v a s id =" z e i c h e n b r e t t " w i d t h =" 400 " h e i g h t =" 300 "> </ canvas >

2 Zeichnen mit JavaScript

2.1 Kontext zum Zeichnen

var c a n v = d o c u m e n t . g e t E l e m e n t B y I d (" z e i c h e n b r e t t ") ; var c o n t e x t = c a n v . g e t C o n t e x t (" 2 d ") ;

2.2 Farbe

f a r b e = " o r a n g e "; // F a r b b e z e i c h n e r f a r b e = " # f f f f f f "; // H e x w e r t e

f a r b e = " rgb ( 2 5 5 , 2 5 5 , 2 5 5 ) "; // rot , gruen , b l a u j e w e i l s von 0 -255 f a r b e = " r g b a ( 2 5 5 , 2 5 5 , 2 5 5 , 0 . 5 ) "; // mit T r a n s p a r e n z von 0.0 bis 1.0

2.3 Zeichenstift

c o n t e x t . l i n e W i d t h = 5;

c o n t e x t . s t r o k e S t y l e = f a r b e ;

2.4 Pinsel

c o n t e x t . f i l l S t y l e = f a r b e ;

2.5 Zeichnen

2.5.1 Rechteck zeichnen

c o n t e x t . s t r o k e R e c t ( x , y , breite , h o e h e ) ;

2.5.2 Rechteck f¨ ullen

c o n t e x t . f i l l R e c t ( x , y , breite , h o e h e ) ;

2.5.3 Rechteck l¨ oschen

c o n t e x t . c l e a r R e c t ( x , y , breite , h o e h e ) ;

2.5.4 Linie zeichnen

c o n t e x t . b e g i n P a t h () ; c o n t e x t . m o v e T o ( x , y ) ; c o n t e x t . l i n e T o ( x , y ) ; c o n t e x t . s t r o k e () ; c o n t e x t . c l o s e P a t h () ;

2.5.5 Text zeichnen

c o n t e x t . f o n t = " b o l d 40 px m o n o s p a c e ";

c o n t e x t . s t r o k e T e x t (" T e x t ",x , y ) ; // R a n d c o n t e x t . f i l l T e x t (" T e x t ",x , y ) ; // F u e l l u n g

2.5.6 Kreisbogen zeichnen

c o n t e x t . b e g i n P a t h () ;

c o n t e x t . arc ( x , y , radius , s t a r t W i n k e l , e n d W i n k e l , g e g e n U h r z e i g e r ) ; c o n t e x t . s t r o k e () ;

c o n t e x t . f i l l () ; c o n t e x t . c l o s e P a t h () ;

Franz Kohnle Seite 1 von 1 10. Dezember 2012

Referenzen

ÄHNLICHE DOKUMENTE

Ein radioaktives Element X zerfällt mit einer Halbwertszeit von 8

Mit dem digitalen Marketing ergeben sich neue und zum Teil automatisierte Ansätze in Vertrieb, Verkauf, Kommunikation, Service und Kundenbindung?. Version: Beschreibung

Stockach (swb). Die Kirchen- gemeinde Herz-Jesu in Zizen- hausen begeht ihr Kirchenpa- trozinium am Sonntag, 29. Der Tag beginnt um 9 Uhr mit einem Festgottesdienst in

Ein entsprechen- der Antrag wurde gestellt, ob- wohl Stockach nach einem Ge- meinderatsbeschluss die Bestre- bungen auch mit Blick auf sein geplantes Schulzentrum zwi- schen

public class Haupt extends Applet{. Kreuz

ˆ watch: Methoden, die bei ¨ Anderung des Wertes einer data-Varaible ausgef¨ uhrt werden.. ˆ mounted: Quellcode, der beim Start ausgef¨

Diese Adjektive sollten das Thema und die Idee deines Pop-ups darstellen und dein Anhaltspunkt für zukünftige Entscheidungen sein. Wenn du eine klare Vorstellung davon hast, wie

Beschriften Sie bitte im Bild die beiden Elektroden Anode und Kathode.. Hinweis: gemäss Definition ist die Anode dort wo die