לדלג לתוכן

קובץ:Wfm floodfill animation queue.gif

תוכן הדף אינו נתמך בשפות אחרות.
מתוך ויקיפדיה, האנציקלופדיה החופשית

Wfm_floodfill_animation_queue.gif(200 × 200 פיקסלים, גודל הקובץ: 31 ק"ב, סוג MIME‏: image/gif, בלולאה, 175 תמונות, 19 שניות)

ויקישיתוף זהו קובץ שמקורו במיזם ויקישיתוף. תיאורו בדף תיאור הקובץ המקורי (בעברית) מוצג למטה.

תקציר

תיאור Example image showing Floodfill animated using a queue structure
תאריך יצירה
מקור נוצר על־ידי מעלה היצירה
יוצר Finlay McWalter
גרסאות אחרות image:Wfm_floodfill_animation_stack.gif

רישיון

אני, בעל זכויות היוצרים על היצירה הזאת, מפרסם אותה בזאת תחת הרישיונות הבאים:
GNU head מוענקת בכך הרשות להעתיק, להפיץ או לשנות את המסמך הזה, לפי תנאי הרישיון לשימוש חופשי במסמכים של גנו, גרסה 1.2 או כל גרסה מאוחרת יותר שתפורסם על־ידי המוסד לתוכנה חופשית; ללא פרקים קבועים, ללא טקסט עטיפה קדמית וללא טקסט עטיפה אחורית. עותק של הרישיון כלול בפרק שכותרתו הרישיון לשימוש חופשי במסמכים של גנו.
w:he:Creative Commons
ייחוס שיתוף זהה
הנכם רשאים:
  • לשתף – להעתיק, להפיץ ולהעביר את העבודה
  • לערבב בין עבודות – להתאים את העבודה
תחת התנאים הבאים:
  • ייחוס – יש לתת ייחוס הולם, לתת קישור לרישיון, ולציין אם נעשו שינויים. אפשר לעשות את זה בכל צורה סבירה, אבל לא בשום צורה שמשתמע ממנה שמעניק הרישיון תומך בך או בשימוש שלך.
  • שיתוף זהה – אם תיצרו רמיקס, תשנו, או תבנו על החומר, חובה עליכם להפיץ את התרומות שלך לפי תנאי רישיון זהה או תואם למקור.
הנכם מוזמנים לבחור את הרישיון הרצוי בעיניכם.

Creation

Created using the following Python program:

#!/usr/bin/python

# Basic Python program to render animations for Wikipedia floodfill
# article (not a general floodfill example, very far from a shining example).

# This example uses the four-way floodfill algorithm, and generates 
# example animations using both a stack and a queue as intermediate
# storage schemes.

# Requirements:
# * python
# * Python Imaging Library (PIL)
# * ImageMagick (used to compile intermediate images to GIF animations)
# 
# The os.system() calls are written for unix; changing them for windows
# should be trivial

# Copyright (C) 2008 Finlay McWalter. 
# Licence: your choice from GFDL, GPLv2, GPLv3, CC-by-SA2.0
 

import os, Image, ImageColor, ImageDraw
from collections import deque

def floodfill(img, 
              (startx, starty), 
              targetcolour, 
              newcolour, 
              dumpEveryX=70,
              pattern=None,
              useQueue=False,
              startIndex=0):
    
    if useQueue:
        workpile = deque();
        getpoint = workpile.popleft
    else:
        workpile = []
        getpoint = workpile.pop

    max=0
    count=0

    workpile.append((startx,starty))
    while len(workpile)> 0:
        x,y=getpoint()
        
        if len(workpile)> max: 
            max=len(workpile)

        if img.getpixel((x,y)) == targetcolour:
            img.putpixel((x,y), newcolour)
            
            # every few pixels drawn, dump an image showing our progress
            count += 1
            if (count%dumpEveryX)==0 and pattern != None:
                img.save(pattern %(startIndex+count))

            # this demo code doesn't handle the case where we get to the edge
            if img.getpixel((x-1,y))== targetcolour: workpile.append((x-1,y))
            if img.getpixel((x+1,y))== targetcolour: workpile.append((x+1,y))
            if img.getpixel((x,y-1))== targetcolour: workpile.append((x,y-1))
            if img.getpixel((x,y+1))== targetcolour: workpile.append((x,y+1))

    print '    done with count %d, max %d' % (count,max)
    return count

def make_floodfill_example(filename, use_queue):
    print 'making image '+filename
    print '  removing old files'
    os.system('rm -f out*.png ' +filename )

    i = Image.new('RGB', (200,200), 'white')

    # draw a rough ying-yang
    draw = ImageDraw.Draw(i)
    draw.ellipse((30,30,170,170), outline='black')
    draw.arc((65,100,135,170), 90,270, fill='black')
    draw.arc((64,30,134,100), 270,90, fill='black')
    draw.ellipse((80,45,120,85), outline='black')
    draw.ellipse((80,115,120,155), outline='black')
    del draw

    print '  filling'
    redcount = floodfill(i, 
                         (100, 90), 
                         (255,255,255), #white
                         (255,0,0), #red
                         useQueue = use_queue,
                         pattern='out_%05d.png')

    print '  filling'
    bluecount = floodfill(i,
                          (110,110),
                          (255,255,255), # white
                          (0,0,255), # blue
                          useQueue = use_queue,
                          pattern='out_%05d.png',
                          startIndex=redcount)

    # push some extra frames of animation so we can see the finished fill
    for x in range(redcount+bluecount,redcount+bluecount+20):
        i.save('out_%05d.png' %(x))    

    print '  converting to animated GIF - this may take several minutes'
    os.system ('convert -loop 0 out*.png '+filename)

# draw one example image using a FIFO as the means of storing points,
# and another using a LIFO.
make_floodfill_example('wfm_floodfill_animation_queue.gif', True)
make_floodfill_example('wfm_floodfill_animation_stack.gif', False)
print 'done'

כיתובים

נא להוסיף משפט שמסביר מה הקובץ מייצג

פריטים שמוצגים בקובץ הזה

מוצג

היסטוריית הקובץ

ניתן ללחוץ על תאריך/שעה כדי לראות את הקובץ כפי שנראה באותו זמן.

תאריך/שעהתמונה ממוזערתממדיםמשתמשהערה
נוכחית02:07, 9 באפריל 2014תמונה ממוזערת לגרסה מ־02:07, 9 באפריל 2014‪200 × 200‬ (31 ק"ב)CountingPineOptimise file size using GIMP
18:28, 24 באוגוסט 2008תמונה ממוזערת לגרסה מ־18:28, 24 באוגוסט 2008‪200 × 200‬ (241 ק"ב)Finlay McWalter{{Information |Description= |Source= |Date= |Author= |Permission= |other_versions= }}
17:28, 24 באוגוסט 2008תמונה ממוזערת לגרסה מ־17:28, 24 באוגוסט 2008‪200 × 200‬ (236 ק"ב)Finlay McWalter{{Information |Description=Example image showing Floodfill animated using a queue structure |Source=self made |Date=24th August 2008 |Author=Finlay McWalter |Permission=see below |other_versions=[[:image:Wfm_floodfill_animation_queue.gif

אין בוויקיפדיה דפים המשתמשים בקובץ זה.

שימוש גלובלי בקובץ

אתרי הוויקי השונים הבאים משתמשים בקובץ זה: