' ------------------------------------------------------------------------------------ ' Mire3D.vbs ' Ce script créé une mire d'alignement pour la projection stéréo avec deux projecteurs. ' La mire est composée de deux images de 1024x768 placées côte-à-côte en vision croisée ' et comporte les éléments suivants : ' - Grand rectangle pour les réglages de taille et de déformation (trapézoïde,...) ' - Croix centrale pour l'alignement ' - Echelle de chiffres en profondeur décroissante. ' - Grandes lettres G et D pour bien différencier les deux projecteurs. ' - Optionnellement une échelle de gris pour les réglages contraste et luminosité ' (ce dégradé est très long à tracer !). ' ------------------------------------------------------------------------------------ Option Explicit ' Constants that can be used with the DrawText nFormat parameter ' (from Microsoft documentation) Const DT_TOP = &H0 ' Specifies top-justified text (single line only). Const DT_LEFT = &H0 ' Aligns text flush-left. Const DT_CENTER = &H1 ' Centers text horizontally. Const DT_RIGHT = &H2 ' Aligns text flush-right. Const DT_VCENTER = &H4 ' Specifies vertically centered text (single line only). Const DT_BOTTOM = &H8 ' Specifies bottom-justified text (single line only). Const DT_WORDBREAK = &H10 ' Specifies word-breaking. Const DT_SINGLELINE = &H20 ' Specifies single line only. Carriage returns and ' linefeeds do not break the line. Const DT_EXPANDTABS = &H40 ' Expands tab characters. The default number of characters ' per tab is eight. Const DT_TABSTOP = &H80 ' Sets tab stops. The high-order byte of nFormat is the ' number of characters for each tab. Const DT_NOCLIP = &H100 ' Draws without clipping. Const DT_EXTERNALLEADING = &H200 'Includes the font’s external leading in the line height. ' Normally, external leading is not included in the ' height of a line of text. Const DT_CALCRECT = &H400 ' Determines the width and height of the rectangle. ' If there are multiple lines of text, DrawText will use ' the width of the rectangle pointed to by lpRect and ' extend the base of the rectangle to bound the last line ' of text. If there is only one line of text, DrawText ' will modify the right side of the rectangle so that it ' bounds the last character in the line. In either case, ' DrawText returns the height of the formatted text, but ' does not draw the text. Const DT_NOPREFIX = &H800 ' Turns off processing of prefix characters. Normally, ' DrawText interprets the ampersand (&) mnemonic-prefix ' character as a directive to underscore the character ' that follows, and the two-ampersand (&&) mnemonic-prefix ' characters as a directive to print a single ampersand. ' By specifying DT_NOPREFIX, this processing is turned off. Const DT_INTERNAL = &H1000 ' Uses the system font to calculate text metrics. Const DT_EDITCONTROL = &H2000 ' Duplicates the text-displaying characteristics of a ' multiline edit control. Specifically, the average ' character width is calculated in the same manner as for ' an edit control, and the function does not display a ' partially visible last line. Const DT_PATH_ELLIPSIS = &H4000 ' For displayed text, replaces characters in the middle ' of the string with ellipses so that the result fits in ' the specified rectangle. If the string contains backslash ' (\) characters, DT_PATH_ELLIPSIS preserves as much as ' possible of the text after the last backslash. Const DT_END_ELLIPSIS = &H8000 ' For displayed text, replaces the end of a string with ' ellipses so that the result fits in the specified ' rectangle. Any word (not at the end of the string) that ' goes beyond the limits of the rectangle is truncated ' without ellipses. Const DT_MODIFYSTRING = &H10000 ' Modifies the specified string to match the displayed ' text. This value has no effect unless DT_END_ELLIPSIS ' or DT_PATH_ELLIPSIS is specified. Const DT_RTLREADING = &H20000 ' Layout in right-to-left reading order for bi-directional ' text when the font selected into the hdc is a Hebrew or ' Arabic font. The default reading order for all text is ' left-to-right. Const DT_WORD_ELLIPSIS = &H40000 ' Truncates any word that does not fit in the rectangle ' and adds ellipses. Compare with DT_END_ELLIPSIS and ' DT_PATH_ELLIPSIS. Const DT_NOFULLWIDTHCHARBREAK = &H80000 ' Prevents a line break at a DBCS (double-wide ' character string), so that the line-breaking rule is ' equivalent to SBCS strings. For example, this can be ' used in Korean windows, for more readability of icon ' labels. This value has no effect unless DT_WORDBREAK ' is specified. Const DT_HIDEPREFIX = &H100000 ' Ignores the ampersand (&) prefix character in the text. ' The letter that follows will not be underlined, but ' other mnemonic-prefix characters are still processed. Const DT_PREFIXONLY = &H200000 ' Draws only an underline at the position of the character ' following the ampersand (&) prefix character. Does not ' draw any character in the string. const maxW = 1024 ' Largeur d'une image du couple const maxH = 768 ' Hauteur d'une image du couple const backColor = &hffffff ' Couleur de remplissage const BORDER = 50 const DRAW_MIRE = True ' Trace la mire centrale const DRAW_RECT = True ' Trace le rectangle à BORDER des bords const DRAW_NOMBRES3D = True ' Trace une série de chiffres avec profondeur variable const DRAW_REPERES_GD = True ' Trace les repères 'G' et 'D' sur chacune des vues (vision croisée) const DRAW_SCF = True ' Trace "Stéréo-Club Français" const DRAW_DEGRADEGRIS = False ' Trace un dégradé de gris dim alb, pic, picNew, i, rect, k app.ClearTrace set alb = app.GetCurrentAlbum if not alb is nothing then set picNew = alb.NewPicture( 2*maxW, maxH, 24, backColor) set rect = CreateObject("MyAlbum.rect") if DRAW_MIRE then ' Mire centrale en pointillé picNew.DrawLine 0, maxH / 2, 2*maxW, maxH / 2, 0, 1, 0 picNew.DrawLine maxW / 2, 0, maxW / 2, maxH, 0, 1, 0 picNew.DrawLine maxW + maxW / 2, 0, maxW + maxW / 2, maxH, 0, 1, 0 picNew.DrawLine maxW/2, maxH / 2 - BORDER, maxW/2, maxH / 2 + BORDER, 3, 0, 0 ' Croix centrale picNew.DrawLine maxW/2 - BORDER, maxH / 2, maxW/2 + BORDER, maxH / 2, 3, 0, 0 picNew.DrawLine maxW + maxW/2, maxH / 2 - BORDER, maxW + maxW/2, maxH / 2 + BORDER, 3, 0, 0 picNew.DrawLine maxW + maxW/2 - BORDER, maxH / 2, maxW + maxW/2 + BORDER, maxH / 2, 3, 0, 0 end if if DRAW_RECT then ' Cadre principal rect.x = BORDER rect.y = BORDER rect.w = maxW-2*BORDER rect.h = maxH-2*BORDER picNew.DrawRectangle rect, 5, 0, -1, DRAWRECT_RECT, 0, 0 rect.x = rect.x + maxW picNew.DrawRectangle rect, 5, 0, -1, DRAWRECT_RECT, 0, 0 ' Cercle inscrit dans le cadre rect.x = BORDER + ( maxW - maxH ) / 2 rect.w = rect.h picNew.DrawRectangle rect, 5, 0, -1, DRAWRECT_ELLIPSE, 0, 0 rect.x = rect.x + maxW picNew.DrawRectangle rect, 5, 0, -1, DRAWRECT_ELLIPSE, 0, 0 end if if DRAW_NOMBRES3D then for i = -9 to 9 rect.x = maxW/2 + i*45 -9 rect.y = 3*BORDER rect.w = maxW rect.h = 50 picNew.drawText i, rect, "Arial,36,0,400,0,0,0", 0, -1, DT_TOP or DT_LEFT or DT_NOPREFIX rect.x = rect.x + maxW + 4*i picNew.drawText i, rect, "Arial,36,0,400,0,0,0", 0, -1, DT_TOP or DT_LEFT or DT_NOPREFIX next end if if DRAW_REPERES_GD then rect.x = BORDER rect.y = maxH/2 rect.w = maxW/2-BORDER rect.h = maxH/2-BORDER picNew.drawText " D", rect, "Times,150,0,700,0,0,0", &hffff00, -1, DT_BOTTOM or DT_LEFT or DT_NOPREFIX or DT_SINGLELINE rect.x = 3*maxW/2 picNew.drawText "G ", rect, "Times,150,0,700,0,0,0", &hff, -1, DT_BOTTOM or DT_RIGHT or DT_NOPREFIX or DT_SINGLELINE end if if DRAW_SCF then rect.x = -10 rect.y = BORDER rect.w = maxW rect.h = maxH picNew.drawText "Stéréo-Club Français", rect, "Times,90,40,700,0,0,0", 0, -1, DT_TOP or DT_CENTER or DT_NOPREFIX or DT_SINGLELINE rect.x = maxW+10 picNew.drawText "Stéréo-Club Français", rect, "Times,90,40,700,0,0,0", 0, -1, DT_TOP or DT_CENTER or DT_NOPREFIX or DT_SINGLELINE end if if DRAW_DEGRADEGRIS then dim w, xP, wB, c, color wB = 3 * BORDER / 2 w = maxW - 2 * wB for xP = wB to maxW - wB c = 255 - round( 255 * (xP-wB) / w ) color = c + 256 * c + 65536 * c app.Trace c picNew.DrawLine xP, 4*BORDER, xP, 5*BORDER, 1, 0, color picNew.DrawLine maxW + xP, 4*BORDER, maxW + xP, 5*BORDER, 1, 0, color next end if ' Now save the picture dim filename 'filename = "d:\Mire3D.png" filename = app.GetFilename( "Nom du fichier dans lequel enregistrer la mire :", 1, "Mire3d.png", "", 0 ) picNew.Save filename, True picNew.UpdateThumbnail True set picNew = Nothing set rect = Nothing alb.redraw end if app.Trace "Fini !", -1, TRACE_GREENDOT