File size: 2,541 Bytes
ad8cacf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""

Output-related UI components.

"""

import gradio as gr
from app.ui.components_common import EMOJI

def create_output_components():
    """Create output components."""
    with gr.Group():
        gr.Markdown(f"## {EMOJI['split']} 分割結果")
        overview_image = gr.Image(
            label=f"{EMOJI['image']} 分割されたイラスト",
            type="filepath"
        )
    
    with gr.Group():
        gr.Markdown(f"## {EMOJI['vector']} SVG変換結果")
        output_text = gr.Textbox(
            label=f"{EMOJI['processing']} 処理状況",
            placeholder="処理結果がここに表示されます",
            lines=5
        )
        
        grid_display = gr.Checkbox(
            label=f"{EMOJI['grid']} グリッド表示",
            value=True,
            info="SVGをグリッド状に配置して表示"
        )
        
        with gr.Row():
            svg_preview = gr.HTML(
                label=f"{EMOJI['art']} SVGプレビュー",
                value="<div style='text-align:center'>SVGがここに表示されます</div>"
            )
        
        with gr.Row():
            output_files = gr.File(
                label=f"{EMOJI['download']} 個別SVGファイル",
                file_count="multiple"
            )
            zip_download = gr.File(
                label=f"{EMOJI['folder']} ZIPアーカイブ",
                file_count="single"
            )
    
    return (
        overview_image,
        output_text,
        output_files,
        grid_display,
        svg_preview,
        zip_download
    )

def create_progress_display():
    """Create progress display component."""
    return gr.HTML(
        value="<div id='progress'></div>",
        visible=False
    )

def update_progress(value, status):
    """

    Update progress display.

    

    Args:

        value (float): Progress value (0-1)

        status (str): Status message

        

    Returns:

        dict: HTML update for progress display

    """
    percentage = int(value * 100)
    return {
        "value": f"""

        <div style="width:100%; background-color:#f0f0f0; border-radius:5px;">

            <div style="width:{percentage}%; background-color:var(--orange-3); 

                        height:20px; border-radius:5px;">

            </div>

        </div>

        <div style="text-align:center; margin-top:5px;">

            {status} ({percentage}%)

        </div>

        """
    }