PHPで作図
このページの末尾へ
図形のコピー
: 作図例91 ピタゴラスの定理
ヘルプ
ドット数(幅
高
)形式(
gif
jpg
)
set_scale($scale = 10, $org_x_percent = 50, $org_y_percent = 50); function pythagoras($cent_x, $cent_y, $len_c = 4, $ang_a = 1, $mode = 0) { $len_b = $len_c * cos($ang_a); $len_a = $len_c * sin($ang_a); $ax = $cent_x; $ay = $cent_y; $bx = $ax + $len_c ; $by = $ay; $cx = $ax + $len_b * cos($ang_a); $cy = $ay + $len_b * sin($ang_a); $a1x = $ax; $a1y = $ay - $len_c; $a2x = $ax + $len_b * cos($ang_a + M_PI / 2); $a2y = $ay + $len_b * sin($ang_a + M_PI / 2); $a3x = $ax; $a3y = $ay + $len_c; $b1x = $bx; $b1y = $by - $len_c; $b2x = $bx + $len_a * cos($ang_a); $b2y = $by + $len_a * sin($ang_a); $b3x = $bx; $b3y = $by + $len_c; $c1x = $cx + $len_b * cos($ang_a + M_PI / 2); $c1y = $cy + $len_b * sin($ang_a + M_PI / 2); $c2x = $cx + $len_a * cos($ang_a); $c2y = $cy + $len_a * sin($ang_a); $c3x = $cx; $c3y = $ay; $c4x = $cx; $c4y = $a1y; $c5x = $c1x + $len_a * cos($ang_a); $c5y = $c1y + $len_a * sin($ang_a); /* allocate_color('purple'); allocate_bgcolor('yellow'); draw_line($ax, $ay, $bx, $by); draw_line($bx, $by, $cx, $cy); draw_line($cx, $cy, $ax, $ay); draw_line($c3x, $c3y, $c4x, $c4y); */ if($mode == 0 || $mode == 1){ allocate_color('#FFD700'); fill_quadrangle($ax, $ay, $cx, $cy, $c1x, $c1y, $a2x, $a2y); }else if($mode == 2 || $mode == 3){ allocate_color('#FFD700'); fill_quadrangle($ax, $ay, $cx, $cy, $c5x, $c5y, $a3x, $a3y); } if($mode == 0 || $mode == 1){ allocate_color('#87CEEB'); fill_quadrangle($cx, $cy, $bx, $by, $b2x, $b2y, $c2x, $c2y); }else if($mode == 2 || $mode == 3){ allocate_color('#87CEEB'); fill_quadrangle($cx, $cy, $bx, $by, $b3x, $b3y, $c5x, $c5y); } if($mode == 0 || $mode == 1 || $mode == 2){ allocate_color('#FF69B4'); fill_quadrangle($ax, $ay, $bx, $by, $b1x, $b1y, $a1x, $a1y); }else{ allocate_color('#FFD700'); fill_quadrangle($ax, $ay, $c3x, $c3y, $c4x, $c4y, $a1x, $a1y); allocate_color('#87CEEB'); fill_quadrangle($c3x, $c3y, $c4x, $c4y, $b1x, $b1y, $bx, $by); } allocate_color('black'); draw_line($ax, $ay, $a1x, $a1y); draw_line($ax, $ay, $a2x, $a2y); draw_line($a1x, $a1y, $b1x, $b1y); draw_line($bx, $by, $b1x, $b1y); draw_line($bx, $by, $b2x, $b2y); draw_line($b2x, $b2y, $c2x, $c2y); draw_line($cx, $cy, $c1x, $c1y); draw_line($cx, $cy, $c2x, $c2y); draw_line($c1x, $c1y, $a2x, $a2y); allocate_color('black'); draw_marked_triangle($ax, $ay, $bx, $by, $cx, $cy, $type_a = 0, $type_b = 0, $type_c = 1, $text_a = '', $text_b = '', $text_c = '', $text_ops_a = 'A', $text_ops_b = 'B', $text_ops_c = 'C', $italic = true, $italic_ops = false, $r = 10); if($mode == 0){ draw_text('a', ($bx + $cx) / 2, ($by + $cy) / 2, O_POS_LOW_LEFT); draw_text('b', ($cx + $ax) / 2, ($cy + $ay) / 2, O_POS_LOW_RIGHT); draw_text('c', ($ax + $bx) / 2, ($ay + $by) / 2 - $len_c / 10, O_POS_UP_CENTER); } if($mode == 1){ allocate_color('red'); draw_line($cx, $cy, $c5x, $c5y); draw_line($c2x, $c2y, $c5x, $c5y); draw_line($c1x, $c1y, $c5x, $c5y); }else if($mode == 2){ allocate_color('red'); set_thick($thick = 3); draw_line($cx, $cy, $c5x, $c5y); draw_line($b3x, $b3y, $c5x, $c5y); draw_line($b3x, $b3y, $bx, $by); draw_line($bx, $by, $cx, $cy); draw_line($a3x, $a3y, $c5x, $c5y); draw_line($a3x, $a3y, $ax, $ay); draw_line($cx, $cy, $ax, $ay); set_thick($thick = 1); }else if($mode == 3){ allocate_color('red'); set_thick($thick = 1); draw_line($c3x, $c3y, $c5x, $c5y); draw_line($b3x, $b3y, $c5x, $c5y); draw_line($b3x, $b3y, $bx, $by); draw_line($bx, $by, $cx, $cy); draw_line($a3x, $a3y, $c5x, $c5y); draw_line($a3x, $a3y, $ax, $ay); draw_line($cx, $cy, $ax, $ay); set_thick($thick = 3); draw_line($c3x, $c3y, $c4x, $c4y); draw_line($ax, $ay, $bx, $by); draw_line($bx, $by, $b1x, $b1y); draw_line($b1x, $b1y, $a1x, $a1y); draw_line($a1x, $a1y, $ax, $ay); set_thick($thick = 1); } } pythagoras($x = -12, $y = 6.3, $len = 6, $ang = M_PI / 3, $mode = 0); pythagoras($x = 3, $y = 6.3, $len = 6, $ang = M_PI / 3, $mode = 1); pythagoras($x = -12, $y = -8.8, $len = 6, $ang = M_PI / 3, $mode = 2); pythagoras($x = 3, $y = -8.8, $len = 6, $ang = M_PI / 3, $mode = 3); set_text_size(8); draw_text('ピタゴラスの定理 (1)', -15, 15, O_POS_UP_LEFT, 'ipamp'); draw_formula('a^2+b^2=c^2', $size = 9, -15, 13, O_POS_UP_LEFT); draw_text('(2)', 0, 15, O_POS_UP_LEFT, 'ipamp'); draw_text('(3)', -15, 0, O_POS_UP_LEFT, 'ipamp'); draw_text('(4)', 0, 0, O_POS_UP_LEFT, 'ipamp');
テンプレートを選択するとプログラムに追加されます。
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)
作図プログラムをコンパイルして図形を仮表示する
仮表示
作図プログラムをサーバに保存するには、やる勉にログインしてください。
日付順
名前順
図形の新規作成
ログイン
図形の新規作成
ログイン
このページの先頭へ