Skip to content

Instantly share code, notes, and snippets.

@originalsouth
Created June 1, 2017 23:15
Show Gist options
  • Save originalsouth/c5858d0a5e362a841b01f5fc39e8e64a to your computer and use it in GitHub Desktop.
Save originalsouth/c5858d0a5e362a841b01f5fc39e8e64a to your computer and use it in GitHub Desktop.
Draw a dislocation svg
#include "tlv/tlv.h"
int main()
{
std::vector<int> x={38,149,264,396,520,640,764,93,208,327,452,573,693,60,169,286,388,498,619,747,118,242,389,552,695,55,195,322,450,592,739,118,262,398,525,661,58,195,332,450,593,738};
std::vector<int> y={33,33,33,31,32,45,39,141,139,131,132,139,147,249,255,253,222,254,231,261,358,356,342,360,359,466,461,461,464,464,460,562,560,565,569,565,652,647,651,654,650,647};
const int N=x.size();
const int R=25;
const int L=10;
tlv::svg img(798,690);
for(int i=0;i<N;i++) for(int j=0;j<N;j++) if(i>j and (int)sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2))<170) tlv_drw(&img,line x1="%d" y1="%d" x2="%d" y2="%d" stroke="#808000" stroke-width="%d",x[i],y[i],x[j],y[j],L);
for(int i=0;i<N;i++) tlv_drw(&img,circle cx="%d" cy="%d" r="%d" stroke="#000000" fill="#000000",x[i],y[i],R);
img.write("disloc.svg");
return EXIT_SUCCESS;
}
@originalsouth
Copy link
Author

In case you are looking for tlv follow: https://github.com/originalsouth/tlv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment