242 lines
8.1 KiB
HTML
242 lines
8.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Drawing Shapes</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
<body background="images/back.gif">
|
|
<!--START-->
|
|
|
|
<h3>Drawing shapes</h3>
|
|
|
|
There is a whole collection of functions available to draw different shapes.
|
|
Also there are functions to draw text (see next section). You can only use
|
|
these in the drawing event of an object; these functions in general don't
|
|
make any sense anywhere else in code. Realize that collisions between
|
|
instances are determined by their sprites (or masks) and not by what
|
|
you actually draw. The following drawing functions exist that can be
|
|
used to draw basic shapes.
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>draw_clear(col)</b></tt>
|
|
Clears the entire room in the given color (no alpha blending).<br>
|
|
<tt><b>draw_clear_alpha(col,alpha)</b></tt>
|
|
Clears the entire room in the given color and alpha value (in particular useful for surfaces).<br>
|
|
<tt><b>draw_point(x,y)</b></tt>
|
|
Draws a point at (x,y) in the current color.<br>
|
|
<tt><b>draw_line(x1,y1,x2,y2)</b></tt>
|
|
Draws a line from (x1,y1) to (x2,y2).<br>
|
|
<tt><b>draw_line_width(x1,y1,x2,y2,w)</b></tt>
|
|
Draws a line from (x1,y1) to (x2,y2) with width w.<br>
|
|
<tt><b>draw_rectangle(x1,y1,x2,y2,outline)</b></tt>
|
|
Draws a rectangle. <tt>outline</tt> indicates whether
|
|
only the outline must be drawn (true) or it should be filled (false).<br>
|
|
<tt><b>draw_roundrect(x1,y1,x2,y2,outline)</b></tt>
|
|
Draws a rounded rectangle. <tt>outline</tt> indicates whether
|
|
only the outline must be drawn (true) or it should be filled (false).<br>
|
|
<tt><b>draw_triangle(x1,y1,x2,y2,x3,y3,outline)</b></tt>
|
|
Draws a triangle. <tt>outline</tt> indicates whether
|
|
only the outline must be drawn (true) or it should be filled (false).<br>
|
|
<tt><b>draw_circle(x,y,r,outline)</b></tt>
|
|
Draws a circle at (x,y) with radius r. <tt>outline</tt> indicates whether
|
|
only the outline must be drawn (true) or it should be filled (false).<br>
|
|
<tt><b>draw_ellipse(x1,y1,x2,y2,outline)</b></tt>
|
|
Draws an ellipse. <tt>outline</tt> indicates whether
|
|
only the outline must be drawn (true) or it should be filled (false).<br>
|
|
<tt><b>draw_set_circle_precision(precision)</b></tt>
|
|
Sets the precision with which circles are drawn, that is, the number
|
|
of segments they consist of. The precision must lie between 4 and 64
|
|
and must be dividable by 4. This is also used for drawing ellipses and
|
|
rounded rectangles.<br>
|
|
<tt><b>draw_arrow(x1,y1,x2,y2,size)</b></tt>
|
|
Draws an arrow from (x1,y1) to (x2,y2).
|
|
size indicates the size of the arrow in pixels.<br>
|
|
<tt><b>draw_button(x1,y1,x2,y2,up)</b></tt>
|
|
Draws a button, <tt>up</tt> indicates whether up (1) or down (0).<br>
|
|
<tt><b>draw_path(path,x,y,absolute)</b></tt>
|
|
With this function you can draw the indicated
|
|
path in the room with its start at position (x,y). If absolute is true the path is drawn
|
|
at the position where it was defined and the values of x and y are ignored.<br>
|
|
<tt><b>draw_healthbar(x1,y1,x2,y2,amount,backcol,mincol,maxcol,direction,showback,showborder)</b></tt>
|
|
With this function you can draw a healthbar (or any other bar that indicates some value, like
|
|
e.g. the damage). The arguments x1, y1, x2 and y2 indicate the total area for the bar.
|
|
amount indicates the percentage of the bar that must be filled (must lie between 0 and
|
|
100). backcol is the color of the background for the bar. mincol and maxcol indicate the
|
|
color when the amount is 0 and 100 respectively. For an amount in between the color is
|
|
interpolated. So you can easily make a bar that goes e.g. from green to red. The direction
|
|
is the direction in which the bar is drawn. 0 indicates that the bar is anchored at the
|
|
left, 1 at the right, 2 at the top and 3 at the bottom. Finally showback indicates whether
|
|
a background box must be shown and showborder indicated whether the box and bar should
|
|
have a black border line.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
|
|
Most of the above functions use the color and alpha setting that
|
|
can be changed with following functions.
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>draw_set_color(col)</b></tt>
|
|
Sets the drawing color to be used from now on for drawing primitives.<br>
|
|
<tt><b>draw_set_alpha(alpha)</b></tt>
|
|
Sets the alpha transparency value to be used from now on for drawing
|
|
primitives. Should lie in the range 0-1. 0 is fully transparent, 1 is fully opaque.<br>
|
|
<tt><b>draw_get_color()</b></tt>
|
|
Returns the drawing color used for drawing primitives.<br>
|
|
<tt><b>draw_get_alpha()</b></tt>
|
|
Returns the alpha value used for drawing primitives.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
|
|
A whole range of predefined colors is available:
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>c_aqua</b></tt><br>
|
|
<tt><b>c_black</b></tt><br>
|
|
<tt><b>c_blue</b></tt><br>
|
|
<tt><b>c_dkgray</b></tt><br>
|
|
<tt><b>c_fuchsia</b></tt><br>
|
|
<tt><b>c_gray</b></tt><br>
|
|
<tt><b>c_green</b></tt><br>
|
|
<tt><b>c_lime</b></tt><br>
|
|
<tt><b>c_ltgray</b></tt><br>
|
|
<tt><b>c_maroon</b></tt><br>
|
|
<tt><b>c_navy</b></tt><br>
|
|
<tt><b>c_olive</b></tt><br>
|
|
<tt><b>c_orange</b></tt><br>
|
|
<tt><b>c_purple</b></tt><br>
|
|
<tt><b>c_red</b></tt><br>
|
|
<tt><b>c_silver</b></tt><br>
|
|
<tt><b>c_teal</b></tt><br>
|
|
<tt><b>c_white</b></tt><br>
|
|
<tt><b>c_yellow</b></tt><br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
|
|
The following functions can help you to create the colors you want.
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>make_color_rgb(red,green,blue)</b></tt>
|
|
Returns a color with the indicated red,
|
|
green, and blue components, where red, green and blue must be values between 0 and 255.<br>
|
|
<tt><b>make_color_hsv(hue,saturation,value)</b></tt>
|
|
Returns a color with the
|
|
indicated hue, saturation and value components (each between 0 and 255).<br>
|
|
<tt><b>color_get_red(col)</b></tt>
|
|
Returns the red component of the color.<br>
|
|
<tt><b>color_get_green(col)</b></tt>
|
|
Returns the green component of the color.<br>
|
|
<tt><b>color_get_blue(col)</b></tt>
|
|
Returns the blue component of the color.<br>
|
|
<tt><b>color_get_hue(col)</b></tt>
|
|
Returns the hue component of the color.<br>
|
|
<tt><b>color_get_saturation(col)</b></tt>
|
|
Returns the saturation component of the color.<br>
|
|
<tt><b>color_get_value(col)</b></tt>
|
|
Returns the value component of the color.<br>
|
|
<tt><b>merge_color(col1,col2,amount)</b></tt>
|
|
Returns a merged color of col1 and col2.
|
|
The merging is determined by amount. A value of 0 corresponds to col1, a value of 1 to
|
|
col2, and values in between to merged values.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
|
|
The following miscellaneous functions exist.
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>draw_getpixel(x,y)</b></tt>
|
|
Returns the color of the pixel corresponding to position (x,y) in the room. This is
|
|
not very fast, so use with care.<br>
|
|
<tt><b>screen_save(fname)</b></tt>
|
|
Saves a png image of the screen in the given
|
|
filename. Useful for making screenshots.<br>
|
|
<tt><b>screen_save_part(fname,x,y,w,h)</b></tt>
|
|
Saves part of the screen in the given png filename.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
|
|
|
|
<!--END-->
|
|
</body>
|
|
</html>
|
|
|
|
<!-- KEYWORDS
|
|
drawing shapes
|
|
points
|
|
lines
|
|
rectangles
|
|
triangles
|
|
circles
|
|
healthbar
|
|
color
|
|
alpha
|
|
making colors
|
|
merging colors
|
|
colors, merging
|
|
rgb
|
|
hsv
|
|
saving screen
|
|
snapshot
|
|
taking snapshots
|
|
|
|
draw_clear()
|
|
draw_clear_alpha()
|
|
draw_point()
|
|
draw_line()
|
|
draw_line_width()
|
|
draw_rectangle()
|
|
draw_roundrect()
|
|
draw_triangle()
|
|
draw_circle()
|
|
draw_ellipse()
|
|
draw_set_circle_precision()
|
|
draw_arrow()
|
|
draw_button()
|
|
draw_path()
|
|
draw_healthbar()
|
|
draw_set_color()
|
|
draw_set_alpha()
|
|
draw_get_color()
|
|
draw_get_alpha()
|
|
c_aqua
|
|
c_black
|
|
c_blue
|
|
c_dkgray
|
|
c_fuchsia
|
|
c_gray
|
|
c_green
|
|
c_lime
|
|
c_ltgray
|
|
c_maroon
|
|
c_navy
|
|
c_olive
|
|
c_orange
|
|
c_purple
|
|
c_red
|
|
c_silver
|
|
c_teal
|
|
c_white
|
|
c_yellow
|
|
make_color_rgb()
|
|
make_color_hsv()
|
|
color_get_red()
|
|
color_get_green()
|
|
color_get_blue()
|
|
color_get_hue()
|
|
color_get_saturation()
|
|
color_get_value()
|
|
merge_color()
|
|
draw_getpixel()
|
|
screen_save()
|
|
screen_save_part()
|
|
--> |