PHPで作図
このページの末尾へ
図形のコピー
: 作図例9 いろいろな曲線
ヘルプ
ドット数(幅
高
)形式(
gif
jpg
)
set_scale($scale = 10, $org_x_percent = 50, $org_y_percent = 50); allocate_color('gray'); draw_xyaxis(); allocate_color('black'); function ellipse_x($t) {$cx = 7; $cy = 4; $a = 5; $b = 2.5; return $a * cos($t) + $cx;} function ellipse_y($t) {$cx = 7; $cy = 4; $a = 5; $b = 2.5; return $b * sin($t) + $cy;} df_xt_yt('ellipse_x', 'ellipse_y', 0, 2 * M_PI, $div = 32); draw_formula("{lbrace}matrix{2}{1}{{x=a cos t}{x=b sin t}}", $size = 12, $px = 7, $py = 10, $o_pos = O_POS_MIDDLE_CENTER); allocate_color('red'); function star_x($t) {$cx = -7; $cy = -7; $r = 5; $s = 1.5; return ($r + $s * sin($t * 5)) * cos($t) + $cx;} function star_y($t) {$cx = -7; $cy = -7; $r = 5; $s = 1.5; return ($r + $s * sin($t * 5)) * sin($t) + $cy;} df_xt_yt('star_x', 'star_y', 0, 2 * M_PI, $div = 64); allocate_text_color('blue'); draw_formula("{lbrace}matrix{2}{1}{{x=(r + s sin(5t)) cos t}{x=(r + s sin(5t)) sin t}}", $size = 12, $px = -15, $py = 0, $o_pos = O_POS_UP_LEFT); allocate_color('green'); function roll_x($t) {$cx = -7; $cy = 7; $r = 1; return ($r * exp($t / (3 * 2 * M_PI))) * cos($t) + $cx;} function roll_y($t) {$cx = -7; $cy = 7; $r = 1; return ($r * exp($t / (3 * 2 * M_PI))) * sin($t) + $cy;} df_xt_yt('roll_x', 'roll_y', 0, 11 * M_PI, $div = 256); draw_formula("{lbrace}matrix{2}{1}{{x=e^{t/{6 pi}} cos t}{x=e^{t/{6 pi}} sin t}}", $size = 12, $px = -15, $py = 15, $o_pos = O_POS_UP_LEFT); function fractale($x1, $y1, $x2, $y2, $nest) { if($nest > 0){ --$nest; $px = ($x1 * 2 + $x2) / 3; $py = ($y1 * 2 + $y2) / 3; $qx = ($x1 + $x2 * 2) / 3; $qy = ($y1 + $y2 * 2) / 3; $u = $x2 - $x1; $v = $y2 - $y1; $len = (unit_vector($u, $v) / 3) * sqrt(3) / 2; rot90_vec($u, $v, $u90, $v90); $rx = ($x1 + $x2) / 2 + $len * $u90; $ry = ($y1 + $y2) / 2 + $len * $v90; fractale($x1, $y1, $px, $py, $nest); fractale($px, $py, $rx, $ry, $nest); fractale($rx, $ry, $qx, $qy, $nest); fractale($qx, $qy, $x2, $y2, $nest); }else{ draw_line($x1, $y1, $x2, $y2); } } for($i = 0; $i <= 4; ++$i){ $y = -14.8 + $i * 2.6; fractale(0, $y, 15, $y, $i); } allocate_text_color('blue'); draw_text('Fractale', $x = 7.5, $y = -14, $o_pos = O_POS_LOW_CENTER);
テンプレートを選択するとプログラムに追加されます。
set_scale(...);
allocate_color('black');
allocate_color('gray');
allocate_color('red');
allocate_color('blue');
allocate_color('green');
allocate_color('purple');
allocate_bgcolor('white');
transparent_bgcolor();
set_thick($thick = 1);
set_dashlen($dashlen = 7);
set_arrow_size(...);
draw_line(...);
draw_horizontal($y);
draw_vertical($x);
draw_dash_line(...);
draw_rect(...);
draw_arrow_head(...);
draw_xaxis(...);
draw_yaxis(...);
draw_xyaxis();
draw_circle(...);
draw_arc_deg(...);
draw_arc(...);
draw_dash_arc(...);
M_PI = 3.1415926535898
M_PI_2 = pi/2
M_PI_4 = pi/4
fill_rect(...);
fill_circle(...);
fill_arc_deg(...);
fill_triangle(...);
fill_quadrangle(...);
fill_polygon();
fill_toborder($x, $y, $border_color_x, $border_color_y);
allocate_text_color('black');
allocate_text_color('gray');
allocate_text_color('red');
allocate_text_color('blue');
allocate_text_color('green');
allocate_text_color('purple');
allocate_text_bgcolor('white');
transparent_text_bgcolor();
set_text_size($text_size);
set_text_margin($text_margin);
set_mark_size($mark_size);
draw_text(...);
O_POS_LOW_LEFT
O_POS_LOW_RIGHT
O_POS_UP_RIGHT
O_POS_UP_LEFT
O_POS_LOW_CENTER
O_POS_MIDDLE_RIGHT
O_POS_UP_CENTER
O_POS_MIDDLE_LEFT
O_POS_MIDDLE_CENTER
get_o_pos_by_ang($ang);
draw_formula(...);
ARC_TYPE_NONE
ARC_TYPE_SOLID
ARC_TYPE_DASH
BEG_TYPE_ARROW
END_TYPE_ARROW
draw_arc_mark(...);
draw_corner_mark(...);
draw_marked_triangle(...);
CMARK_NONE 0
CMARK_1_ARC 1
CMARK_2_ARC 2
CMARK_D_ARC 3
CMARK_1_PIE 4
CMARK_2_PIE 5
CMARK_D_PIE 6
CMARK_SQUARE
CMARK_CROSS
CMARK_CIRCLE
CMARK_DOT
draw_mark(...);
draw_mark_on_line(...);
draw_mark_on_circle(...);
MARK_1_LINE
MARK_2_LINE
MARK_3_LINE
MARK_SQUARE
MARK_CROSS
MARK_CIRCLE
MARK_DOT
set_x_def_range(...);
df1_ax_b($a, $b);
df1_x_y($x, $y);
df1_2p($x1, $y1, $x2, $y2);
df2_ax2_bx_c(...);
df2_ax_p2_q(...);
df2_a_x_al_x_be(...);
df_y_fx($y_fx);
df_xt_yt(...);
unit_vector(...);
calc_angle(...);
normalize_ang($ang);
calc_da(...);
calc_intersec_pt_of_lines(...);
calc_intersec_pt_of_lns(...);
rot90_vec(...);
rot_vec(...);
calc_perpendicular_bisector(...);
calc_distance(...);
calc_circumscribed_circle(...);
calc_didtance_to_line(...);
calc_foot_of_perpendicular_line(...);
calc_parallel_line(...);
calc_foot_of_perpendicular_circle(...);
calc_intersec_pts_of_line_circle(...);
calc_intersec_pts_of_circles(...);
calc_inscribed_circle(...);
calc_2p_arc(...);
calc_3dview(...);
clear_canvas();
set_alphablending($alpha = 50);
set_antialias($antialias = true);
transparent_gif_bgcolor();
xf($x)
x_rev($x)
yf($y)
y_rev($y)
作図プログラムをコンパイルして図形を仮表示する
仮表示
作図プログラムをサーバに保存するには、やる勉にログインしてください。
日付順
名前順
図形の新規作成
ログイン
図形の新規作成
ログイン
このページの先頭へ