アットウィキロゴ

jhg98

var x = new Array();
var y = new Array();
var cx = new Array();
var cy = new Array();
var link_a = new Array();
var link_b = new Array();
 
function sample() {
 
 
 
 
    faststep();
 
 
 
 
 
    var timer;
    var delay = 100;
 
    var loop = function () {
 
 
        y_body = y_body + 10;
        if (y_body > 200) y_body = 100;
 
        change();
 
        delta();
 
        paint();
 
        clearTimeout(timer);
        timer = setTimeout(loop, delay);
    }
 
    loop();
 
 
}
 
 
 
function poly(col) {
 
    var str, data;
    var s;
    data = "";
    for (s = 1; s <24; s++) {
        data = data + cx[s] + "," + cy[s] + ",";
    }
    s = 24;
    data = data + cx[s] + "," + cy[s];
 
    str = "<polygon fill=" + chop(col) + " points=" + chop(data) + "/>";
 
    return str;
}
 
function chop(str) {
 
    var strx;
 
    strx = "\"" + str + "\"";
 
    return strx;
 
}
 
 
function faststep() {
 
    y_body = 200;
    x_body = 250;
    th_body = 90;
    len_body = 100;
 
    th_head = 90;
    len_head = 50;
 
    len_sh_r = 30;
    th_sh_r = 0;
    th_sh_l = 180;
    len_sh_l = 30;
 
    th_hand_r = 300;
    len_hand_r = 50;
    len_hand_l = 50;
    th_hand_l = 250;
 
    th_finger_r = 270;
    len_finger_r = 30;
    len_finger_l = 30;
    th_finger_l = 270;
 
    th_hip_r = 0;
    len_hip_r = 20;
    len_hip_l = 20;
    th_hip_l = 180;
 
    th_leg_r = 270;
    len_leg_r = 40;
    len_leg_l = 40;
    th_leg_l = 270;
 
    th_foot_r = 270;
    len_foot_r = 40;
    len_foot_l = 40;
    th_foot_l = 270;
 
 
 
    link_a[1] = 1;
    link_b[1] = 2;
    link_a[2] = 2;
    link_b[2] = 3;
    link_a[3] = 2;
    link_b[3] = 4;
    link_a[4] = 2;
    link_b[4] = 5;
    link_a[5] = 4;
    link_b[5] = 6;
    link_a[6] = 5;
    link_b[6] = 7;
    link_a[7] = 6;
    link_b[7] = 8;
    link_a[8] = 7;
    link_b[8] = 9;
    link_a[9] = 1;
    link_b[9] = 10;
    link_a[10] = 1;
    link_b[10] = 11;
    link_a[11] = 10;
    link_b[11] = 12;
    link_a[12] = 11;
    link_b[12] = 13;
    link_a[13] = 12;
    link_b[13] = 14;
    link_a[14] = 13;
    link_b[14] = 15;
 
}
 
