mirror of https://github.com/dnomd343/klotski.git
Dnomd343
2 years ago
6 changed files with 211 additions and 109 deletions
@ -1,4 +1,8 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
|
include_directories(svg) |
||||
|
|
||||
|
add_subdirectory(svg) |
||||
|
|
||||
add_library(graph graph.cc) |
add_library(graph graph.cc) |
||||
target_link_libraries(graph analyse) |
target_link_libraries(graph analyse svg) |
||||
|
@ -0,0 +1,3 @@ |
|||||
|
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
|
add_library(svg svg.cc) |
@ -0,0 +1,50 @@ |
|||||
|
#include "svg.h" |
||||
|
|
||||
|
#include <cstdio> |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
std::string SvgRect::dump() const { |
||||
|
|
||||
|
/// <rect x="120" width="100" height="100" rx="15" />
|
||||
|
|
||||
|
// char *radius_str = nullptr;
|
||||
|
// if (radius == 0) {
|
||||
|
// asprintf(&radius_str, " ");
|
||||
|
// } else {
|
||||
|
// asprintf(&radius_str, R"( rx="%lu" )", radius);
|
||||
|
// }
|
||||
|
|
||||
|
std::string style; |
||||
|
|
||||
|
// style="fill:blue;stroke:pink;stroke-width:5;fill-opacity:0.1;stroke-opacity:0.9"
|
||||
|
|
||||
|
char *xml = nullptr; |
||||
|
asprintf(&xml, R"(<rect x="%ld" y="%ld" width="%ld" height="%ld")", left, top, width, height); |
||||
|
std::string ret(xml); |
||||
|
free(xml); |
||||
|
|
||||
|
if (radius != 0) { |
||||
|
char *radius_str = nullptr; |
||||
|
asprintf(&radius_str, R"( rx="%lu")", radius); |
||||
|
|
||||
|
ret += radius_str; |
||||
|
|
||||
|
free(radius_str); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// std::cout << xml << std::endl;
|
||||
|
|
||||
|
// std::string result = xml;
|
||||
|
|
||||
|
// free(xml);
|
||||
|
|
||||
|
// std::string xml("<rect ");
|
||||
|
// xml += "x = ";
|
||||
|
//
|
||||
|
// xml += atoi();
|
||||
|
|
||||
|
return ret + " />"; |
||||
|
|
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include <string> |
||||
|
#include <cstdint> |
||||
|
|
||||
|
class SvgRect { |
||||
|
public: |
||||
|
uint64_t top; |
||||
|
uint64_t left; |
||||
|
uint64_t width; |
||||
|
uint64_t height; |
||||
|
uint64_t radius = 0; |
||||
|
uint32_t stroke = 1; |
||||
|
|
||||
|
float opacity = 0; |
||||
|
float line_opacity = 0; |
||||
|
std::string color = "pink"; |
||||
|
std::string line_color = "blue"; |
||||
|
|
||||
|
std::string dump() const; |
||||
|
}; |
Loading…
Reference in new issue