You are on page 1of 6

Visual basic .

NET

 Moramo znati koristiti picturebox  Moramo znati koristiti vertical i horizontal scroll bar  ukoliko želimo deklarirati sliku
o Dim s As New Bitmap(x, y)

o Gdje je x širina a ! visina slike u pixelima  "a bi mo#li crtati po slici moramo otvoriti #ra$i%ki objekt
o Dim g As Graphics

o & povezati #a sa slikom
o g = Graphics.FromImage(s)

 koordinatni sustav ima ishodište'( () u #ornjem lijevom kutu i x raste po širini a ! po visini slike ukoliko želimo prila#oditi koordinatni sustav koristimo
o g.TranslateTrans orm(x, y)  o pomi!e "oor#inatni s$sta% &a x po osi x i y po osi y

g.'otateTrans orm(x)  rotira s$sta% o"o isho#i(ta &a x st$pn)e%a

o

g.*caleTrans orm(x, y)

množi x koordinatu s brojem x i ! koordinatu s brojem !

 brisanje slike ili ispunjavanje slike odre*enom bojom+
o g.+lear(+olor.Transparent)

 crtanje likova+ o dra,line - crtanje linije o dra, lines - crtanje linija zadanih s nizom to%aka o dra,elipse . crtanje elipse i kru#a o dra,rectan#le - crtanje pravokutnika o dra,pol!#on - crtanje poli#ona zadanim vrhovima ako #a želimo zatvoriti zadnja to%ka mora biti jednaka prvoj

2.1al$e = 3/ nacrta)(3/) 7n# *$0 6ri%ate *$0 . New Font(./) g./.*crollBar3. Br$shes.+lear(+olor.*crollBar3.an#les . /.*crollBar39*croll(By1al sen#er As *ystem. %). 43) g.<axim$m = 2.TranslateTrans orm(2..*croll7%entArgs) .Draw5ine(6ens./.Transparent) g.Draw5ine(6ens.Bac"gro$n#Image = s g./) g./. 4r.Blac".*crollBar3. y) o na koordinatama 'x !) ispisuje se tekst u navedenom $ontu veli%ine v  0rimjeri zadataka koje treba znati+ o Nacrtati kru# radijusa koje# možemo mijenjati sa scroll barom o Nacrtati #ra$ odre*ene $unkcije o Nacrtati odre*eni lik te #a rotirati pomo1u scrollbara o Napisati tekst na slici i rotirati #a oko ishodišta pomo1u scrollbara o & sl 2iješeni prvi zadatak+ 3orma sadržava picturebox s imenom pbox i jedan hscrollbar s imenom hscrollbar4 Dim s As New Bitmap(. 2. 2 8 r) p0ox. 2 8 r.5oa# . 4r.*croll . 42.te"st.:0)ect.an#les <yBase./.*caleTrans orm(3.//) *$0 nacrta)(By1al r) Dim g As Graphics g = Graphics..<inim$m = 3 .  pisanje teksta po slici+ o g.Draw7llipse(6ens. /.Blac". /) g. .arial. 42.Dispose() p0ox.o / o ukoliko želimo nacrtati ispunjeni lik koristimo $ill umjesto dra.7%entArgs) . By1al e As *ystem. x.Blac". 2.Forms.'e resh() 7n# *$0 6ri%ate *$0 Form395oa#(By1al sen#er As *ystem.Draw*tring(.A-$amarine.FromImage(s) g.:0)ect.=in#ows. /./ . By1al e As *ystem.*crollBar3.//.

*crollBar3.1al$e) 7n# *$0 .nacrta)(.

/.*caleTrans orm(3.Draw5ines(6ens.//) F$nction (By1al x As Integer) As Integer 'et$rn <ath.Blac". /) g.*caleTrans orm(3.//./)./) g./.'e resh() 7n# *$0 .@ = (x) Next g. 2. /.+lear(+olor. 2. /.Blac". Dim g As Graphics Dim p(./3) For x = 42. /.2iješeni dru#i zadatak+ 3orma sadržava picturebox s imenom pbox i jedan button s imenom cmd5ok Dim s As New Bitmap(.//) As 6oint Dim x As Integer g = Graphics.Blac". 42./) g.Bac"gro$n#Image = s g.Transparent) g./.Draw5ine(6ens.Draw5ine(6ens..? = x p(x > 2. ./. p) p0ox. 2. /. 2) 7n# F$nction *$0 cm#9o"9. 43) g..Dispose() p0ox./ To 2.FromImage(s) g.6ow(x. 42./ p(x > 2.TranslateTrans orm(2./).

*crollBar3.*caleTrans orm(3./. 3//) p(A) = p(/) g.*crollBar3.Forms.TranslateTrans orm(2./) p(2) = New 6oint(.2iješeni tre1i zadatak+ 3orma sadržava picturebox s imenom pbox i jedan hscrollbar s imenom hscrollbar4 Dim s As New Bitmap(. /.7%entArgs) .1al$e) 7n# *$0 ./.Blac".Fill6olygon(Br$shes.'e resh() 7n# *$0 6ri%ate *$0 Form395oa#(By1al sen#er As *ystem./././) g.5oa# .//. 42. By1al e As *ystem. . /./) g.*crollBar3.Blac".1al$e = / nacrta)(/) 7n# *$0 6ri%ate *$0 .*croll nacrta)(.*crollBar39*croll(By1al sen#er As *ystem. 2.:0)ect.=in#ows.FromImage(s) g.Transparent) g.an#les . 2.<inim$m = / .'otateTrans orm(st$pn)e%i) p(/) = New 6oint(43//. /.*crollBar3.Draw5ine(6ens.:0)ect.<axim$m = AB/ .*croll7%entArgs) .//) *$0 nacrta)(By1al st$pn)e%i) Dim g As Graphics Dim p(A) As 6oint g = Graphics.an#les <yBase. p) p0ox.+lear(+olor. 4. 43) g.Dispose() p0ox.Draw5ine(6ens. 43//) p(3) = New 6oint(3//.Blac".Bac"gro$n#Image = s g./. By1al e As *ystem. 2. /) g. 42.*crollBar3.

.Draw*tring(.:0)ect. Br$shes.*croll nacrta)(. .'otateTrans orm(st$pn)e%i) g.*crollBar3. By1al e As *ystem. /.'e resh() 7n# *$0 6ri%ate *$0 Form395oa#(By1al sen#er As *ystem.Dispose() p0ox. 2.1al$e = / nacrta)(/) 7n# *$0 6ri%ate *$0 .+o$rier New.5oa# .1al$e) 7n# *$0 .Bac"gro$n#Image = s g.Bl$e..*crollBar3.<inim$m = / .//) *$0 nacrta)(By1al st$pn)e%i) Dim g As Graphics g = Graphics.=in#ows.:0)ect.//.*crollBar3.*crollBar3.*crollBar39*croll(By1al sen#er As *ystem.FromImage(s) g.an#les <yBase. /) p0ox. New Font(. 2C).*crollBar3./.T$rin Fran&.Transparent) g.2iješeni %etvrti zadatak+ 3orma sadržava picturebox s imenom pbox i jedan hscrollbar s imenom hscrollbar4 Dim s As New Bitmap(.Forms.7%entArgs) ./) g.*croll7%entArgs) .TranslateTrans orm(2.<axim$m = AB/ .an#les . By1al e As *ystem.+lear(+olor.