湖濱散記部落格的樹心幽徑[login][主頁]
362:20170708Koch-snowflake(three segment von koch curve)

alt

alt

altalt

//g++  `Magick++-config --cxxflags --cppflags` -I/usr/local/include/ImageMagick-7  segb.c `Magick++-config --ldflags --libs`  -L/usr/local/zlib/lib -lz

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <Magick++.h>
using namespace Magick;
void drawTen(int L,int ox,int oy, int w, int h,Image *pim){
if (L==1){
    drawTen(L-1,ox+2*w/7,oy+2*h/7,3*w/7,3*h/7,pim);
    drawTen(L-1,ox+1*w/7,oy+0*h/7,3*w/7,3*h/7,pim);
    drawTen(L-1,ox+4*w/7,oy+1*h/7,3*w/7,3*h/7,pim);
    drawTen(L-1,ox+3*w/7,oy+4*h/7,3*w/7,3*h/7,pim);
    drawTen(L-1,ox+0*w/7,oy+3*h/7,3*w/7,3*h/7,pim);
    }
if (L==2){
    drawTen(L-1,ox+4*w/15,oy+4*h/15,7*w/15,7*h/15,pim);
    drawTen(L-1,ox+0*w/15,oy+1*h/15,7*w/15,7*h/15,pim);
    drawTen(L-1,ox+7*w/15,oy+0*h/15,7*w/15,7*h/15,pim);
    drawTen(L-1,ox+8*w/15,oy+7*h/15,7*w/15,7*h/15,pim);
    drawTen(L-1,ox+1*w/15,oy+8*h/15,7*w/15,7*h/15,pim);
    }
if (L==3){
    drawTen(L-1,ox+10*w/35,oy+10*h/35,15*w/35,15*h/35,pim);
    drawTen(L-1,ox+ 5*w/35,oy+ 0*h/35,15*w/35,15*h/35,pim);
    drawTen(L-1,ox+20*w/35,oy+ 5*h/35,15*w/35,15*h/35,pim);
    drawTen(L-1,ox+15*w/35,oy+20*h/35,15*w/35,15*h/35,pim);
    drawTen(L-1,ox+ 0*w/35,oy+15*h/35,15*w/35,15*h/35,pim);
    }
if (L==4){
    drawTen(L-1,ox+20*w/75,oy+20*h/75,35*w/75,35*h/75,pim);
    drawTen(L-1,ox+ 0*w/75,oy+ 5*h/75,35*w/75,35*h/75,pim);
    drawTen(L-1,ox+35*w/75,oy+ 0*h/75,35*w/75,35*h/75,pim);
    drawTen(L-1,ox+40*w/75,oy+35*h/75,35*w/75,35*h/75,pim);
    drawTen(L-1,ox+ 5*w/75,oy+40*h/75,35*w/75,35*h/75,pim);
    }
if(L==0){
pim->strokeColor("white");
pim->draw(DrawableLine(ox+w/3,oy+0,ox+w/3,oy+h));
pim->draw(DrawableLine(ox+2*w/3,oy+0,ox+2*w/3,oy+h));
pim->draw(DrawableLine(ox+0,oy+h/3,ox+w,oy+h/3));
pim->draw(DrawableLine(ox+0,oy+2*h/3,ox+w,oy+2*h/3));
pim->draw(DrawableLine(ox,oy+h/3,ox,oy+2*h/3));
pim->draw(DrawableLine(ox+w-1,oy+h/3,ox+w-1,oy+2*h/3));
pim->draw(DrawableLine(ox+w/3,oy,ox+2*w/3,oy));
pim->draw(DrawableLine(ox+w/3,oy+h-1,ox+2*w/3,oy+h-1));
pim->strokeColor("red");
pim->draw(DrawableArc(ox+w/3+5,oy+h/3+5,ox+w*2/3-5,oy+h*2/3-5,0,360));
}
}

int main()
{
int w=3*7*5*10;
int h=3*7*5*10;
Image im( Geometry(w, h), Color("black"));
im.draw(DrawableStrokeColor(Color("black")));
im.strokeWidth(2);
drawTen(4,0,0,w,h,&im);
im.write("seg0708-4.jpg");
drawTen(3,0,0,w,h,&im);
im.write("seg0708-3.jpg");
drawTen(2,0,0,w,h,&im);
im.write("seg0708-2.jpg");
drawTen(1,0,0,w,h,&im);
im.write("seg0708-1.jpg");
}


select id,article_id,topic,text from lt_articles_text where article_id =362; ok. update lt_articles set num_reads=num_reads +1 where id=362; ok.