Skip to content

Instantly share code, notes, and snippets.

@HelloWorld017
Created September 24, 2016 12:54
Show Gist options
  • Save HelloWorld017/98061ac6ba860cd1aee192932c09ade5 to your computer and use it in GitHub Desktop.
Save HelloWorld017/98061ac6ba860cd1aee192932c09ade5 to your computer and use it in GitHub Desktop.
아카시아 로고 제작에 사용된 js
let get_xy = (x, y, radius, angle) => {
let rad = Math.PI / 180 * angle;
return {
x: Math.round(x + Math.cos(rad) * radius),
y: Math.round(y + Math.sin(rad) * radius)
};
};
let generate_flower = (x, y, radius, angle_base) => {
let str = '';
for(let angle = 0; angle < 180; angle += angle_base){
let pos1 = get_xy(x, y, radius * Math.sin(radius * angle), angle);
let pos2 = get_xy(x, y, radius * Math.sin(radius * angle), angle + 180);
str += `<line x1="${pos1.x}" y1="${pos1.y}" x2="${pos2.x}" y2="${pos2.y}" stroke-width="2" stroke="#ff9800"/>\n`;
}
return str;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment