diff6-10.chapter25.txtこのページは最後に更新されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。 last mod. 2008-08-28 (木) 09:58:21
5c5,6 < takes place in a separate window that is created when open_graph is called. --- > takes place in a separate window that is created when Graphics.open_graph is > called. 7,9c8,9 < This library is implemented under the X11 windows system. < Programs that use the graphics library must be linked as < follows: --- > This library is implemented under the X11 windows system. Programs that > use the graphics library must be linked as follows: 18,26c18,25 < or (if dynamic linking of C libraries is supported on your < platform), start ocaml and type #load "graphics.cma";;. < Here are the graphics mode specifications supported by < open_graph on the X11 implementation of this library: the < argument to open_graph has the format "display-name geometry", < where display-name is the name of the X-windows display to < connect to, and geometry is a standard X-windows geometry < specification. The two components are separated by a space. < Either can be omitted, or both. Examples: --- > or (if dynamic linking of C libraries is supported on your platform), start > ocaml and type #load "graphics.cma";;. > Here are the graphics mode specifications supported by Graphics.open_graph > on the X11 implementation of this library: the argument to > Graphics.open_graph has the format "display-name geometry", where > display-name is the name of the X-windows display to connect to, and > geometry is a standard X-windows geometry specification. The two components > are separated by a space. Either can be omitted, or both. Examples: 28c27 < open_graph "foo:0" connects to the display foo:0 and creates a --- > Graphics.open_graph "foo:0" connects to the display foo:0 and creates a 30,36c29,33 < open_graph "foo:0 300x100+50-0" connects to the display foo:0 < and creates a window 300 pixels wide by 100 pixels tall, at < location (50,0) < open_graph " 300x100+50-0" connects to the default display and < creates a window 300 pixels wide by 100 pixels tall, at < location (50,0) < open_graph "" connects to the default display and creates a --- > Graphics.open_graph "foo:0 300x100+50-0" connects to the display foo:0 and > creates a window 300 pixels wide by 100 pixels tall, at location (50,0) > Graphics.open_graph " 300x100+50-0" connects to the default display and > creates a window 300 pixels wide by 100 pixels tall, at location (50,0) > Graphics.open_graph "" connects to the default display and creates a 41,45c38,41 < This library is available both for standalone compiled programs < and under the toplevel application ocamlwin.exe. For the latter, < this library must be loaded in-core by typing < << < #load "graphics.cma";; --- > This library is available both for standalone compiled programs and under > the toplevel application ocamlwin.exe. For the latter, this library must be > loaded in-core by typing > << #load "graphics.cma";; 63d58 < 75d69 < 80,87c74,79 < Show the graphics window or switch the screen to graphic mode. < The graphics window is cleared and the current point is set to < (0, 0). The string argument is used to pass optional < information on the desired graphics mode, the graphics window < size, and so on. Its interpretation is implementation-dependent. < If the empty string is given, a sensible default is selected. < < --- > Show the graphics window or switch the screen to graphic mode. The graphics > window is cleared and the current point is set to (0, 0). The string > argument is used to pass optional information on the desired graphics mode, > the graphics window size, and so on. Its interpretation is > implementation-dependent. If the empty string is given, a sensible default > is selected. 93,96c85 < Delete the graphics window or switch the screen back to text < mode. < < --- > Delete the graphics window or switch the screen back to text mode. 103a93,95 > << > val resize_window : int -> int -> unit > >> 104a97 > Resize and erase the graphics window. 112,113d104 < < 120,121d110 < < 126,129c115,118 < Return the size of the graphics window. Coordinates of the < screen pixels range over 0 .. size_x()-1 and 0 .. size_y()-1. < Drawings outside of this rectangle are clipped, without causing < an error. The origin (0,0) is at the lower left corner. --- > Return the size of the graphics window. Coordinates of the screen pixels > range over 0 .. size_x()-1 and 0 .. size_y()-1. Drawings outside of this > rectangle are clipped, without causing an error. The origin (0,0) is at the > lower left corner. 136d124 < 141,147c129,132 < A color is specified by its R, G, B components. Each component < is in the range 0..255. The three components are packed in an < int: 0xRRGGBB, where RR are the two hexadecimal digits for the < red component, GG for the green component, BB for the blue < component. < < --- > A color is specified by its R, G, B components. Each component is in the > range 0..255. The three components are packed in an int: 0xRRGGBB, where RR > are the two hexadecimal digits for the red component, GG for the green > component, BB for the blue component. 153,157c138,139 < rgb r g b returns the integer encoding the color with red < component r, green component g, and blue component b. r, g and < b are in the range 0..255. < < --- > rgb r g b returns the integer encoding the color with red component r, > green component g, and blue component b. r, g and b are in the range 0..255. 165,166d146 < < 173,174d152 < < 179,183c157,160 < Default background and foreground colors (usually, either black < foreground on a white background or white foreground on a < black background). Graphics.clear_graph[25.1] fills the screen < with the background color. The initial drawing color is < foreground. --- > Default background and foreground colors (usually, either black foreground > on a white background or white foreground on a black background). > Graphics.clear_graph[25.1] fills the screen with the background color. The > initial drawing color is foreground. 190d166 < 195d170 < 200d174 < 205d178 < 210d182 < 215d186 < 220d190 < 225d194 < 230a200 > 234d203 < 241,242d209 < < 249,250d215 < < 255,258c220,221 < Return the color of the given point in the backing store (see < "Double buffering" below). < < --- > Return the color of the given point in the backing store (see "Double > buffering" below). 266,267d228 < < 274,275d234 < < 282,283d240 < < 290,291d246 < < 298,299d252 < < 304,307c257,258 < Draw a line with endpoints the current point and the given < point, and move the current point to the given point. < < --- > Draw a line with endpoints the current point and the given point, and move > the current point to the given point. 313,317c264,265 < Draw a line with endpoints the current point and the current < point translated of the given vector, and move the current < point to this point. < < --- > Draw a line with endpoints the current point and the current point > translated of the given vector, and move the current point to this point. 323,327c271,272 < curveto b c d draws a cubic Bezier curve starting from the < current point to point d, with control points b and c, and < moves the current point to d. < < --- > curveto b c d draws a cubic Bezier curve starting from the current point to > point d, with control points b and c, and moves the current point to d. 333,336c278,280 < draw_rect x y w h draws the rectangle with lower left corner < at x,y, width w and height h. The current point is unchanged. < < --- > draw_rect x y w h draws the rectangle with lower left corner at x,y, width > w and height h. The current point is unchanged. Raise Invalid_argument if w > or h is negative. 342,347c286,288 < draw_poly_line points draws the line that joins the points < given by the array argument. The array contains the coordinates < of the vertices of the polygonal line, which need not be < closed. The current point is unchanged. < < --- > draw_poly_line points draws the line that joins the points given by the > array argument. The array contains the coordinates of the vertices of the > polygonal line, which need not be closed. The current point is unchanged. 353,357c294,295 < draw_poly polygon draws the given polygon. The array contains < the coordinates of the vertices of the polygon. The current < point is unchanged. < < --- > draw_poly polygon draws the given polygon. The array contains the > coordinates of the vertices of the polygon. The current point is unchanged. 363,368c301,304 < draw_segments segments draws the segments given in the array < argument. Each segment is specified as a quadruple (x0, y0, x1, < y1) where (x0, y0) and (x1, y1) are the coordinates of the end < points of the segment. The current point is unchanged. < < --- > draw_segments segments draws the segments given in the array argument. Each > segment is specified as a quadruple (x0, y0, x1, y1) where (x0, y0) and (x1, > y1) are the coordinates of the end points of the segment. The current point > is unchanged. 374,378c310,313 < draw_arc x y rx ry a1 a2 draws an elliptical arc with center < x,y, horizontal radius rx, vertical radius ry, from angle a1 to < angle a2 (in degrees). The current point is unchanged. < < --- > draw_arc x y rx ry a1 a2 draws an elliptical arc with center x,y, > horizontal radius rx, vertical radius ry, from angle a1 to angle a2 (in > degrees). The current point is unchanged. Raise Invalid_argument if rx or ry > is negative. 384,388c319,321 < draw_ellipse x y rx ry draws an ellipse with center x,y, < horizontal radius rx and vertical radius ry. The current point < is unchanged. < < --- > draw_ellipse x y rx ry draws an ellipse with center x,y, horizontal radius > rx and vertical radius ry. The current point is unchanged. Raise > Invalid_argument if rx or ry is negative. 394,397c327,328 < draw_circle x y r draws a circle with center x,y and radius r. < The current point is unchanged. < < --- > draw_circle x y r draws a circle with center x,y and radius r. The current > point is unchanged. Raise Invalid_argument if r is negative. 403,406c334,337 < Set the width of points and lines drawn with the functions < above. Under X Windows, set_line_width 0 selects a width of 1 < pixel and a faster, but less precise drawing algorithm than the < one used when set_line_width 1 is specified. --- > Set the width of points and lines drawn with the functions above. Under X > Windows, set_line_width 0 selects a width of 1 pixel and a faster, but less > precise drawing algorithm than the one used when set_line_width 1 is > specified. Raise Invalid_argument if the argument is negative. 413d343 < 420,421d349 < < 426,430c354,356 < Draw a character or a character string with lower left corner < at current position. After drawing, the current position is set < to the lower right corner of the text drawn. < < --- > Draw a character or a character string with lower left corner at current > position. After drawing, the current position is set to the lower right > corner of the text drawn. 436,439c362,363 < Set the font used for drawing text. The interpretation of the < arguments to set_font is implementation-dependent. < < --- > Set the font used for drawing text. The interpretation of the argument to > set_font is implementation-dependent. 445,449c369,370 < Set the character size used for drawing text. The < interpretation of the arguments to set_text_size is < implementation-dependent. < < --- > Set the character size used for drawing text. The interpretation of the > argument to set_text_size is implementation-dependent. 455,456c376,377 < Return the dimensions of the given text, if it were drawn with < the current font and size. --- > Return the dimensions of the given text, if it were drawn with the current > font and size. 463d383 < 468,471c388,390 < fill_rect x y w h fills the rectangle with lower left corner < at x,y, width w and height h, with the current color. < < --- > fill_rect x y w h fills the rectangle with lower left corner at x,y, width > w and height h, with the current color. Raise Invalid_argument if w or h is > negative. 477,480c396,397 < Fill the given polygon with the current color. The array < contains the coordinates of the vertices of the polygon. < < --- > Fill the given polygon with the current color. The array contains the > coordinates of the vertices of the polygon. 486,489c403,404 < Fill an elliptical pie slice with the current color. The < parameters are the same as for Graphics.draw_arc[25.1]. < < --- > Fill an elliptical pie slice with the current color. The parameters are the > same as for Graphics.draw_arc[25.1]. 495,498c410,411 < Fill an ellipse with the current color. The parameters are the < same as for Graphics.draw_ellipse[25.1]. < < --- > Fill an ellipse with the current color. The parameters are the same as for > Graphics.draw_ellipse[25.1]. 504,505c417,418 < Fill a circle with the current color. The parameters are the < same as for Graphics.draw_circle[25.1]. --- > Fill a circle with the current color. The parameters are the same as for > Graphics.draw_circle[25.1]. 512d424 < 517,520c429,430 < The abstract type for images, in internal representation. < Externally, images are represented as matrices of colors. < < --- > The abstract type for images, in internal representation. Externally, > images are represented as matrices of colors. 526,533c436,440 < In matrices of colors, this color represent a ``transparent'' < point: when drawing the corresponding image, all pixels on the < screen corresponding to a transparent pixel in the image will < not be modified, while other points will be set to the color of < the corresponding point in the image. This allows superimposing < an image over an existing background. < < --- > In matrices of colors, this color represent a "transparent" point: when > drawing the corresponding image, all pixels on the screen corresponding to a > transparent pixel in the image will not be modified, while other points will > be set to the color of the corresponding point in the image. This allows > superimposing an image over an existing background. 539,543c446,448 < Convert the given color matrix to an image. Each sub-array < represents one horizontal line. All sub-arrays must have the < same length; otherwise, exception Graphic_failure is raised. < < --- > Convert the given color matrix to an image. Each sub-array represents one > horizontal line. All sub-arrays must have the same length; otherwise, > exception Graphic_failure is raised. 551,552d455 < < 559,560d461 < < 565,568c466,467 < Capture the contents of a rectangle on the screen as an image. < The parameters are the same as for Graphics.fill_rect[25.1]. < < --- > Capture the contents of a rectangle on the screen as an image. The > parameters are the same as for Graphics.fill_rect[25.1]. 574,579c473,475 < create_image w h returns a new image w pixels wide and h < pixels tall, to be used in conjunction with blit_image. The < initial image contents are random, except that no point is < transparent. < < --- > create_image w h returns a new image w pixels wide and h pixels tall, to be > used in conjunction with blit_image. The initial image contents are random, > except that no point is transparent. 585,589c481,484 < blit_image img x y copies screen pixels into the image img, < modifying img in-place. The pixels copied are those inside the < rectangle with lower left corner at x,y, and width and height < equal to those of the image. Pixels that were transparent in < img are left unchanged. --- > blit_image img x y copies screen pixels into the image img, modifying img > in-place. The pixels copied are those inside the rectangle with lower left > corner at x,y, and width and height equal to those of the image. Pixels that > were transparent in img are left unchanged. 596d490 < 634,635d527 < < 669,670d560 < < 675,682c565,570 < Wait until one of the events specified in the given event list < occurs, and return the status of the mouse and keyboard at that < time. If Poll is given in the event list, return immediately < with the current status. If the mouse cursor is outside of the < graphics window, the mouse_x and mouse_y fields of the event are < outside the range 0..size_x()-1, 0..size_y()-1. Keypresses are < queued, and dequeued one by one when the Key_pressed event is < specified. --- > Wait until one of the events specified in the given event list occurs, and > return the status of the mouse and keyboard at that time. If Poll is given > in the event list, return immediately with the current status. If the mouse > cursor is outside of the graphics window, the mouse_x and mouse_y fields of > the event are outside the range 0..size_x()-1, 0..size_y()-1. Keypresses are > queued, and dequeued one by one when the Key_pressed event is specified. 689d576 < 694,699c581,583 < Return the position of the mouse cursor, relative to the < graphics window. If the mouse cursor is outside of the graphics < window, mouse_pos() returns a point outside of the range < 0..size_x()-1, 0..size_y()-1. < < --- > Return the position of the mouse cursor, relative to the graphics window. > If the mouse cursor is outside of the graphics window, mouse_pos() returns a > point outside of the range 0..size_x()-1, 0..size_y()-1. 707,708d590 < < 713,716c595,596 < Wait for a key to be pressed, and return the corresponding < character. Keypresses are queued. < < --- > Wait for a key to be pressed, and return the corresponding character. > Keypresses are queued. 722,723c602,603 < Return true if a keypress is available; that is, if read_key < would not block. --- > Return true if a keypress is available; that is, if read_key would not > block. 730d609 < 735,736c614,615 < sound freq dur plays a sound at frequency freq (in hertz) for < a duration dur (in milliseconds). --- > sound freq dur plays a sound at frequency freq (in hertz) for a duration > dur (in milliseconds). 743d621 < 748,762c626,636 < By default, drawing takes place both on the window displayed < on screen, and in a memory area (the ``backing store''). The < backing store image is used to re-paint the on-screen window < when necessary. < To avoid flicker during animations, it is possible to turn off < on-screen drawing, perform a number of drawing operations in < the backing store only, then refresh the on-screen window < explicitly. < auto_synchronize false turns on-screen drawing off. All < subsequent drawing commands are performed on the backing store < only. < auto_synchronize true refreshes the on-screen window from the < backing store (as per synchronize), then turns on-screen < drawing back on. All subsequent drawing commands are performed < both on screen and in the backing store. --- > By default, drawing takes place both on the window displayed on screen, and > in a memory area (the "backing store"). The backing store image is used to > re-paint the on-screen window when necessary. > To avoid flicker during animations, it is possible to turn off on-screen > drawing, perform a number of drawing operations in the backing store only, > then refresh the on-screen window explicitly. > auto_synchronize false turns on-screen drawing off. All subsequent drawing > commands are performed on the backing store only. > auto_synchronize true refreshes the on-screen window from the backing store > (as per synchronize), then turns on-screen drawing back on. All subsequent > drawing commands are performed both on screen and in the backing store. 765,766d638 < < 771,775c643,644 < Synchronize the backing store and the on-screen window, by < copying the contents of the backing store onto the graphics < window. < < --- > Synchronize the backing store and the on-screen window, by copying the > contents of the backing store onto the graphics window. 781,787c650,653 < Set display mode on or off. When turned on, drawings are done < in the graphics window; when turned off, drawings do not affect < the graphics window. This occurs independently of drawing into < the backing store (see the function Graphics.remember_mode[25.1] < below). Default display mode is on. < < --- > Set display mode on or off. When turned on, drawings are done in the > graphics window; when turned off, drawings do not affect the graphics > window. This occurs independently of drawing into the backing store (see the > function Graphics.remember_mode[25.1] below). Default display mode is on. 793,799c659,662 < Set remember mode on or off. When turned on, drawings are done < in the backing store; when turned off, the backing store is < unaffected by drawings. This occurs independently of drawing < onto the graphics window (see the function < Graphics.display_mode[25.1] above). Default remember mode is < on. < --- > Set remember mode on or off. When turned on, drawings are done in the > backing store; when turned off, the backing store is unaffected by drawings. > This occurs independently of drawing onto the graphics window (see the > function Graphics.display_mode[25.1] above). Default remember mode is on. |