Max 5 API Reference
00001 00002 #ifndef _JGRAPHICS_H_ 00003 #define _JGRAPHICS_H_ 00004 00005 BEGIN_USING_C_LINKAGE 00006 00007 #if C74_PRAGMA_STRUCT_PACKPUSH 00008 #pragma pack(push, 2) 00009 #elif C74_PRAGMA_STRUCT_PACK 00010 #pragma pack(2) 00011 #endif 00012 00013 // opaque types for the users of jgraphics 00014 #ifdef __cplusplus 00015 struct t_jgraphics; 00016 struct t_jpath; 00017 struct t_jpattern; 00018 struct t_jfont; 00019 struct t_jtextlayout; 00020 struct t_jtransform; 00021 struct t_jsurface; 00022 struct t_jpopupmenu; 00023 struct t_jsvg; 00024 #else 00025 typedef struct _jgraphics t_jgraphics; ///< An instance of a jgraphics drawing context. @ingroup jgraphics 00026 typedef struct _jpath t_jpath; ///< An instance of a jgraphics path. @ingroup jgraphics 00027 typedef struct _jpattern t_jpattern; ///< An instance of a jgraphics pattern. @ingroup jpattern 00028 typedef struct _jfont t_jfont; ///< An instance of a jgraphics font. @ingroup jfont 00029 typedef struct _jtextlayout t_jtextlayout; ///< An instance of a jgraphics text layout object. @ingroup jgraphics 00030 typedef struct _jtransform t_jtransform; ///< An instance of a jgraphics transform. @ingroup jgraphics 00031 typedef struct _jsurface t_jsurface; ///< An instance of a jgraphics surface. @ingroup jsurface 00032 typedef struct _jsvg t_jsvg; ///< An instance of an SVG object. @ingroup jgraphics 00033 typedef struct _jpopupmenu t_jpopupmenu; ///< An instance of a pop-up menu. @ingroup jgraphics 00034 #endif 00035 00036 00037 // pre-defined colors -- internal use only -- not exported from the kernel 00038 00039 extern t_jrgb s_jrgb_white; // White 00040 extern t_jrgb s_jrgb_black; // Black 00041 extern t_jrgb s_jrgb_red; // Red 00042 extern t_jrgb s_jrgb_green; // Green 00043 extern t_jrgb s_jrgb_blue; // Blue 00044 extern t_jrgb s_jrgb_yellow; // Yellow 00045 extern t_jrgb s_jrgb_cyan; // Cyan 00046 extern t_jrgb s_jrgb_magenta; // Magenta 00047 extern t_jrgb s_jrgb_gray; // Gray 00048 extern t_jrgb s_jrgb_boxgray; // Box Gray 00049 00050 /** Determine the coordinate of the bottom of a rect. 00051 @ingroup jgraphics */ 00052 #define JGRAPHICS_RECT_BOTTOM(rect) (((rect)->y)+((rect)->height)) 00053 00054 /** Determine the coordinate of the right side of a rect. 00055 @ingroup jgraphics */ 00056 #define JGRAPHICS_RECT_RIGHT(rect) (((rect)->x)+((rect)->width)) 00057 00058 00059 // misc utilities 00060 00061 /** Utility macro to return the value of Pi. @ingroup jgraphics */ 00062 #define JGRAPHICS_PI (3.1415926535897932384626433832795028842) 00063 00064 /** Utility macro to return the value of twice Pi. @ingroup jgraphics */ 00065 #define JGRAPHICS_2PI (2. * 3.1415926535897932384626433832795028842) 00066 00067 /** Utility macro to return the value of half of Pi. @ingroup jgraphics */ 00068 #define JGRAPHICS_PIOVER2 (0.5 * 3.1415926535897932384626433832795028842) 00069 00070 /** Utility macro to return the 270ยบ Case. @ingroup jgraphics */ 00071 #define JGRAPHICS_3PIOVER2 ((3.0 * JGRAPHICS_PI) / 2.0) 00072 00073 /** Utility for rounding a double to an int. 00074 @ingroup jgraphics 00075 @param d floating-point input. 00076 @return rounded int output. */ 00077 int jgraphics_round(double d); 00078 00079 00080 00081 // surfaces 00082 00083 /** Enumeration of color formats used by jgraphics surfaces. 00084 @ingroup jgraphics */ 00085 typedef enum _jgraphics_format { 00086 JGRAPHICS_FORMAT_ARGB32, ///< Color is represented using 32 bits, 8 bits each for the components, and including an alpha component. 00087 JGRAPHICS_FORMAT_RGB24, ///< Color is represented using 32 bits, 8 bits each for the components. There is no alpha component. 00088 JGRAPHICS_FORMAT_A8 ///< The color is represented only as an 8-bit alpha mask. 00089 // JGRAPHICS_FORMAT_A1 // not supported 00090 } t_jgraphics_format; 00091 00092 00093 /** Enumeration of file formats usable for jgraphics surfaces. 00094 @ingroup jgraphics */ 00095 typedef enum _jgraphics_fileformat { 00096 JGRAPHICS_FILEFORMAT_PNG, ///< Portable Network Graphics (PNG) format 00097 JGRAPHICS_FILEFORMAT_JPEG ///< JPEG format 00098 } t_jgraphics_fileformat; 00099 00100 00101 /** Create an image surface. 00102 Use jgraphics_surface_destroy() to free it when you are done. 00103 @ingroup jsurface 00104 @param format Defines the color format for the new surface. 00105 @param width Defines the width of the new surface. 00106 @param height Defines the height of the new surface. 00107 @return A pointer to the new surface. */ 00108 t_jsurface* jgraphics_image_surface_create(t_jgraphics_format format, int width, int height); 00109 00110 00111 /** Create an image surface, filling it with the contents of a file, and get a reference to the surface. 00112 Use jgraphics_surface_destroy() to release your reference to the surface when you are done. 00113 @ingroup jsurface 00114 @param filename The name of the file. 00115 @param path The path id of the file. 00116 @return A pointer to the new surface. */ 00117 t_jsurface *jgraphics_image_surface_create_referenced(const char *filename, short path); 00118 00119 00120 /** Create an image surface, filling it with the contents of a file. 00121 Use jgraphics_surface_destroy() to free it when you are done. 00122 @ingroup jsurface 00123 @param filename The name of the file. 00124 @param path The path id of the file. 00125 @return A pointer to the new surface. */ 00126 t_jsurface* jgraphics_image_surface_create_from_file(const char *filename, short path); 00127 00128 00129 /** Create an image surface from given pixel data. 00130 Data should point to start of top line of bitmap, stride tells how to get to next line. 00131 For upside down windows bitmaps, data = (pBits-(height-1)*stride) and stride is a negative number. 00132 @ingroup jsurface 00133 @param data The data. For example, an RGBA image loaded in memory. 00134 @param format The format of the data. 00135 @param width The width of the new surface. 00136 @param height The height of the new surface. 00137 @param stride The number of bytes between the start of rows in the dat buffer. 00138 @param freefun If not NULL, freefun will be called when the surface is destroyed 00139 @param freearg This will be passed to freefun if/when freefun is called. 00140 @return A pointer to the new surface. */ 00141 t_jsurface* jgraphics_image_surface_create_for_data(unsigned char *data, t_jgraphics_format format, 00142 int width, int height, int stride, 00143 method freefun, void *freearg); 00144 00145 // Internal Use Only 00146 t_jsurface* jgraphics_image_surface_create_for_data_premult(unsigned char *data, t_jgraphics_format format, 00147 int width, int height, int stride, 00148 method freefun, void *freearg); 00149 00150 /** Create a new surface from file data. 00151 @ingroup jsurface 00152 @param data A pointer to the raw PNG or JPG bits. 00153 @param datalen The number of bytes in data. 00154 @return The new surface. 00155 @see jgraphics_write_image_surface_to_filedata() */ 00156 t_jsurface* jgraphics_image_surface_create_from_filedata(const void *data, unsigned long datalen); 00157 00158 00159 /** Create a new surface from a resource in your external. 00160 @ingroup jsurface 00161 @param moduleRef A pointer to your external's module, 00162 which is passed to your external's main() function when the class is loaded. 00163 @param resname The name of the resource in the external. 00164 @remark The following example shows an example of how this might be used in an external. 00165 @code 00166 static s_my_surface = NULL; 00167 00168 int main(void *moduleRef) 00169 { 00170 // (Do typical class initialization here) 00171 00172 // now create the surface from a resource that we added to the Xcode/VisualStudio project 00173 s_my_surface = jgraphics_image_surface_create_from_resource(moduleRef, "myCoolImage"); 00174 00175 return 0; 00176 } 00177 @endcode */ 00178 t_jsurface* jgraphics_image_surface_create_from_resource(const void* moduleRef, const char *resname); 00179 00180 /** Low-level routine to access an object's resource data. 00181 @ingroup jsurface 00182 @param moduleRef A pointer to your external's module, which is passed to your external's main() function when the class is loaded. 00183 @param resname Base name of the resource data (without an extension) 00184 @param extcount Count of possible extensions (ignored on Windows) 00185 @param exts Array of symbol atoms containing possible filename extensions (ignored on Windows) 00186 @param data Returned resource data assigned to a pointer you supply 00187 @param datasize Size of the data returned 00188 @remark You are responsible for freeing any data returned in the data pointer 00189 @return A Max error code. */ 00190 t_max_err jgraphics_get_resource_data(const void *moduleRef, const char *resname, long extcount, t_atom *exts, void **data, unsigned long *datasize); 00191 00192 /** Create a reference to an existing surface. 00193 Use jgraphics_surface_destroy() to release your reference to the surface when you are done. 00194 @ingroup jsurface 00195 @param s The surface to reference. 00196 @return The new reference to the surface. */ 00197 t_jsurface* jgraphics_surface_reference(t_jsurface *s); 00198 00199 00200 /** Release or free a surface. 00201 @ingroup jsurface 00202 @param s The surface to release. */ 00203 void jgraphics_surface_destroy(t_jsurface *s); 00204 00205 00206 /** Export a PNG file of the contents of a surface. 00207 @ingroup jsurface 00208 @param surface The surface to export. 00209 @param filename Specify the name of the file to create. 00210 @param path Specify the path id for where to create the file. 00211 @param dpi Define the resolution of the image (e.g. 72). 00212 @return A Max error code. */ 00213 t_max_err jgraphics_image_surface_writepng(t_jsurface *surface, const char *filename, short path, long dpi); 00214 00215 00216 // Not used by any C74 code... 00217 void jgraphics_surface_set_device_offset(t_jsurface *s, double x_offset, double y_offset); 00218 void jgraphics_surface_get_device_offset(t_jsurface *s, double *x_offset, double *y_offset); 00219 00220 00221 /** Retrieve the width of a surface. 00222 @ingroup jsurface 00223 @param s The surface to query. 00224 @return The width of the surface. */ 00225 int jgraphics_image_surface_get_width(t_jsurface *s); 00226 00227 /** Retrieve the height of a surface. 00228 @ingroup jsurface 00229 @param s The surface to query. 00230 @return The height of the surface. */ 00231 int jgraphics_image_surface_get_height(t_jsurface *s); 00232 00233 /** Set the color of an individual pixel in a surface. 00234 @ingroup jsurface 00235 @param s The surface. 00236 @param x The horizontal coordinate of the pixel. 00237 @param y The vertical coordinate of the pixel. 00238 @param color The color of the pixel. */ 00239 void jgraphics_image_surface_set_pixel(t_jsurface *s, int x, int y, t_jrgba color); 00240 00241 /** Retrieve the color of an individual pixel in a surface. 00242 @ingroup jsurface 00243 @param s The surface. 00244 @param x The horizontal coordinate of the pixel. 00245 @param y The vertical coordinate of the pixel. 00246 @param color The address of a valid #t_jrgba struct 00247 whose values will be filled in with the color of the pixel upon return. */ 00248 void jgraphics_image_surface_get_pixel(t_jsurface *s, int x, int y, t_jrgba *color); 00249 00250 /** 00251 @ingroup jsurface 00252 @param s The surface to scroll. 00253 @param x The origin of the rect to scroll. 00254 @param y The origin of the rect to scroll. 00255 @param width The width of the rect to scroll. 00256 @param height The height of the rect to scroll. 00257 @param dx The amount to scroll the surface horizontally. 00258 @param dy The amount to scroll the surface vertically. 00259 @param path Can pass NULL if you are not interested in this info. 00260 Otherwise pass a pointer and it will be returned with a path containing the invalid region. 00261 */ 00262 void jgraphics_image_surface_scroll(t_jsurface *s, 00263 int x, int y, int width, int height, 00264 int dx, int dy, 00265 t_jpath **path); // 00266 00267 00268 // The lockpixels methods are for C74 internal use only. Use jgraphics_image_surface_create_for_data(). 00269 00270 /* Get a read-only raw bitmap of a surface. 00271 This gives you a pointer to the raw bitmap data so you can read from it yourself and examine the stuff that was drawn. 00272 The jgraphics_image_surface_lockpixels() version gives you a pointer to the bits that you can directly munge. 00273 After either call you should make the appropriate unlock call. 00274 @ingroup jsurface 00275 @param s The surface. 00276 @param x The rect horizontal-origin for the raw bitmap. 00277 @param y The rect vertical-origin for the raw bitmap. 00278 @param width The rect width for the bitmap. 00279 @param height The rect height for the bitmap. 00280 @param linestride The line stride for the bitmap. 00281 @param pixelstride The pixel stride for the bitmap. 00282 @return A pointer to the raw bitmap. */ 00283 const unsigned char* jgraphics_image_surface_lockpixels_readonly(t_jsurface *s, 00284 int x, int y, int width, int height, 00285 int *linestride, int *pixelstride); 00286 /* Unlock a surface locked by jgraphics_image_surface_lockpixels_readonly(). 00287 @ingroup jsurface 00288 @param s The surface. 00289 @param data The pointer returned by jgraphics_image_surface_lockpixels_readonly(). */ 00290 void jgraphics_image_surface_unlockpixels_readonly(t_jsurface *s, const unsigned char *data); 00291 00292 00293 /* Get a writable bitmap of a surface. 00294 After you are done reading/writing to the bitmap, you should call jgraphics_image_surface_unlockpixels(). 00295 @ingroup jsurface 00296 @param s The surface. 00297 @param x The rect horizontal-origin for the raw bitmap. 00298 @param y The rect vertical-origin for the raw bitmap. 00299 @param width The rect width for the bitmap. 00300 @param height The rect height for the bitmap. 00301 @param linestride The line stride for the bitmap. 00302 @param pixelstride The pixel stride for the bitmap. 00303 @return A pointer to the raw bitmap. */ 00304 unsigned char* jgraphics_image_surface_lockpixels(t_jsurface *s, 00305 int x, int y, int width, int height, 00306 int *linestride, int *pixelstride); 00307 00308 /* Unlock a surface locked by jgraphics_image_surface_lockpixels(). 00309 @ingroup jsurface 00310 @param s The surface. 00311 @param data The pointer returned by jgraphics_image_surface_lockpixels(). */ 00312 void jgraphics_image_surface_unlockpixels(t_jsurface *s, unsigned char *data); 00313 00314 00315 /** Draw an image surface. 00316 This not in cairo, but, it seems silly to have to make a brush to just draw an image. 00317 This doesn't support rotations, however. 00318 @ingroup jsurface 00319 @param g The graphics context in which to draw the surface. 00320 @param s The surface to draw. 00321 @param srcRect The rect within the surface that should be drawn. 00322 @param destRect The rect in the context to which to draw the srcRect. 00323 @see jgraphics_image_surface_draw_fast() */ 00324 void jgraphics_image_surface_draw(t_jgraphics *g, t_jsurface *s, t_rect srcRect, t_rect destRect); 00325 00326 00327 /** Draw an image surface quickly. 00328 The draw_fast version won't scale based on zoom factor or user transforms so make sure that this is what you want! 00329 Draws entire image, origin *can* be shifted via zoom and user transforms 00330 (even though image is not scaled based on those same transforms) 00331 @ingroup jsurface 00332 @param g The graphics context in which to draw the surface. 00333 @param s The surface to draw. 00334 @see jgraphics_image_surface_draw */ 00335 void jgraphics_image_surface_draw_fast(t_jgraphics *g, t_jsurface *s); 00336 00337 00338 /** Get surface data ready for manually writing to a file. 00339 @ingroup jsurface 00340 @param surf The surface whose data will be retrieved. 00341 @param fmt The format for the data. This should be a selection from #t_jgraphics_fileformat. 00342 @param data The address of a pointer that will be allocated and filled. 00343 When you are done with this data you should free it using sysmem_freeptr(). 00344 @param size The address of a variable to hold the size of the data upon return. 00345 00346 @remark A good example of this is to embed the surface as a PNG in a patcher file. 00347 @code 00348 long size = 0; 00349 void *data = NULL; 00350 00351 jgraphics_write_image_surface_to_filedata(x->j_surface, JGRAPHICS_FILEFORMAT_PNG, &data, &size); 00352 if (size) { 00353 x->j_format = gensym("png"); 00354 binarydata_appendtodictionary(data, size, gensym("data"), x->j_format, d); 00355 x->j_imagedata = data; 00356 x->j_imagedatasize = size; 00357 } 00358 @endcode 00359 @see jgraphics_image_surface_create_from_filedata() */ 00360 void jgraphics_write_image_surface_to_filedata(t_jsurface *surf, long fmt, void **data, long *size); 00361 00362 00363 /** Set all pixels in rect to 0. 00364 @ingroup jsurface 00365 @param s The surface to clear. 00366 @param x The horizontal origin of the rect to clear. 00367 @param y The vertical origin of the rect to clear. 00368 @param width The width of the rect to clear. 00369 @param height The height of the rect to clear. */ 00370 void jgraphics_image_surface_clear(t_jsurface *s, int x, int y, int width, int height); 00371 00372 00373 00374 // SVG Stuff 00375 00376 /** Read an SVG file, return a #t_jsvg object. 00377 @ingroup jsvg 00378 @param filename The name of the file to read. 00379 @param path The path id of the file to read. 00380 @return A new SVG object. */ 00381 t_jsvg* jsvg_create_from_file(const char *filename, short path); 00382 00383 00384 /** Read an SVG file from a resource. 00385 @ingroup jsvg 00386 @param moduleRef The external's moduleRef. 00387 @param resname The name of the SVG resource. 00388 @return A new SVG object. 00389 @see jgraphics_image_surface_create_from_resource() */ 00390 t_jsvg* jsvg_create_from_resource(const void *moduleRef, const char *resname); 00391 00392 00393 /** Create an SVG object from a string containing the SVG's XML. 00394 @ingroup jsvg 00395 @param svgXML The SVG source. 00396 @return A new SVG object. */ 00397 t_jsvg* jsvg_create_from_xmlstring(const char *svgXML); 00398 00399 00400 /** Retrieve the size of an SVG object. 00401 @ingroup jsvg 00402 @param svg An SVG object. 00403 @param width The address of a variable that will be set to the width upon return. 00404 @param height The address of a variable that will be set to the width upon return. */ 00405 void jsvg_get_size(t_jsvg *svg, double *width, double *height); 00406 00407 00408 /** Free a #t_jsvg object. 00409 @ingroup jsvg 00410 @param svg The object to free. */ 00411 void jsvg_destroy(t_jsvg *svg); 00412 00413 00414 /** Render an SVG into a graphics context. 00415 @ingroup jsvg 00416 @param svg The SVG object to render. 00417 @param g The graphics context in which to render. */ 00418 void jsvg_render(t_jsvg *svg, t_jgraphics *g); 00419 00420 00421 /** Create a context to draw on a particular surface. 00422 When you are done, call jgraphics_destroy(). 00423 @ingroup jsurface 00424 @param target The surface to which to draw. 00425 @return The new graphics context. */ 00426 t_jgraphics* jgraphics_create(t_jsurface *target); 00427 00428 00429 /** Get a reference to a graphics context. 00430 When you are done you should release your reference with jgraphics_destroy(). 00431 @ingroup jgraphics 00432 @param g The context you wish to reference. 00433 @return A new reference to the context. */ 00434 t_jgraphics* jgraphics_reference(t_jgraphics *g); 00435 00436 00437 /** Release or free a graphics context. 00438 @ingroup jgraphics 00439 @param g The context to release. */ 00440 void jgraphics_destroy(t_jgraphics *g); 00441 00442 00443 00444 // Paths 00445 00446 /** Begin a new path. 00447 This action clears any current path in the context. 00448 @ingroup jgraphics 00449 @param g The graphics context. */ 00450 void jgraphics_new_path(t_jgraphics *g); 00451 00452 00453 /** Get a copy of the current path from a context. 00454 @ingroup jgraphics 00455 @param g A copy of the current path. */ 00456 t_jpath* jgraphics_copy_path(t_jgraphics *g); 00457 00458 00459 /** Release/free a path. 00460 @ingroup jgraphics 00461 @param path The path to release. */ 00462 void jgraphics_path_destroy(t_jpath *path); 00463 00464 00465 /** Add a path to a graphics context. 00466 @ingroup jgraphics 00467 @param g The graphics context. 00468 @param path The path to add. */ 00469 void jgraphics_append_path(t_jgraphics *g, t_jpath *path); 00470 00471 00472 /** Close the current path in a context. 00473 This will add a line segment to close current subpath. 00474 @ingroup jgraphics 00475 @param g The graphics context. */ 00476 void jgraphics_close_path(t_jgraphics *g); 00477 00478 00479 /** Round out any corners in a path. 00480 This action clears any current path in the context. 00481 @ingroup jgraphics 00482 @param g The graphics context. 00483 @param cornerRadius The amount by which to round corners. */ 00484 void jgraphics_path_roundcorners(t_jgraphics *g, double cornerRadius); 00485 00486 00487 /** Get the current location of the cursor in a graphics context. 00488 @ingroup jgraphics 00489 @param g The graphics context. 00490 @param x The address of a variable that will be set to the horizontal cursor location upon return. 00491 @param y The address of a variable that will be set to the vertical cursor location upon return. */ 00492 void jgraphics_get_current_point(t_jgraphics *g, double *x, double *y); 00493 00494 00495 /** Add a circular, clockwise, arc to the current path. 00496 @ingroup jgraphics 00497 @param g The graphics context. 00498 @param xc The horizontal coordinate of the arc's center. 00499 @param yc The vertical coordinate of the arc's center. 00500 @param radius The radius of the arc. 00501 @param angle1 The starting angle of the arc in radians. 00502 Zero radians is center right (positive x axis). 00503 @param angle2 The terminal angle of the arc in radians. 00504 Zero radians is center right (positive x axis). */ 00505 void jgraphics_arc(t_jgraphics *g, 00506 double xc, double yc, 00507 double radius, 00508 double angle1, double angle2); 00509 00510 00511 /** Add a non-circular arc to the current path. 00512 @ingroup jgraphics 00513 @param g The graphics context. 00514 @param xc The horizontal coordinate of the arc's center. 00515 @param yc The vertical coordinate of the arc's center. 00516 @param radiusx The horizontal radius of the arc. 00517 @param radiusy The vertical radius of the arc. 00518 @param angle1 The starting angle of the arc in radians. 00519 Zero radians is center right (positive x axis). 00520 @param angle2 The terminal angle of the arc in radians. 00521 Zero radians is center right (positive x axis). */ 00522 void jgraphics_ovalarc(t_jgraphics *g, 00523 double xc, double yc, 00524 double radiusx, double radiusy, 00525 double angle1, double angle2); 00526 00527 00528 /** Add a circular, counter-clockwise, arc to the current path. 00529 @ingroup jgraphics 00530 @param g The graphics context. 00531 @param xc The horizontal coordinate of the arc's center. 00532 @param yc The vertical coordinate of the arc's center. 00533 @param radius The radius of the arc. 00534 @param angle1 The starting angle of the arc in radians. 00535 Zero radians is center right (positive x axis). 00536 @param angle2 The terminal angle of the arc in radians. 00537 Zero radians is center right (positive x axis). */ 00538 void jgraphics_arc_negative(t_jgraphics *g, 00539 double xc, double yc, 00540 double radius, 00541 double angle1, double angle2); 00542 00543 00544 /** Add a cubic Bezier spline to the current path. 00545 @ingroup jgraphics 00546 @param g The graphics context. 00547 @param x1 The first control point. 00548 @param y1 The first control point. 00549 @param x2 The second control point. 00550 @param y2 The second control point. 00551 @param x3 The destination point. 00552 @param y3 The destination point. */ 00553 void jgraphics_curve_to(t_jgraphics *g, 00554 double x1, double y1, 00555 double x2, double y2, 00556 double x3, double y3); 00557 00558 00559 /** Add a cubic Bezier spline to the current path, using coordinates relative to the current point. 00560 @ingroup jgraphics 00561 @param g The graphics context. 00562 @param x1 The first control point. 00563 @param y1 The first control point. 00564 @param x2 The second control point. 00565 @param y2 The second control point. 00566 @param x3 The destination point. 00567 @param y3 The destination point. */ 00568 void jgraphics_rel_curve_to(t_jgraphics *g, 00569 double x1, double y1, 00570 double x2, double y2, 00571 double x3, double y3); 00572 00573 00574 /** Add a line segment to the current path. 00575 @ingroup jgraphics 00576 @param g The graphics context. 00577 @param x The destination point. 00578 @param y The destination point. */ 00579 void jgraphics_line_to(t_jgraphics *g, double x, double y); 00580 00581 00582 /** Add a line segment to the current path, using coordinates relative to the current point. 00583 @ingroup jgraphics 00584 @param g The graphics context. 00585 @param x The destination point. 00586 @param y The destination point. */ 00587 void jgraphics_rel_line_to(t_jgraphics *g, double x, double y); 00588 00589 00590 /** Move the cursor to a new point and begin a new subpath. 00591 @ingroup jgraphics 00592 @param g The graphics context. 00593 @param x The new location. 00594 @param y The new location. */ 00595 void jgraphics_move_to(t_jgraphics *g, double x, double y); 00596 00597 00598 /** Move the cursor to a new point and begin a new subpath, using coordinates relative to the current point. 00599 @ingroup jgraphics 00600 @param g The graphics context. 00601 @param x The new location. 00602 @param y The new location. */ 00603 void jgraphics_rel_move_to(t_jgraphics *g, double x, double y); 00604 00605 00606 /** Add a closed rectangle path in the context. 00607 @ingroup jgraphics 00608 @param g The graphics context. 00609 @param x The horizontal origin. 00610 @param y The vertical origin. 00611 @param width The width of the rect. 00612 @param height The height of the rect. */ 00613 void jgraphics_rectangle(t_jgraphics *g, 00614 double x, double y, 00615 double width, double height); 00616 00617 00618 /** Deprecated -- do not use. Adds a closed oval path in the context, however, it does not scale appropriately. 00619 @ingroup jgraphics 00620 @param g The graphics context. 00621 @param x The horizontal origin. 00622 @param y The vertical origin. 00623 @param width The width of the oval. 00624 @param height The height of the oval. */ 00625 void jgraphics_oval(t_jgraphics *g, 00626 double x, double y, 00627 double width, double height); 00628 00629 00630 /** Add a closed rounded-rectangle path in the context. 00631 @ingroup jgraphics 00632 @param g The graphics context. 00633 @param x The horizontal origin. 00634 @param y The vertical origin. 00635 @param width The width of the rect. 00636 @param height The height of the rect. 00637 @param ovalwidth The width of the oval used for the round corners. 00638 @param ovalheight The height of the oval used for the round corners. */ 00639 void jgraphics_rectangle_rounded(t_jgraphics *g, 00640 double x, double y, 00641 double width, double height, 00642 double ovalwidth, double ovalheight); 00643 00644 00645 /** Add a closed elliptical path in the context. 00646 @ingroup jgraphics 00647 @param g The graphics context. 00648 @param x The horizontal origin. 00649 @param y The vertical origin. 00650 @param width The width of the rect. 00651 @param height The height of the rect. */ 00652 void jgraphics_ellipse(t_jgraphics *g, 00653 double x, double y, 00654 double width, double height); 00655 00656 00657 // Internal use only 00658 void jgraphics_diagonal_line_fill(t_jgraphics *g, double pixels, double x, double y, double width, double height); 00659 00660 00661 // need to add glyph stuff and stuff for adding glyphs to a path. 00662 00663 /** Enumeration of slanting options for font display. 00664 @ingroup jfont */ 00665 typedef enum _jgraphics_font_slant { 00666 JGRAPHICS_FONT_SLANT_NORMAL, ///< Normal slanting (typically this means no slanting) 00667 JGRAPHICS_FONT_SLANT_ITALIC ///< Italic slanting 00668 // JGRAPHICS_FONT_SLANT_OBLIQUE 00669 } t_jgraphics_font_slant; 00670 00671 00672 /** Enumeration of font weight options for font display. 00673 @ingroup jfont */ 00674 typedef enum _jgraphics_font_weight { 00675 JGRAPHICS_FONT_WEIGHT_NORMAL, ///< Normal font weight 00676 JGRAPHICS_FONT_WEIGHT_BOLD ///< Bold font weight 00677 } t_jgraphics_font_weight; 00678 00679 00680 /** Specify a font for a graphics context. 00681 @ingroup jgraphics 00682 @param g The graphics context. 00683 @param family The name of the font family (e.g. "Arial"). 00684 @param slant Define the slant to use for the font. 00685 @param weight Define the weight to use for the font. */ 00686 void jgraphics_select_font_face(t_jgraphics *g, 00687 const char *family, 00688 t_jgraphics_font_slant slant, 00689 t_jgraphics_font_weight weight); 00690 00691 00692 /** Specify a font for a graphics context by passing a #t_jfont object. 00693 @ingroup jgraphics 00694 @param g The graphics context. 00695 @param jfont A jfont object whose attributes will be copied to the context. */ 00696 void jgraphics_select_jfont(t_jgraphics *g, t_jfont *jfont); 00697 00698 00699 /** Specify the font size for a context. 00700 @ingroup jgraphics 00701 @param g The graphics context. 00702 @param size The font size. */ 00703 void jgraphics_set_font_size(t_jgraphics *g, double size); 00704 00705 00706 /** Turn underlining on/off for text in a context. 00707 @ingroup jgraphics 00708 @param g The graphics context. 00709 @param underline Pass true or false to set the appropriate behavior. */ 00710 void jgraphics_set_underline(t_jgraphics *g, char underline); 00711 00712 00713 /** Display text at the current position in a context. 00714 @ingroup jgraphics 00715 @param g The graphics context. 00716 @param utf8 The text to display. */ 00717 void jgraphics_show_text(t_jgraphics *g, const char *utf8); 00718 00719 00720 /** A structure for holding information related to how much space the rendering of a given font will use. 00721 The units for these measurements is in pixels. 00722 @ingroup jgraphics 00723 */ 00724 typedef struct _jgraphics_font_extents { 00725 double ascent; ///< The ascent. 00726 double descent; ///< The descent. 00727 double height; ///< The hieght. 00728 double max_x_advance; ///< Unused / Not valid. 00729 double max_y_advance; ///< Unused / Not valid. 00730 } t_jgraphics_font_extents; 00731 00732 00733 /** Return the extents of the currently selected font for a given graphics context. 00734 @ingroup jgraphics 00735 @param g Pointer to a jgraphics context. 00736 @param extents The address of a #t_jgraphics_font_extents structure to be filled with the results. 00737 */ 00738 void jgraphics_font_extents(t_jgraphics *g, t_jgraphics_font_extents *extents); 00739 00740 00741 /** Return the height and width of a string given current graphics settings in a context. 00742 @ingroup jgraphics 00743 @param g Pointer to a jgraphics context. 00744 @param utf8 A string containing the text whose dimensions we wish to find. 00745 @param width The address of a variable to be filled with the width of the rendered text. 00746 @param height The address of a variable to be filled with the height of the rendered text. 00747 */ 00748 void jgraphics_text_measure(t_jgraphics *g, const char *utf8, double *width, double *height); 00749 00750 00751 /** Return the height, width, and number of lines that will be used to render a given string. 00752 @ingroup jgraphics 00753 @param g Pointer to a jgraphics context. 00754 @param utf8 A string containing the text whose dimensions we wish to find. 00755 @param wrapwidth The number of pixels in width at which the text should be wrapped if it is too long. 00756 @param includewhitespace Set zero to not include white space in the calculation, otherwise set this parameter to 1. 00757 @param width The address of a variable to be filled with the width of the rendered text. 00758 @param height The address of a variable to be filled with the height of the rendered text. 00759 @param numlines The address of a variable to be filled with the number of lines required to render the text. 00760 */ 00761 void jgraphics_text_measure_wrapped(t_jgraphics *g, const char *utf8, double wrapwidth, long includewhitespace, 00762 double *width, double *height, long *numlines); 00763 00764 00765 // Internal Use Only 00766 double jgraphics_getfontscale(void); 00767 00768 00769 00770 // Working with fonts directly 00771 00772 // Internal Use Only 00773 t_jfont* jfont_create_from_maxfont(short number, short size); 00774 00775 00776 /** Create a new font object. 00777 @ingroup jfont 00778 @param family The name of the font family (e.g. Arial). 00779 @param slant The type of slant for the font. 00780 @param weight The type of weight for the font. 00781 @param size The size of the font. 00782 @return The new font object. */ 00783 t_jfont* jfont_create(const char *family, 00784 t_jgraphics_font_slant slant, 00785 t_jgraphics_font_weight weight, 00786 double size); 00787 00788 00789 /** Create new reference to an existing font object. 00790 @ingroup jfont 00791 @param font The font object for which to obtain a reference. 00792 @return The new font object reference. */ 00793 t_jfont* jfont_reference(t_jfont *font); 00794 00795 00796 /** Release or free a font object. 00797 @ingroup jfont 00798 @param font The font object to release. */ 00799 void jfont_destroy(t_jfont *font); 00800 00801 00802 /** Set the size of a font object. 00803 @ingroup jfont 00804 @param font The font object. 00805 @param size The new size for the font object. */ 00806 void jfont_set_font_size(t_jfont *font, double size); 00807 00808 00809 /** Set the underlining of a font object. 00810 @ingroup jfont 00811 @param font The font object. 00812 @param ul Pass true to underline, or false for no underlining. */ 00813 void jfont_set_underline(t_jfont *font, char ul); 00814 00815 00816 double jfont_get_heighttocharheightratio(t_jfont *font); 00817 00818 00819 /** Get extents of this font 00820 @ingroup jfont 00821 @param font The font object. 00822 @param extents The font extents upon return/ */ 00823 void jfont_extents(t_jfont *font, t_jgraphics_font_extents *extents); 00824 00825 00826 /** Given a font, find out how much area is required to render a string of text. 00827 @ingroup jfont 00828 @param font The font object. 00829 @param utf8 The text whose rendering will be measured. 00830 @param width The address of a variable to hold the width upon return. 00831 @param height The address of a variable to hold the height upon return. */ 00832 void jfont_text_measure(t_jfont *font, const char *utf8, double *width, double *height); 00833 00834 00835 /** Given a font, find out how much area is required to render a string of text, 00836 provided a horizontal maximum limit at which the text is wrapped. 00837 @ingroup jfont 00838 @param font The font object. 00839 @param utf8 The text whose rendering will be measured. 00840 @param wrapwidth The maximum width, above which text should wrap onto a new line. 00841 @param includewhitespace If non-zero, include whitespace in the measurement. 00842 @param width The address of a variable to hold the width upon return. 00843 @param height The address of a variable to hold the height upon return. 00844 @param numlines The address of a variable to hold the number of lines of text after wrapping upon return. */ 00845 void jfont_text_measure_wrapped(t_jfont *font, const char *utf8, double wrapwidth, long includewhitespace, 00846 double *width, double *height, long *numlines); 00847 00848 /** Get a list of font names. 00849 @ingroup jfont 00850 @param count The addres of a variable to hold the count of font names in list upon return. 00851 @param list The address of a #t_symbol** initialized to NULL. 00852 Upon return this will be set to an array of count #t_symbol pointers. 00853 This array should be freed using sysmem_freeptr() when you are done with it. 00854 @return A Max error code. */ 00855 t_max_err jfont_getfontlist(long *count, t_symbol ***list); 00856 00857 00858 // Internal Use Only -- not exported 00859 void jfont_set_juce_default_fontname(char *s); 00860 void jfont_copy_juce_default_fontname(char *s, long maxlen); 00861 void jfont_copy_juce_platform_fontname(char *s, long maxlen); 00862 void jfont_set_juce_fallback_fontname(char *s); 00863 void jfont_copy_juce_fallback_fontname(char *s, long maxlen); 00864 00865 00866 /** Determine if you can anti-alias text to a transparent background. 00867 You might want to call this and then disable "useimagebuffer" if false *and* 00868 you are rendering text on a transparent background. 00869 @ingroup jgraphics 00870 @return Non-zero if you can anti-alias text to a transparent background. */ 00871 long jgraphics_system_canantialiastexttotransparentbg(); 00872 00873 00874 long jgraphics_fontname_hasglyph(char *name, long code); 00875 00876 00877 /** Create a new textlayout object. 00878 @ingroup textlayout 00879 @return The new textlayout object. */ 00880 t_jtextlayout* jtextlayout_create(); 00881 00882 00883 /** Create a new textlayout object. 00884 This gives a hint to the textlayout as to what the text bgcolor will be. 00885 It won't actually paint the bg for you. 00886 But, it does let it do a better job. 00887 @ingroup textlayout 00888 @param g The graphics context for the textlayout. 00889 @param bgcolor The background color for the textlayout. 00890 @return The new textlayout object. */ 00891 t_jtextlayout* jtextlayout_withbgcolor(t_jgraphics *g, t_jrgba *bgcolor); 00892 00893 00894 /** Release/free a textlayout object. 00895 @ingroup textlayout 00896 @param textlayout The textlayout object to release. */ 00897 void jtextlayout_destroy(t_jtextlayout* textlayout); 00898 00899 00900 /** Enumeration of text justification options, which are specified as a bitmask. 00901 @ingroup jgraphics */ 00902 typedef enum _jgraphics_text_justification { 00903 JGRAPHICS_TEXT_JUSTIFICATION_LEFT = 1, ///< Justify left 00904 JGRAPHICS_TEXT_JUSTIFICATION_RIGHT = 2, ///< Justify right 00905 JGRAPHICS_TEXT_JUSTIFICATION_HCENTERED = 4, ///< Centered horizontally 00906 JGRAPHICS_TEXT_JUSTIFICATION_TOP = 8, ///< Justified to the top 00907 JGRAPHICS_TEXT_JUSTIFICATION_BOTTOM = 16, ///< Justified to the bottom 00908 JGRAPHICS_TEXT_JUSTIFICATION_VCENTERED = 32, ///< Centered vertically 00909 JGRAPHICS_TEXT_JUSTIFICATION_HJUSTIFIED = 64, ///< Horizontally justified 00910 JGRAPHICS_TEXT_JUSTIFICATION_CENTERED = JGRAPHICS_TEXT_JUSTIFICATION_HCENTERED + JGRAPHICS_TEXT_JUSTIFICATION_VCENTERED ///< Shortcut for Centering both vertically and horizontally 00911 } t_jgraphics_text_justification; 00912 00913 00914 /** Flags for setting text layout options. 00915 @ingroup textlayout */ 00916 typedef enum _jgraphics_textlayout_flags { 00917 JGRAPHICS_TEXTLAYOUT_NOWRAP = 1, ///< disable word wrapping 00918 JGRAPHICS_TEXTLAYOUT_USEELLIPSIS = 3 ///< show ... if a line doesn't fit (implies NOWRAP too) 00919 } t_jgraphics_textlayout_flags; 00920 00921 00922 /** Set the text and attributes of a textlayout object. 00923 @ingroup textlayout 00924 @param textlayout The textlayout object. 00925 @param utf8 The text to render. 00926 @param jfont The font with which to render the text. 00927 @param x The text is placed within rect specified by x, y, width, height. 00928 @param y The text is placed within rect specified by x, y, width, height. 00929 @param width The text is placed within rect specified by x, y, width, height. 00930 @param height The text is placed within rect specified by x, y, width, height. 00931 @param justification How to justify the text within the rect. 00932 @param flags Additional flags to control behaviour. */ 00933 void jtextlayout_set(t_jtextlayout *textlayout, 00934 const char *utf8, 00935 t_jfont *jfont, 00936 double x, double y, 00937 double width, 00938 double height, 00939 t_jgraphics_text_justification justification, 00940 t_jgraphics_textlayout_flags flags); 00941 00942 00943 /** Set the color to render text in a textlayout object. 00944 @ingroup textlayout 00945 @param textlayout The textlayout object for which to set the color. 00946 @param textcolor The color for the text. */ 00947 void jtextlayout_settextcolor(t_jtextlayout *textlayout, t_jrgba *textcolor); 00948 00949 00950 /** Return a measurement of how much space will be required to draw the text of a textlayout. 00951 @ingroup textlayout 00952 @param textlayout The textlayout object to query. 00953 @param startindex You can measure a subset of the characters. 00954 This defines the character from which to start. 00955 @param numchars Pass -1 for all characters from startindex to end 00956 @param includewhitespace Define whether to measure with or without whitespace truncated from edges. 00957 @param width Returns the width of text not including any margins. 00958 @param height Returns the height of text not including any margins. 00959 @param numlines Returns the number of lines of text. */ 00960 void jtextlayout_measure(t_jtextlayout *textlayout, 00961 long startindex, 00962 long numchars, 00963 long includewhitespace, 00964 double *width, double *height, 00965 long *numlines); 00966 00967 00968 /** Draw a textlayout in a given graphics context. 00969 @ingroup textlayout 00970 @param tl The textlayout object to query. 00971 @param g The graphics context in which to draw the text. */ 00972 void jtextlayout_draw(t_jtextlayout *tl, t_jgraphics *g); 00973 00974 00975 /** Retrieve a count of the number of characters in a textlayout object. 00976 @ingroup textlayout 00977 @param tl The textlayout object to query. 00978 @return The number of characters. */ 00979 long jtextlayout_getnumchars(t_jtextlayout *tl); 00980 00981 00982 /** Retrieve the #t_rect containing a character at a given index. 00983 @ingroup textlayout 00984 @param tl The textlayout object to query. 00985 @param index The index from which to fetch the unicode character. 00986 @param rect The address of a valid #t_rect which will be filled in upon return. 00987 @return A Max error code. */ 00988 t_max_err jtextlayout_getcharbox(t_jtextlayout *tl, long index, t_rect *rect); 00989 00990 00991 /** Retrieve the unicode character at a given index. 00992 @ingroup textlayout 00993 @param tl The textlayout object to query. 00994 @param index The index from which to fetch the unicode character. 00995 @param pch The address of a variable to hold the unicode character value upon return. 00996 @return A Max error code. */ 00997 t_max_err jtextlayout_getchar(t_jtextlayout *tl, long index, long *pch); 00998 00999 01000 01001 01002 /** An affine transformation (such as scale, shear, etc). 01003 @ingroup jmatrix */ 01004 typedef struct { 01005 double xx; ///< xx component 01006 double yx; ///< yx component 01007 double xy; ///< xy component 01008 double yy; ///< yy component 01009 double x0; ///< x translation 01010 double y0; ///< y translation 01011 } t_jmatrix; 01012 01013 /** Set a #t_jmatrix to an affine transformation. 01014 @ingroup jmatrix 01015 @param x 01016 @param xx 01017 @param yx 01018 @param xy 01019 @param yy 01020 @param x0 01021 @param y0 01022 @remark given x,y the matrix specifies the following transformation: 01023 @code 01024 xnew = xx * x + xy * y + x0; 01025 ynew = yx * x + yy * y + y0; 01026 @endcode 01027 */ 01028 void jgraphics_matrix_init(t_jmatrix *x, double xx, double yx, double xy, double yy, double x0, double y0); 01029 01030 /** Modify a matrix to be an identity transform. 01031 @ingroup jmatrix 01032 @param x The #t_jmatrix. 01033 */ 01034 void jgraphics_matrix_init_identity(t_jmatrix *x); 01035 01036 /** Initialize a #t_jmatrix to translate (offset) a point. 01037 @ingroup jmatrix 01038 @param x The #t_jmatrix. 01039 @param tx The amount of x-axis translation. 01040 @param ty The amount of y-axis translation. 01041 */ 01042 void jgraphics_matrix_init_translate(t_jmatrix *x, double tx, double ty); 01043 01044 /** Initialize a #t_jmatrix to scale (offset) a point. 01045 @ingroup jmatrix 01046 @param x The #t_jmatrix. 01047 @param sx The horizontal scale factor. 01048 @param sy The vertical scale factor. 01049 */ 01050 void jgraphics_matrix_init_scale(t_jmatrix *x, double sx, double sy); 01051 01052 /**Initialize a #t_jmatrix to rotate (offset) a point. 01053 @ingroup jmatrix 01054 @param x The #t_jmatrix. 01055 @param radians The angle or rotation in radians. 01056 */ 01057 void jgraphics_matrix_init_rotate(t_jmatrix *x, double radians); 01058 01059 01060 /** Apply a translation to an existing matrix. 01061 @ingroup jmatrix 01062 @param x The #t_jmatrix. 01063 @param tx The amount of x-axis translation. 01064 @param ty The amount of y-axis translation. 01065 */ 01066 void jgraphics_matrix_translate(t_jmatrix *x, double tx, double ty); 01067 01068 /** Apply a scaling to an existing matrix. 01069 @ingroup jmatrix 01070 @param x The #t_jmatrix. 01071 @param sx The horizontal scale factor. 01072 @param sy The vertical scale factor. 01073 */ 01074 void jgraphics_matrix_scale(t_jmatrix *x, double sx, double sy); 01075 01076 /** Apply a rotation to an existing matrix. 01077 @ingroup jmatrix 01078 @param x The #t_jmatrix. 01079 @param radians The angle or rotation in radians. 01080 */ 01081 void jgraphics_matrix_rotate(t_jmatrix *x, double radians); 01082 01083 /** Invert an existing matrix. 01084 @ingroup jmatrix 01085 @param x The #t_jmatrix. 01086 */ 01087 void jgraphics_matrix_invert(t_jmatrix *x); 01088 01089 /** Multiply two matrices: resulting matrix has effect of first applying a and then applying b. 01090 @ingroup jmatrix 01091 @param result The resulting product #t_jmatrix. 01092 @param a The first operand. 01093 @param b The second operand. 01094 */ 01095 void jgraphics_matrix_multiply(t_jmatrix *result, const t_jmatrix *a, const t_jmatrix *b); 01096 01097 01098 /** Transform a point using a #t_jmatrix transormation. 01099 @ingroup jmatrix 01100 @param matrix The #t_jmatrix. 01101 @param x The address of the variable holding the x coordinate. 01102 @param y The address of the variable holding the y coordinate. 01103 */ 01104 void jgraphics_matrix_transform_point(const t_jmatrix *matrix, double *x, double *y); 01105 01106 01107 01108 01109 // Patterns 01110 t_jpattern* jgraphics_pattern_create_rgba(double red, 01111 double green, // colors between 0 and 1 01112 double blue, 01113 double alpha); // solid, set alpha to 1.0 01114 01115 t_jpattern* jgraphics_pattern_create_for_surface(t_jsurface *surface); 01116 01117 t_jpattern* jgraphics_pattern_create_linear(double x0, double y0, double x1, double y1); 01118 01119 /* 01120 cx0 : x coordinate for the center of the start circle 01121 cy0 : y coordinate for the center of the start circle 01122 radius0 : radius of the start circle 01123 cx1 : x coordinate for the center of the end circle 01124 cy1 : y coordinate for the center of the end circle 01125 radius1 : radius of the end circle 01126 */ 01127 t_jpattern* jgraphics_pattern_create_radial(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1); 01128 01129 void jgraphics_pattern_add_color_stop_rgba(t_jpattern* pattern, double offset, double red, double green, double blue, double alpha); 01130 01131 t_jpattern *jgraphics_pattern_reference(t_jpattern *pattern); 01132 void jgraphics_pattern_destroy(t_jpattern *pattern); 01133 01134 typedef enum _jgraphics_pattern_type { 01135 JGRAPHICS_PATTERN_TYPE_SOLID, 01136 JGRAPHICS_PATTERN_TYPE_SURFACE, 01137 JGRAPHICS_PATTERN_TYPE_LINEAR, 01138 JGRAPHICS_PATTERN_TYPE_RADIAL 01139 } t_jgraphics_pattern_type; 01140 01141 t_jgraphics_pattern_type jgraphics_pattern_get_type(t_jpattern *pattern); 01142 01143 typedef enum _jgraphics_extend { 01144 JGRAPHICS_EXTEND_NONE, 01145 JGRAPHICS_EXTEND_REPEAT, 01146 JGRAPHICS_EXTEND_REFLECT, 01147 JGRAPHICS_EXTEND_PAD 01148 } t_jgraphics_extend; 01149 01150 // rbs -- JGRAPHICS_EXTEND_NONE for images isn't actually supported yet 01151 #define JGRAPHICS_EXTEND_GRADIENT_DEFAULT JGRAPHICS_EXTEND_PAD 01152 #define JGRAPHICS_EXTEND_SURFACE_DEFAULT JGRAPHICS_EXTEND_NONE 01153 01154 // These functions are placeholders for Cairo functionality, but for which there is no direct JUCE implementation. 01155 // They may or may not be implemented in the future. 01156 void jgraphics_pattern_set_extend(t_jpattern *pattern, t_jgraphics_extend extend); 01157 t_jgraphics_extend jgraphics_pattern_get_extend(t_jpattern *pattern); 01158 01159 void jgraphics_pattern_set_matrix(t_jpattern *pattern, const t_jmatrix *matrix); 01160 void jgraphics_pattern_get_matrix(t_jpattern *pattern, t_jmatrix *matrix); 01161 01162 // Transforms 01163 void jgraphics_translate(t_jgraphics *g, double tx, double ty); 01164 void jgraphics_scale(t_jgraphics *g, double sx, double sy); 01165 void jgraphics_rotate(t_jgraphics *g, double angle); 01166 void jgraphics_transform(t_jgraphics *g, const t_jmatrix *matrix); 01167 void jgraphics_set_matrix(t_jgraphics *g, const t_jmatrix *matrix); 01168 void jgraphics_get_matrix(t_jgraphics *g, t_jmatrix *matrix); 01169 void jgraphics_identity_matrix(t_jgraphics *g); 01170 01171 01172 /** User coordinates are those passed to drawing functions in a given #t_jgraphics context. 01173 Device coordinates refer to patcher canvas coordinates, before any zooming. 01174 @ingroup jgraphics */ 01175 void jgraphics_user_to_device(t_jgraphics *g, 01176 double *x, 01177 double *y); 01178 01179 /** User coordinates are those passed to drawing functions in a given #t_jgraphics context. 01180 Device coordinates refer to patcher canvas coordinates, before any zooming. 01181 @ingroup jgraphics */ 01182 void jgraphics_device_to_user(t_jgraphics *g, 01183 double *x, 01184 double *y); 01185 01186 // Graphics 01187 01188 void jgraphics_save(t_jgraphics* g); // doesn't save/restore the path 01189 void jgraphics_restore(t_jgraphics *g); 01190 01191 t_jsurface* jgraphics_get_target(t_jgraphics *g); 01192 01193 01194 // Pushing and Popping groups is not currently exported or supported by Max. 01195 void jgraphics_push_group(t_jgraphics *g); 01196 t_jpattern* jgraphics_pop_group(t_jgraphics *g); 01197 void jgraphics_pop_group_to_source(t_jgraphics *g); 01198 t_jsurface* jgraphics_get_group_target(t_jgraphics *g); 01199 // jgraphics_pop_group_surface is not in cairo, but equivalent to the following sequence 01200 // jgraphics_get_group_target(), jgraphics_surface_reference(), jgraphics_restore() 01201 t_jsurface* jgraphics_pop_group_surface(t_jgraphics *g); 01202 01203 01204 // if a t_jpattern source was previously selected, it is removed 01205 void jgraphics_set_source_rgba(t_jgraphics *g, 01206 double red, 01207 double green, 01208 double blue, 01209 double alpha); 01210 01211 void jgraphics_set_source_jrgba(t_jgraphics *g, t_jrgba *rgba); 01212 01213 void jgraphics_set_source_rgb(t_jgraphics *g, 01214 double red, 01215 double green, 01216 double blue); 01217 // if NULL source is passed in will revert to prior solid color. 01218 void jgraphics_set_source(t_jgraphics *g, t_jpattern *source); 01219 01220 // convenience function for creating pattern from surface and making it the source for g 01221 void jgraphics_set_source_surface(t_jgraphics *g, 01222 t_jsurface *surface, 01223 double x, double y); 01224 01225 01226 typedef enum _jgraphics_pattern_shared { 01227 JGRAPHICS_PATTERN_GRAY = 0, 01228 JGRAPHICS_NUM_SHARED_PATTERNS 01229 } t_jgraphics_pattern_shared; 01230 01231 01232 // We create some standard patterns which are "owned" by the jgraphics library. 01233 // You can use these as a source for filling or stroking paths. 01234 // The gray patter above is what is used to put dotted lines around the comment box, and others. 01235 void jgraphics_set_source_shared(t_jgraphics *g, t_jgraphics_pattern_shared patindex); 01236 01237 // color transforms 01238 // each component (rgba) has a scale and offset value as part of the graphics context. 01239 // this is saved and restored with the jgraphics_save and jgraphics_restore calls. 01240 01241 void jgraphics_scale_source_rgba(t_jgraphics *g, 01242 double redscale, 01243 double greenscale, 01244 double bluescale, 01245 double alphascale); 01246 01247 void jgraphics_translate_source_rgba(t_jgraphics *g, 01248 double redoffset, 01249 double greenoffset, 01250 double blueoffset, 01251 double alphaoffset); 01252 01253 // example use of this function is in the gswitch object 01254 void jgraphics_set_dash(t_jgraphics *g, 01255 double *dashes, 01256 int numdashes, 01257 double offset); // offset not supported yet 01258 01259 01260 typedef enum _jgraphics_fill_rule { 01261 JGRAPHICS_FILL_RULE_WINDING, 01262 JGRAPHICS_FILL_RULE_EVEN_ODD 01263 } t_jgraphics_fill_rule; 01264 01265 void jgraphics_set_fill_rule(t_jgraphics *g, t_jgraphics_fill_rule fill_rule); 01266 t_jgraphics_fill_rule jgraphics_get_fill_rule(t_jgraphics *g); 01267 01268 01269 typedef enum _jgraphics_line_cap { 01270 JGRAPHICS_LINE_CAP_BUTT, 01271 JGRAPHICS_LINE_CAP_ROUND, 01272 JGRAPHICS_LINE_CAP_SQUARE 01273 } t_jgraphics_line_cap; 01274 01275 void jgraphics_set_line_cap(t_jgraphics *g, t_jgraphics_line_cap line_cap); 01276 t_jgraphics_line_cap jgraphics_get_line_cap(t_jgraphics *g); 01277 01278 01279 typedef enum _jgraphics_line_join { 01280 JGRAPHICS_LINE_JOIN_MITER, 01281 JGRAPHICS_LINE_JOIN_ROUND, 01282 JGRAPHICS_LINE_JOIN_BEVEL 01283 } t_jgraphics_line_join; 01284 01285 01286 void jgraphics_set_line_join(t_jgraphics *g, 01287 t_jgraphics_line_join line_join); 01288 t_jgraphics_line_join jgraphics_get_line_join(t_jgraphics *g); 01289 01290 void jgraphics_set_line_width(t_jgraphics *g, 01291 double width); 01292 double jgraphics_get_line_width(t_jgraphics *g); 01293 01294 // perhaps someday we could expose something like this 01295 // jgraphics_set_operator() 01296 01297 void jgraphics_fill(t_jgraphics *g); 01298 void jgraphics_fill_preserve(t_jgraphics *g); 01299 01300 // Note: you can use jgraphics_image_surface_create with a 1x1 offscreen to do path stuff 01301 // that isn't actually going to be used for drawing. 01302 int jgraphics_in_fill(t_jgraphics *g, double x, double y); // hit test 01303 int jgraphics_path_intersects_line(t_jgraphics *g, double x1, double y1, double x2, double y2); // not in cairo 01304 01305 // various utilities 01306 int jgraphics_ptinrect(t_pt pt, t_rect rect); 01307 01308 /* 01309 Note that the functions jgraphics_rectangle_rounded() and jgraphics_ptinroundedrect() 01310 need different size arguments as ovalsize and ovalwidth. 01311 */ 01312 int jgraphics_ptinroundedrect(t_pt pt, t_rect rect, double ovalwidth, double ovalheight); 01313 01314 // get extents of current path in device coordinates (after transform matrix) 01315 void jgraphics_fill_extents(t_jgraphics *g, 01316 double *x1, double *y1, 01317 double *x2, double *y2); 01318 01319 // paints current source using alpha of pattern 01320 //void jgraphics_mask(t_jgraphics *x, 01321 // t_jpattern *pattern); 01322 01323 // paints current source using alpha of surface 01324 //void jgraphics_mask_surface(t_jgraphics *g, 01325 // t_jsurface *surface, 01326 // double surface_x, // surface origin 01327 // double surface_y); // surface origin 01328 01329 // paint current source in entire current clip region 01330 void jgraphics_paint(t_jgraphics *g); 01331 void jgraphics_paint_with_alpha(t_jgraphics *g, 01332 double alpha); 01333 01334 void jgraphics_stroke(t_jgraphics *g); 01335 void jgraphics_stroke_preserve(t_jgraphics *g); 01336 01337 // fast non antialiasing/rotating versions 01338 void jgraphics_rectangle_fill_fast(t_jgraphics *g, double x, double y, double width, double height); 01339 void jgraphics_rectangle_draw_fast(t_jgraphics *g, double x, double y, double width, double height, double border); 01340 void jgraphics_line_draw_fast(t_jgraphics *g, double x1, double y1, double x2, double y2, double linewidth); 01341 01342 01343 01344 01345 // popup menu API so externals can create popup menus that can also be drawn into 01346 01347 /** Create a pop-up menu. 01348 Free this pop-up menu using jpopupmenu_destroy(). 01349 @ingroup jpopupmenu 01350 @return A pointer to the newly created jpopupmenu object. */ 01351 t_jpopupmenu* jpopupmenu_create(); 01352 01353 /** Free a pop-up menu created with jpopupmenu_create(). 01354 @ingroup jpopupmenu 01355 @param menu The pop-up menu to be freed. */ 01356 void jpopupmenu_destroy(t_jpopupmenu *menu); 01357 01358 /** Clear the conents of a pop-up menu. 01359 @ingroup jpopupmenu 01360 @param menu The pop-up menu whose contents will be cleared. */ 01361 void jpopupmenu_clear(t_jpopupmenu *menu); 01362 01363 // Internal use only 01364 void jpopupmenu_setitemcallback(method fun, void *arg); 01365 01366 /** Set the colors used by a pop-up menu. 01367 @ingroup jpopupmenu 01368 @param menu The pop-up menu to which the colors will be applied. 01369 @param text The text color for menu items. 01370 @param bg The background color for menu items. 01371 @param highlightedtext The text color for the highlighted menu item. 01372 @param highlightedbg The background color the highlighted menu item. */ 01373 void jpopupmenu_setcolors(t_jpopupmenu *menu, 01374 t_jrgba text, 01375 t_jrgba bg, 01376 t_jrgba highlightedtext, 01377 t_jrgba highlightedbg); 01378 01379 // Internal use only (header functions are not exported) 01380 void jpopupmenu_setheadercolor(t_jpopupmenu *menu, t_jrgba *hc); 01381 01382 /** Set the font used by a pop-up menu. 01383 @ingroup jpopupmenu 01384 @param menu The pop-up menu whose font will be set. 01385 @param font A pointer to a font object, whose font info will be copied to the pop-up menu. */ 01386 void jpopupmenu_setfont(t_jpopupmenu *menu, t_jfont *font); 01387 01388 /** Add an item to a pop-up menu. 01389 @ingroup jpopupmenu 01390 @param menu The pop-up menu to which the item will be added. 01391 @param itemid Each menu item should be assigned a unique integer id using this parameter. 01392 @param utf8Text The text to display in for the menu item. 01393 @param textColor The color to use for the menu item, or NULL to use the default color. 01394 @param checked A non-zero value indicates that the item should have a check-mark next to it. 01395 @param disabled A non-zero value indicates that the item should be disabled. 01396 @param icon A #t_jsurface will be used as an icon for the menu item if provided here. 01397 Pass NULL for no icon. */ 01398 void jpopupmenu_additem(t_jpopupmenu *menu, 01399 int itemid, 01400 const char *utf8Text, 01401 t_jrgba *textColor, 01402 int checked, 01403 int disabled, 01404 t_jsurface *icon); 01405 01406 /** Add a pop-menu to another pop-menu as a submenu. 01407 @ingroup jpopupmenu 01408 @param menu The pop-up menu to which a menu will be added as a submenu. 01409 @param utf8Name The name of the menu item. 01410 @param submenu The pop-up menu which will be used as the submenu. 01411 @param disabled Pass a non-zero value to disable the menu item. */ 01412 void jpopupmenu_addsubmenu(t_jpopupmenu *menu, 01413 const char *utf8Name, 01414 t_jpopupmenu *submenu, 01415 int disabled); 01416 01417 /** Add a separator to a pop-menu. 01418 @ingroup jpopupmenu 01419 @param menu The pop-up menu to which the separator will be added. */ 01420 void jpopupmenu_addseperator(t_jpopupmenu *menu); 01421 01422 // Internal use only (header functions are not exported) 01423 void jpopupmenu_addheader(t_jpopupmenu *menu, const char *utf8Text); 01424 01425 // Internal use only 01426 // ownerdraw: give a t_object to the menu. 01427 // it will be sent a paint message to draw itself. 01428 // it will be sent a getsize message to find out the size. 01429 void jpopupmenu_addownerdrawitem(t_jpopupmenu *menu, 01430 int itemid, 01431 t_object *owner); 01432 01433 /** Tell a menu to display at a specified location. 01434 @ingroup jpopupmenu 01435 @param menu The pop-up menu to display. 01436 @param screen The point at which to display in screen coordinates. 01437 @param defitemid The initially choosen item id. 01438 @return The item id for the item in the menu choosen by the user. */ 01439 int jpopupmenu_popup(t_jpopupmenu *menu, 01440 t_pt screen, 01441 int defitemid); // initial item id 01442 01443 /** Tell a menu to display above a given box in a patcher. 01444 @ingroup jpopupmenu 01445 @param menu The pop-up menu to display. 01446 @param box The box above which to display the menu. 01447 @param view The patcherview for the box in which to display the menu. 01448 @param offset An offset from the box position at which to display the menu. 01449 @param defitemid The initially choosen item id. 01450 @return The item id for the item in the menu choosen by the user. */ 01451 int jpopupmenu_popup_abovebox(t_jpopupmenu *menu, t_object *box, t_object *view, int offset, int defitemid); 01452 01453 /** Tell a menu to display near a given box in a patcher. 01454 @ingroup jpopupmenu 01455 @param menu The pop-up menu to display. 01456 @param box The box above which to display the menu. 01457 @param view The patcherview for the box in which to display the menu. 01458 @param defitemid The initially choosen item id. 01459 @return The item id for the item in the menu choosen by the user. */ 01460 int jpopupmenu_popup_nearbox(t_jpopupmenu *menu, 01461 t_object *box, t_object *view, 01462 int defitemid); 01463 01464 01465 /** Tell any open popup menus to go away. 01466 */ 01467 void jpopupmenu_closeall(); 01468 01469 // unused by any C74 code 01470 // you can draw to a surface and then turn that into a cursor 01471 // only works with 16 x 16 surfaces 01472 void jmouse_setcursor_surface(t_object *patcherview, t_object *box, t_jsurface *surface, int xHotSpot, int yHotSpot); 01473 01474 01475 // Unused by any C74 code 01476 void jbox_fontface_to_weight_slant(t_object *b, long *weight, long *slant); 01477 01478 /** Get the slant box's font. 01479 @ingroup jfont 01480 @param b An object's box. 01481 @return A value from the #t_jgraphics_font_weight enum. */ 01482 long jbox_get_font_weight(t_object *b); 01483 01484 /** Get the slant box's font. 01485 @ingroup jfont 01486 @param b An object's box. 01487 @return A value from the #t_jgraphics_font_slant enum. */ 01488 long jbox_get_font_slant(t_object *b); 01489 01490 // create a jfont object for box -- internal use only 01491 t_jfont *jbox_createfont(t_object *b); 01492 01493 01494 01495 01496 // utility funtions and macros for new rgba attribtes and legacy rgb attributes 01497 01498 // don't call these two functions directly, instead use the macros below... 01499 t_max_err jgraphics_attr_setrgba(t_object *x, t_object *attr, long argc, t_atom *argv); 01500 t_max_err jgraphics_attr_setrgb_alias(t_object *x, t_object *attr, long argc, t_atom *argv); 01501 01502 01503 /** 01504 Create a color (#t_jrgba) attribute and add it to a Max class. 01505 01506 @ingroup attr 01507 @param c The class pointer. 01508 @param attrname The name of this attribute as a C-string. 01509 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 01510 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 01511 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 01512 */ 01513 #define CLASS_ATTR_RGBA(c,attrname,flags,structname,structmember) \ 01514 { CLASS_ATTR_DOUBLE_ARRAY(c,attrname,flags,structname,structmember,4); \ 01515 CLASS_ATTR_ACCESSORS(c,attrname,NULL,jgraphics_attr_setrgba); \ 01516 CLASS_ATTR_PAINT(c,attrname,0); } 01517 01518 01519 // for internal use only? 01520 #define CLASS_ATTR_RGBA_LEGACY(c,attrname,aliasname,flags,structname,structmember) \ 01521 { CLASS_ATTR_RGBA(c,attrname,flags,structname,structmember); \ 01522 CLASS_ATTR_ALIAS(c,attrname,aliasname); \ 01523 CLASS_ATTR_INVISIBLE(c,aliasname,0); \ 01524 CLASS_ATTR_ACCESSORS(c,aliasname,NULL,jgraphics_attr_setrgb_alias); } 01525 01526 01527 /** 01528 Retrieves the value of a color attribute, given its parent object and name. 01529 01530 @ingroup attr 01531 @param ob The attribute's parent object 01532 @param s The attribute's name 01533 @param c The address of a #t_jrgba struct that will be filled with the attribute's color component values. 01534 @return This function returns the error code #MAX_ERR_NONE if successful, 01535 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 01536 */ 01537 t_max_err object_attr_getjrgba(void *ob, t_symbol *s, t_jrgba *c); 01538 01539 01540 /** 01541 Sets the value of a color attribute, given its parent object and name. 01542 The function will call the attribute's <tt>set</tt> method, using the data provided. 01543 01544 @ingroup attr 01545 @param ob The attribute's parent object 01546 @param s The attribute's name 01547 @param c The address of a #t_jrgba struct that contains the new color. 01548 @return This function returns the error code #MAX_ERR_NONE if successful, 01549 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 01550 */ 01551 t_max_err object_attr_setjrgba(void *ob, t_symbol *s, t_jrgba *c); 01552 01553 01554 /** Get the components of a color in an array of pre-allocated atoms. 01555 01556 @ingroup color 01557 @param argv The address to the first of an array of atoms that will hold the result. 01558 At least 4 atoms must be allocated, as 4 atoms will be set by this function 01559 for the red, green, blue, and alpha components. 01560 @param c The address of a #t_jrgba struct from which the color components will be fetched. 01561 */ 01562 void jrgba_to_atoms(t_jrgba *c, t_atom *argv); 01563 01564 01565 /** Set the components of a color by providing an array of atoms. 01566 If it is an array of 3 atoms, then the atoms provided should define the 01567 red, green, and blue components (in this order) in a range of [0.0, 1.0]. 01568 If a 4th atom is provided, it will define the alpha channel. 01569 If the alpha channel is not defined then it is assumed to be 1.0. 01570 01571 @ingroup color 01572 @param argc The number of atoms in the array provided in argv. 01573 This should be 3 or 4 depending on whether or not the alpha channel is being provided. 01574 @param argv The address to the first of an array of atoms that define the color. 01575 @param c The address of a #t_jrgba struct for which the color will be defined. 01576 @return A Max error code. */ 01577 t_max_err atoms_to_jrgba(long argc, t_atom *argv, t_jrgba *c); 01578 01579 01580 /** Set the components of a color. 01581 @ingroup color 01582 @param prgba The address of a #t_jrgba struct for which the color will be defined. 01583 @param r The value of the red component in a range of [0.0, 1.0]. 01584 @param g The value of the green component in a range of [0.0, 1.0]. 01585 @param b The value of the blue component in a range of [0.0, 1.0]. 01586 @param a The value of the alpha component in a range of [0.0, 1.0]. */ 01587 void jrgba_set(t_jrgba *prgba, double r, double g, double b, double a); 01588 01589 01590 /** Copy a color. 01591 @ingroup color 01592 @param dest The address of a #t_jrgba struct to which the color will be copied. 01593 @param src The address of a #t_jrgba struct from which the color will be copied. */ 01594 void jrgba_copy(t_jrgba *dest, t_jrgba *src); 01595 01596 01597 /** Compare two colors for equality. 01598 @ingroup color 01599 @param rgba1 The address of a #t_jrgba struct to compare. 01600 @param rgba2 The address of another #t_jrgba struct to compare. 01601 @return returns 1 if rgba1 == rgba2. */ 01602 long jrgba_compare(t_jrgba *rgba1, t_jrgba *rgba2); 01603 01604 01605 /** Get a list of of filetypes appropriate for use with jgraphics surfaces. 01606 @ingroup jgraphics 01607 @param dummy Unused. 01608 @param count The address of a variable to be set with the number of types in filetypes upon return. 01609 @param filetypes The address of a variable that will represent the array of file types upon return. 01610 @param alloc The address of a char that will be flagged with a 1 or a 0 depending on whether or not 01611 memory was allocated for the filetypes member. 01612 01613 @remark This example shows a common usage of jgraphics_getfiletypes(). 01614 @code 01615 char filename[MAX_PATH_CHARS]; 01616 long *type = NULL; 01617 long ntype; 01618 long outtype; 01619 t_max_err err; 01620 char alloc; 01621 short path; 01622 t_jsurface *surface; 01623 01624 if (want_to_show_dialog) { 01625 jgraphics_getfiletypes(x, &ntype, &type, &alloc); 01626 err = open_dialog(filename, &path,(void *)&outtype, (void *)type, ntype); 01627 if (err) 01628 goto out; 01629 } 01630 else { 01631 strncpy_zero(filename, s->s_name, MAX_PATH_CHARS); 01632 err = locatefile_extended(filename, &path, &outtype, type, ntype); 01633 if (err) 01634 goto out; 01635 } 01636 surface = jgraphics_image_surface_create_referenced(filename, path); 01637 out: 01638 if (alloc) 01639 sysmem_freeptr((char *)type); 01640 @endcode 01641 */ 01642 void jgraphics_getfiletypes(void *dummy, long *count, long **filetypes, char *alloc); 01643 01644 01645 // boxlayer stuff 01646 01647 /** Invalidate a layer, indicating that it needs to be re-drawn. 01648 @ingroup boxlayer 01649 @param b The object/box to invalidate. 01650 @param view The patcherview for the object which should be invalidated, or NULL for all patcherviews. 01651 @param name The name of the layer to invalidate. 01652 @return A Max error code. */ 01653 t_max_err jbox_invalidate_layer(t_object *b, t_object *view, t_symbol *name); 01654 01655 // unused by any C74 code 01656 t_max_err jbox_remove_layer(t_object *b, t_object *view, t_symbol *name); 01657 01658 /** Create a layer, and ready it for drawing commands. 01659 The layer drawing commands must be wrapped with a matching call to jbox_end_layer() 01660 prior to calling jbox_paint_layer(). 01661 01662 @ingroup boxlayer 01663 @param b The object/box to which the layer is attached. 01664 @param view The patcherview for the object to which the layer is attached. 01665 @param name A name for this layer. 01666 @param width The width of the layer. 01667 @param height The height of the layer. 01668 @return A #t_jgraphics context for drawing into the layer. */ 01669 t_jgraphics* jbox_start_layer(t_object *b, t_object *view, t_symbol *name, double width, double height); 01670 01671 /** Conclude a layer, indicating that it is complete and ready for painting. 01672 @ingroup boxlayer 01673 @param b The object/box for the layer opened by jbox_start_layer(). 01674 @param view The patcherview for the object opened by jbox_start_layer(). 01675 @param name The name of the layer. 01676 @return A Max error code. */ 01677 t_max_err jbox_end_layer(t_object *b, t_object *view, t_symbol *name); 01678 01679 /** Paint a layer at a given position. 01680 Note that the current color alpha value is used when painting layers to allow you to blend layers. 01681 The same is also true for jgraphics_image_surface_draw() and jgraphics_image_surface_draw_fast(). 01682 01683 @ingroup boxlayer 01684 @param b The object/box to be painted. 01685 @param view The patcherview for the object which should be painted, or NULL for all patcherviews. 01686 @param name The name of the layer to paint. 01687 @param x The x-coordinate for the position at which to paint the layer. 01688 @param y The y-coordinate for the position at which to paint the layer. 01689 @return A Max error code. */ 01690 t_max_err jbox_paint_layer(t_object *b, t_object *view, t_symbol *name, double x, double y); 01691 01692 01693 /** Simple utility to test for rectangle intersection. 01694 @ingroup jgraphics 01695 @param r1 The address of the first rect for the test. 01696 @param r2 The address of the second rect for the test. 01697 @return Returns true if the rects intersect, otherwise false. */ 01698 long jgraphics_rectintersectsrect(t_rect *r1, t_rect *r2); 01699 01700 /** Simple utility to test for rectangle containment. 01701 @ingroup jgraphics 01702 @param outer The address of the first rect for the test. 01703 @param inner The address of the second rect for the test. 01704 @return Returns true if the inner rect is completely inside the outer rect, 01705 otherwise false. */ 01706 long jgraphics_rectcontainsrect(t_rect *outer, t_rect *inner); 01707 01708 /** Generate a #t_rect according to positioning rules. 01709 @ingroup jgraphics 01710 @param positioned_rect The address of a valid #t_rect whose members will be filled in upon return. 01711 @param positioned_near_this_rect A pointer to a rect near which this rect should be positioned. 01712 @param keep_inside_this_rect A pointer to a rect defining the limits within which the new rect must reside. */ 01713 void jgraphics_position_one_rect_near_another_rect_but_keep_inside_a_third_rect( 01714 t_rect *positioned_rect, 01715 const t_rect *positioned_near_this_rect, 01716 const t_rect *keep_inside_this_rect); 01717 01718 #if C74_PRAGMA_STRUCT_PACKPUSH 01719 #pragma pack(pop) 01720 #elif C74_PRAGMA_STRUCT_PACK 01721 #pragma pack() 01722 #endif 01723 01724 END_USING_C_LINKAGE 01725 01726 #endif // #ifndef _JGRAPHICS_H_ 01727
Copyright © 2008, Cycling '74