function delta() {
 
 
 
    cx[1] = x[4];
    cy[1] = y[4] + 5;
 
    cx[2] = x[6];
    cy[2] = y[6] + 5;
    cx[3] = x[8];
    cy[3] = y[8] + 5;
    cx[4] = x[8];
    cy[4] = y[8] - 5;
    cx[5] = x[6];
    cy[5] = y[6] - 5;
 
    cx[6] = x[4];
    cy[6] = y[4] - 10;
    cx[7] = x[10] - 10;
    cy[7] = y[10];
 
    cx[8] = x[12] - 5;
    cy[8] = y[12];
    cx[9] = x[14] - 5;
    cy[9] = y[14];
    cx[10] = x[14] + 5;
    cy[10] = y[14];
    cx[11] = x[12] + 5;
    cy[11] = y[12];
    cx[12] = x[1];
    cy[12] = y[1];
 
    cx[13] = x[13] - 5;
    cy[13] = y[13];
 
    cx[14] = x[15] - 5;
    cy[14] = y[15];
    cx[15] = x[13] + 5;
    cy[15] = y[13];
 
    cx[16] = x[9] + 10;
    cy[16] = y[9];
 
    cx[17] = x[11] + 10;
    cy[17] = y[11];
 
 
    cx[18] = x[5];
    cy[18] = y[5] -10;
    cx[19] = x[7];
    cy[19] = y[7] - 5;
    cx[20] = x[9];
    cy[20] = y[9] - 5;
    cx[21] = x[9];
    cy[21] = y[9] + 5;
    cx[22] = x[7];
    cy[22] = y[7] + 5;
 
    cx[23] = x[5];
    cy[23] = y[5] + 5;
 
 
    cx[24] = x[2];
    cy[24] = y[2];
 
 
 
 
 
 
 
 
    for (s = 1; s < 25; s++) {
        cy[s] = 500 - cy[s];
    }
 
 
}
 
 
function change() {
 
    x[1] = x_body;
    y[1] = y_body;
    x[2] = x[1] + tranx(len_body, th_body);
    y[2] = y[1] + trany(len_body, th_body);
    x[3] = x[2] + tranx(len_head, th_head);
    y[3] = y[2] + trany(len_head, th_head);
 
    x[4] = x[2] + tranx(len_sh_l, th_sh_l);
    y[4] = y[2] + trany(len_sh_l, th_sh_l);
    x[5] = x[2] + tranx(len_sh_r, th_sh_r);
    y[5] = y[2] + trany(len_sh_r, th_sh_r);
 
    x[6] = x[4] + tranx(len_hand_l, th_hand_l);
    y[6] = y[4] + trany(len_hand_l, th_hand_l);
    x[7] = x[5] + tranx(len_hand_r, th_hand_r);
    y[7] = y[5] + trany(len_hand_r, th_hand_r);
 
    x[8] = x[6] + tranx(len_finger_l, th_finger_l);
    y[8] = y[6] + trany(len_finger_l, th_finger_l);
    x[9] = x[7] + tranx(len_finger_r, th_finger_r);
    y[9] = y[7] + trany(len_finger_r, th_finger_r);
 
    x[10] = x[1] + tranx(len_hip_l, th_hip_l);
    y[10] = y[1] + trany(len_hip_l, th_hip_l);
    x[11] = x[1] + tranx(len_hip_r, th_hip_r);
    y[11] = y[1] + trany(len_hip_r, th_hip_r);
 
    x[12] = x[10] + tranx(len_leg_l, th_leg_l);
    y[12] = y[10] + trany(len_leg_l, th_leg_l);
    x[13] = x[11] + tranx(len_leg_r, th_leg_r);
    y[13] = y[11] + trany(len_leg_r, th_leg_r);
 
    x[14] = x[12] + tranx(len_foot_l, th_foot_l);
    y[14] = y[12] + trany(len_foot_l, th_foot_l);
    x[15] = x[13] + tranx(len_foot_r, th_foot_r);
    y[15] = y[13] + trany(len_foot_r, th_foot_r);
 
}
 
 
function paint() {
 
    var sub = new svgpaint();
 
    str = "<svg width=\"500\" height=\"500\">";
    str = str + sub.rect(0, 0, 500, 500, "blue");
 
    str = str + poly("green");
 
    for (s = 1; s < 16; s++) {
        str = str + sub.circle(x[s], 500 - y[s], 2, "red");
    }
 
    for (s = 1; s < 15; s++) {
        s1 = link_a[s];
        s2 = link_b[s];
        str = str + sub.line(x[s1], 500 - y[s1], x[s2], 500 - y[s2], 3, "red");
    }
 
 
    str = str + "</svg>";
 
    $("#memo").html(str);
 
 
}
 
 
 
function tranx(le1, th1) {
 
    x1 = le1 * Math.cos(th1 * Math.PI / 180);
    return x1;
}
 
function trany(le1, th1) {
 
    y1 = le1 * Math.sin(th1 * Math.PI / 180);
 
    return y1;
}
最終更新:2015年06月20日 17:40