Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
draw.qh File Reference
#include "i18n.qh"
#include "vector.qh"
Include dependency graph for draw.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void draw_BorderPicture (vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
void Draw_CylindricLine (vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg)
ERASEABLE void drawstringcenter (vector position, string text, vector theScale, vector rgb, float theAlpha, int flag)
ERASEABLE void drawstringright (vector position, string text, vector theScale, vector rgb, float theAlpha, int flag)

Variables

noref float vid_conheight
noref float vid_conwidth

Function Documentation

◆ draw_BorderPicture()

void draw_BorderPicture ( vector theOrigin,
string pic,
vector theSize,
vector theColor,
float theAlpha,
vector theBorderSize )

Definition at line 44 of file draw.qh.

45 {
46 if (theBorderSize.x < 0 && theBorderSize.y < 0) // draw whole image as it is
47 {
48 drawpic_builtin(theOrigin, pic, theSize, theColor, theAlpha, 0);
49 return;
50 }
51 if (theBorderSize.x == 0 && theBorderSize.y == 0) // no border
52 {
53 // draw only the central part
54 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
55 return;
56 }
57
58 vector dX, dY;
59 vector width, height;
60 vector bW, bH;
61 // pic = draw_UseSkinFor(pic);
62 width = eX * theSize.x;
63 height = eY * theSize.y;
64 if (theSize.x <= theBorderSize.x * 2)
65 {
66 // not wide enough... draw just left and right then
67 bW = eX * (0.25 * theSize.x / (theBorderSize.x * 2));
68 if (theSize.y <= theBorderSize.y * 2)
69 {
70 // not high enough... draw just corners
71 bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2));
72 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
73 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
74 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
75 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
76 }
77 else
78 {
79 dY = theBorderSize.x * eY;
80 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
81 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
82 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
83 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
84 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
85 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
86 }
87 }
88 else
89 {
90 if (theSize.y <= theBorderSize.y * 2)
91 {
92 // not high enough... draw just top and bottom then
93 bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2));
94 dX = theBorderSize.x * eX;
95 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
96 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
97 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
98 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
99 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
100 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
101 }
102 else
103 {
104 dX = theBorderSize.x * eX;
105 dY = theBorderSize.x * eY;
106 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
107 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
108 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
109 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
110 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
111 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
112 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
113 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
114 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
115 }
116 }
117 }
float height
Definition bobbing.qc:3
float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag)
vector
Definition self.qh:92
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44

References drawsubpic(), eX, eY, height, and vector.

Referenced by BorderImage_draw(), m_tooltip(), and minigame_hud_simpleboard().

◆ Draw_CylindricLine()

void Draw_CylindricLine ( vector from,
vector to,
float thickness,
string texture,
float aspect,
float shift,
vector rgb,
float theAlpha,
float drawflag,
vector vieworg )

Definition at line 11 of file draw.qh.

12 {
13 // I want to draw a quad...
14 // from and to are MIDPOINTS.
15
16 float len = vlen(to - from);
17 if (!len)
18 return;
19
20 float length_tex = aspect * len / thickness;
21 vector axis = (to - from) / len; // same as axis = normalize(to - from) but cheaper
22
23 // direction is perpendicular to the view normal, and perpendicular to the axis
24 vector thickdir = normalize(cross(axis, vieworg - from));
25
26 vector ofs = thickdir * (thickness / 2);
27
28 R_BeginPolygon(texture, drawflag, false);
29 R_PolygonVertex(from - ofs, '0 0 0' + shift * '1 0 0', rgb, theAlpha);
30 R_PolygonVertex(from + ofs, '0 1 0' + shift * '1 0 0', rgb, theAlpha);
31 R_PolygonVertex(to + ofs, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha);
32 R_PolygonVertex(to - ofs, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha);
33 R_EndPolygon();
34 }
float vlen(vector v)
vector normalize(vector v)
#define cross(a, b)
Definition vector.qh:25

References cross, normalize(), vector, and vlen().

Referenced by bumble_raygun_draw(), Draw_ArcBeam_callback(), Draw_GrapplingHook_trace_callback(), and Porto_Draw().

◆ drawstringcenter()

ERASEABLE void drawstringcenter ( vector position,
string text,
vector theScale,
vector rgb,
float theAlpha,
int flag )

Definition at line 127 of file draw.qh.

128 {
129 position.x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale.x);
130 drawstring_builtin(position, text, theScale, rgb, theAlpha, flag);
131 }
#define strlen
noref float vid_conwidth
Definition draw.qh:8

References strlen, vector, and vid_conwidth.

◆ drawstringright()

ERASEABLE void drawstringright ( vector position,
string text,
vector theScale,
vector rgb,
float theAlpha,
int flag )

Definition at line 120 of file draw.qh.

121 {
122 position.x -= 2 / 3 * strlen(text) * theScale.x;
123 drawstring_builtin(position, text, theScale, rgb, theAlpha, flag);
124 }

References strlen, and vector.

Variable Documentation

◆ vid_conheight

◆ vid_conwidth