14:51 Изящные шестеренки |
Эту красивую реализацию рисования шестеренок я позаимствовал с примера из purebasic. Шестеренками можно управлять, добавлять зубчики, изменять размеры, и т.д. Код для Create rayon = 120 RayonAlesage = 40 NbDents = 12 HauteurDent = 30 Decalage = 0.6 Couleur = 0 PosX1=0 PosX2=0 PosX3=0 PosX4=0 PosY1=0 PosY2=0 PosY3=0 PosY4=0 x = room_width/2 y = room_height/2 Код для Draw if keyboard_check(vk_left) && NbDents>1 then NbDents-=1 if keyboard_check(vk_right) && NbDents<100 then NbDents+=1 if keyboard_check(vk_up) && HauteurDent>1 then HauteurDent-=1 if keyboard_check(vk_down) && HauteurDent<100 then HauteurDent+=1 if keyboard_check(vk_pageup) then Decalage-=0.1 if keyboard_check(vk_pagedown) then Decalage+=0.1 if keyboard_check(ord("Z")) then rayon-=0.1 if keyboard_check(ord("X")) then rayon+=0.1 Decalage+=0.01 draw_set_color(c_black) draw_circle(x, y, rayon - HauteurDent, false) draw_set_color(c_white) draw_circle(x, y, RayonAlesage, false) draw_set_color(c_black) LargeurDent = floor(rayon * 3 / 5 * sin(pi / NbDents) + 0.5) for (n=0; n<NbDents; n+=1) { cos = cos((n + Decalage) * 2 * pi / NbDents) sin = sin((n + Decalage) * 2 * pi / NbDents) PosX1 = floor(x + rayon * cos + LargeurDent / 2 * sin + 0.5) PosY1 = floor(y + rayon * sin - LargeurDent / 2 * cos + 0.5) PosX2 = floor(x + rayon * cos - LargeurDent / 2 * sin + 0.5) PosY2 = floor(y + rayon * sin + LargeurDent / 2 * cos + 0.5) PosX3 = floor(x + (rayon - HauteurDent - 2) * cos + LargeurDent * sin + 0.5) PosY3 = floor(y + (rayon - HauteurDent - 2) * sin - LargeurDent * cos + 0.5) PosX4 = floor(x + (rayon - HauteurDent - 2) * cos - LargeurDent * sin + 0.5) PosY4 = floor(y + (rayon - HauteurDent - 2) * sin + LargeurDent * cos + 0.5) draw_primitive_begin(pr_trianglefan) draw_vertex_color(PosX1, PosY1,c_black,1) draw_vertex_color(PosX2, PosY2,c_black,1) draw_vertex_color(PosX3, PosY3,c_black,1) draw_vertex_color(PosX1, PosY1,c_black,1) draw_vertex_color(PosX3, PosY3,c_black,1) draw_vertex_color(PosX4, PosY4,c_black,1) draw_vertex_color(PosX2, PosY2,c_black,1) draw_primitive_end() } |
Категория: Примеры |
Просмотров: 3277 |
Добавил: gmExe
| Теги: |
Всего комментариев: 0 | |