Jump to content

Sierpinski curve: Difference between revisions

m
C++ - calculate initial x and y from length
m (Refactored C++ code)
m (C++ - calculate initial x and y from length)
Line 175:
class sierpinski_curve {
public:
void write(std::ostream& out, int size, doubleint xlength, doubleint y,order);
int length, int order);
private:
static std::string rewrite(const std::string& s);
Line 187 ⟶ 186:
};
 
void sierpinski_curve::write(std::ostream& out, int size, doubleint xlength, doubleint y,order) {
int length, int order) {
length_ = length;
x_ = xlength/std::sqrt(2.0);
y_ = y2 * x_;
angle_ = 45;
out << "<svg xmlns='http://www.w3.org/2000/svg' width='"
Line 247 ⟶ 245:
}
sierpinski_curve s;
s.write(out, 545, 5, 10, 7, 5);
return 0;
}</lang>
 
{{out}}
See: [https://slack-files.com/T0CNUL56D-F01GBK1GF2BF01GZ1BU4RZ-6c7c86c4e799f34b7076 sierpinski_curve.svg] (offsite SVG image)
 
=={{header|Factor}}==
1,777

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.