"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Graphics/Renderer/brush.cpp" between
TeXmacs-1.99.4-src.tar.gz and TeXmacs-1.99.5-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

brush.cpp  (TeXmacs-1.99.4-src):brush.cpp  (TeXmacs-1.99.5-src)
skipping to change at line 12 skipping to change at line 12
/****************************************************************************** /******************************************************************************
* MODULE : brush.cpp * MODULE : brush.cpp
* DESCRIPTION: brushes for painting * DESCRIPTION: brushes for painting
* COPYRIGHT : (C) 2013 Joris van der Hoeven * COPYRIGHT : (C) 2013 Joris van der Hoeven
******************************************************************************* *******************************************************************************
* This software falls under the GNU general public license version 3 or later. * This software falls under the GNU general public license version 3 or later.
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
******************************************************************************/ ******************************************************************************/
#include "brush.hpp" #include "renderer.hpp"
#include "gui.hpp" #include "gui.hpp"
#include "image_files.hpp"
url get_current_buffer_safe ();
bool is_percentage (tree t, string s= "%");
double as_percentage (tree t);
/****************************************************************************** /******************************************************************************
* Equality * Equality
******************************************************************************/ ******************************************************************************/
bool bool
operator == (const brush& a, const brush& b) { operator == (const brush& a, const brush& b) {
brush_rep* ar= (brush_rep*) a.rep; brush_rep* ar= (brush_rep*) a.rep;
brush_rep* br= (brush_rep*) b.rep; brush_rep* br= (brush_rep*) b.rep;
return return
skipping to change at line 85 skipping to change at line 90
c (c2), pattern (p), alpha (a) {} c (c2), pattern (p), alpha (a) {}
brush_kind get_type () { return brush_pattern; } brush_kind get_type () { return brush_pattern; }
void* get_handle () { return (void*) this; } void* get_handle () { return (void*) this; }
color get_color () { return c; } color get_color () { return c; }
tree get_pattern () { return pattern; } tree get_pattern () { return pattern; }
int get_alpha () { return alpha; } int get_alpha () { return alpha; }
}; };
url
brush_rep::get_pattern_url () {
tree t= get_pattern ();
if (is_atomic (t) || N(t) == 0 || !is_atomic (t[0])) return url ();
url u= as_string (t[0]);
url r= resolve (url ("$TEXMACS_PATTERN_PATH") * u);
if (!is_none (r)) return r;
url base= get_current_buffer_safe ();
r= resolve (relative (base, u));
if (!is_none (r)) return r;
return u;
}
/****************************************************************************** /******************************************************************************
* Constructors * Constructors
******************************************************************************/ ******************************************************************************/
static brush_rep* static brush_rep*
make_brush (bool b) { make_brush (bool b) {
if (b) return tm_new<color_brush_rep> (white); if (b) return tm_new<color_brush_rep> (white);
else return tm_new<no_brush_rep> (); else return tm_new<no_brush_rep> ();
} }
skipping to change at line 123 skipping to change at line 141
color c= white; color c= white;
if (N(p) == 4) c= named_color (as_string (p[3]), a); if (N(p) == 4) c= named_color (as_string (p[3]), a);
return tm_new<pattern_brush_rep> (c, p, a); return tm_new<pattern_brush_rep> (c, p, a);
} }
} }
//brush::brush (): rep (make_brush (white)) { INC_COUNT (rep); } //brush::brush (): rep (make_brush (white)) { INC_COUNT (rep); }
brush::brush (color c): rep (make_brush (c)) { INC_COUNT (rep); } brush::brush (color c): rep (make_brush (c)) { INC_COUNT (rep); }
brush::brush (bool b): rep (make_brush (b)) { INC_COUNT (rep); } brush::brush (bool b): rep (make_brush (b)) { INC_COUNT (rep); }
brush::brush (tree p, int a): rep (make_brush (p, a)) { INC_COUNT (rep); } brush::brush (tree p, int a): rep (make_brush (p, a)) { INC_COUNT (rep); }
/******************************************************************************
* Unpacking pattern data
******************************************************************************/
void
get_pattern_data (url& u, SI& w, SI& h, brush br, SI pixel) {
// FIXME << what's about ratio and percentages wrt paper lengths?
tree pattern= br->get_pattern ();
u= br->get_pattern_url ();
int imw_pt, imh_pt;
image_size (u, imw_pt, imh_pt);
double pt= ((double) 600*PIXEL) / 72.0;
SI imw= (SI) (((double) imw_pt) * pt);
SI imh= (SI) (((double) imh_pt) * pt);
w= imw, h= imh;
if (is_int (pattern[1])) w= as_int (pattern[1]);
else if (is_percentage (pattern[1]))
w= (SI) (as_percentage (pattern[1]) * ((double) w));
else if (is_percentage (pattern[1], "@"))
w= (SI) (as_percentage (pattern[1]) * ((double) h));
if (is_int (pattern[2])) h= as_int (pattern[2]);
else if (is_percentage (pattern[2]))
h= (SI) (as_percentage (pattern[2]) * ((double) h));
else if (is_percentage (pattern[2], "@"))
h= (SI) (as_percentage (pattern[2]) * ((double) w));
w= ((w + pixel - 1) / pixel);
h= ((h + pixel - 1) / pixel);
}
 End of changes. 4 change blocks. 
1 lines changed or deleted 19 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS