Visual Basic 6 Black Book:Working With Graphics
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Drawing Points
To draw individual points, you use PSet in forms and picture boxes like this:
object.PSet [Step] ( x, y), [color]
Here are the arguments you pass to PSet:
StepKeyword specifying that the coordinates are relative to the current graphics position given by the CurrentX and CurrentY properties.
x, ySingle values indicating the horizontal (x-axis) and vertical (y-axis) coordinates of the point to set.
colorLong integer value indicating the RGB color specified for the point. If omitted, the current ForeColor property setting is used. You can use the RGB function or QBColor function to specify the color.
You can also use the Point method to retrieve the color of a point at a specific (x, y) location.
Setting The Drawing Mode
You draw with pens in Windows. Every drawing operation uses these pens. When you set the drawing width, youre really setting the width of the pen; when you set the drawing color, youre setting the color of the pen.
You can also use the DrawMode property to specify how the current pen interacts with the graphics it already finds in a form or picture box. Here are the possible settings for the pens drawing mode:
vbBlackness1, Blackness
vbNotMergePen2, Not Merge Pen; inverse of setting 15 (Merge Pen)
vbMaskNotPen3, Mask Not Pen; combination of the colors common to the background color and the inverse of the pen
vbNotCopyPen4, Not Copy Pen; inverse of setting 13 (Copy Pen)
vbMaskPenNot5, Mask Pen Not; combination of the colors common to both the pen and the inverse of the display
vbInvert6, Invert; inverse of the display color
vbXorPen7, XOR Pen; combination of the colors in the pen and in the display color, but not in both
vbNotMaskPen8, Not Mask Pen; inverse of setting 9 (Mask Pen)
vbMaskPen9, Mask Pen; combination of the colors common to both the pen and the display
vbNotXorPen10, Not XOR Pen; inverse of setting 7 (XOR Pen)
vbNop11 Nop, No operation; output remains unchanged (in effect, this setting turns drawing off)
vbMergeNotPen12, Merge Not Pen; combination of the display color and the inverse of the pen color
vbCopyPen13, Copy Pen (the default); color specified by the ForeColor property
vbMergePenNot14, Merge Pen Not; combination of the pen color and the inverse of the display color
vbMergePen15, Merge Pen; combination of the pen color and the display color
vbWhiteness16, Whiteness
For example, we can set the pen to be an invert pen with this code and draw over some lines. The pen will invert the pixels it finds:
Private Sub Form_Load()
Dim intLoopIndex As Integer
For intLoopIndex = 1 To 9
DrawWidth = intLoopIndex
Line (0, intLoopIndex * ScaleHeight / 10)(ScaleWidth, _
intLoopIndex * ScaleHeight / 10)
Next intLoopIndex
DrawMode = vbInvert
DrawWidth = 10
Line (0, 0)-(ScaleWidth, ScaleHeight)
Line (0, ScaleHeight)-(ScaleWidth, 0)
End Sub
The result of this code appears in Figure 18.13; the two diagonal lines are drawn with the inverted pen.
Figure 18.13 Drawing with the Invert pen.
TIP: The XOR (exclusive OR) pen is a popular one, because when you draw with it twice in the same location, the display is restored to its original condition. This happens because if you XOR number A to number B twice, number B is restored. Programmers use this to draw figures they know theyll need to erase, such as when letting the user stretch a graphics figure with the mouse. In such a case, each figure you draw will have to be erased before you can draw the next one to give the illusion of stretching the figure. What programmers usually do is to draw the stretched figure with the XOR pen, and when its time to erase it, they draw it again with the same pen, thereby restoring the screen.
The code for this example is located in the drawinvert folder on this books accompanying CD-ROM.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
604 606604 606fileQ83 3 br 604 info599 604W Ziemi Obiecanej (1615 606 p n e )MaxCom KXT 604606 (2)Gruca Jaroslaw 14 gr=604606 613ONKYO KODY DO PILOTA 506,576,606,5100codes603 606601 604606 (3)604 (2)606 Tablice606 609więcej podobnych podstron