Segments In Computer Graphics
Segments
Image Source - Google | Image By - geeksforgeeks |
• BD created for a code that is not specified where it belongs then it belongs to zero segments, with no visibility.
• Segment name can be integers from 1 to max number.
Create Segment
create_segment (seg_name)
{
variables:
now_open (global val = 0), num_seg, seg_start [num_seg], seg_size [num_seg], trans_x [num_seg], visibility [num_seg], trans_y [num_seg], angle [num_seg], scale [num_seg], free
If now_open > 0 then,
Error: "Segment already opened"
If seg_name < 1 or seg_name > num_seg then,
Error: "Invalid segment name"
If seg_size [seg_name] > 0 then,
Error: "Segment already exists"
seg_start [seg_name] = free
seg_size [seg_name] = 0
visibility [seg_name] = visibility [0]
trans_x [seg_name] = trans_x [0]
trans_y [seg_name] = trans_y [0]
scale_x [seg_name] = scale_x [0]
scale_y [seg_name] = scale_y [0]
angle [seg_name] = angle [0]
now_open = seg_name
}
Close Segment
close_segment ()
{
If now_open = 0 then,
Error: "Segment already closed"
delete_seg (0)
seg_start [0] = free
seg_size [0] = 0
now_open = 0
}
Delete Segment
delete_segment (seg_name)
{
If (seg_name < 1 or seg_name > num_seg) then,
Error: "Invalid segment name"
If now_open = seg_name then,
Error: "Segment open"
If seg_size [seg_name] = 0 then,
Error: "Segment doesn't exists"
put = seg_start [seg_name]
size = seg_size [seg_name]
get = put + size
while (get < free)
{
df_op [put] = df_op [get]
df_x [put] = df_x [get]
df_y [put] = df_y [get]
put ++
get ++
}
free = put
for (i = 0 to num_seg)
{
if (seg_start [i] > seg_start [seg_name])
{
seg_start [i] = seg_start [i] - size
}
}
seg_size [seg_name] = 0
if (visibility [seg_name] == 1) then,
new_frame ()
}
Delete All
delete_all ()
{
for (i = 0 to num_seg)
{
seg_start [i] = 1
seg_size [i] = 0
}
free = 1
now_open = 0
new_frame ()
}
Liang Barsky Algorithm In Computer Graphics
Double Buffering In Computer Graphics
Comment your views on this Article :)
No comments
Comment your views on this article