Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substrate heatmaps in SVGs, defined in config file #219

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions modules/PhysiCell_SVG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ bool Write_SVG_text( std::ostream& os, const char* str , double position_x, doub
return true;
}

void Write_SVG_text(std::ostream& os, const char* str , double position_x, double position_y, double font_size , const char* color , const char* font, double rotation)
{
double text_width = font_size * strlen(str) / 2.0; // estimate the width of the text
double text_height = font_size / 2.0; // estimate the height of the text

double center_x = position_x + text_width / 2.0;
double center_y = position_y + text_height / 2.0;

os << "<text x=\"" << position_x << "\" y=\"" << position_y << "\" font-size=\"" << font_size << "\" fill=\"" << color << "\" font-family=\"" << font << "\" transform=\"rotate(" << rotation << " " << center_x << " " << center_y << ")\">" << str << "</text>\n";
}

bool Write_SVG_circle( std::ostream& os, double center_x, double center_y, double radius, double stroke_size,
std::string stroke_color , std::string fill_color )
{
Expand Down
3 changes: 3 additions & 0 deletions modules/PhysiCell_SVG.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>

#ifndef _PhysiCell_SVG_h_
#define _PhysiCell_SVG_h_
Expand All @@ -78,6 +79,8 @@ bool Write_SVG_start( std::ostream& os, double width, double height );
bool Write_SVG_end( std::ostream& os );

bool Write_SVG_text( std::ostream& os, const char* str , double position_x, double position_y, double font_size , const char* color , const char* font);
void Write_SVG_text(std::ostream& os, const char* str , double position_x, double position_y, double font_size , const char* color , const char* font, double rotation);

bool Write_SVG_circle( std::ostream& os, double center_x, double center_y, double radius, double stroke_size, std::string stroke_color , std::string fill_color );

bool Write_SVG_rect( std::ostream& os , double UL_corner_x, double UL_corner_y, double width, double height,
Expand Down
Loading
Loading