Slideshow funktioniert nicht ganz

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
tebineisbe
User
Beiträge: 1
Registriert: Mittwoch 27. März 2019, 15:07

Hallo,

meine Slideshow hat das Problem das sie ausgeführt wird, aber es keine Bilder angezeigt werden.
Ich wüsste nicht wo ich den path der Galerie hinschreiben soll.
Ich bitte um code ergänzungen


def setup():

size(displayWidth, displayHeight, P3D)

global background_color, n_images, image_frame, image_size, my_images
global index, x, y, start_point_x

background_color = color(0, 90, 200)

n_images = 5

image_size = {"x1": 600, "y1": 500}
image_frame = {"x1": 400, "y1": 100, "x2": 1000, "y2": 600}

index = 0

start_point_x = image_frame["x1"] - image_size["x1"]
x = start_point_x
y = image_frame["y1"]



my_images = [PImage] * n_images

for i in range(n_images):
my_images = loadImage("my_images" + str(i) + ".jpg")
my_images.resize(image_size["x1"], image_size["y1"])

def draw():

global background_color
background(background_color)

move_the_image()
display_the_image()


def move_the_image():

global x, image_frame, start_point_x, index, n_images

speed = 3.5

x += speed

if x > image_frame["x2"]:
x = start_point_x
index = (index + 1) % n_images


def display_the_image():

global x, y, index, my_images, image_frame


textSize(30)
message = "my_images" + str(index) + ".jpg"
fill(255)
text(message, image_frame["x1"], image_frame["y1"] - 10)

noFill()

stroke(255)
rect(image_frame["x1"], image_frame["y1"], \
image_frame["x2"] - image_frame["x1"], \
image_frame["y2"] - image_frame["y1"])

image(my_images[index], x, y)
fill(background_color)
noStroke()

rect(0, image_frame["y1"], image_frame["x1"], \
image_frame["y2"] - image_frame["y1"])


rect(image_frame["x2"], image_frame["y1"], width, \
image_frame["y2"] - image_frame["y1"])




def mousePressed():
exit()setup():

size(displayWidth, displayHeight, P3D)

global background_color, n_images, image_frame, image_size, my_images
global index, x, y, start_point_x

background_color = color(0, 90, 200)

n_images = 5

image_size = {"x1": 600, "y1": 500}
image_frame = {"x1": 400, "y1": 100, "x2": 1000, "y2": 600}

index = 0

start_point_x = image_frame["x1"] - image_size["x1"]
x = start_point_x
y = image_frame["y1"]



my_images = [PImage] * n_images

for i in range(n_images):
my_images = loadImage("my_images" + str(i) + ".jpg")
my_images.resize(image_size["x1"], image_size["y1"])

def draw():

global background_color
background(background_color)

move_the_image()
display_the_image()


def move_the_image():

global x, image_frame, start_point_x, index, n_images

speed = 3.5

x += speed

if x > image_frame["x2"]:
x = start_point_x
index = (index + 1) % n_images


def display_the_image():

global x, y, index, my_images, image_frame


textSize(30)
message = "my_images" + str(index) + ".jpg"
fill(255)
text(message, image_frame["x1"], image_frame["y1"] - 10)

noFill()

stroke(255)
rect(image_frame["x1"], image_frame["y1"], \
image_frame["x2"] - image_frame["x1"], \
image_frame["y2"] - image_frame["y1"])

image(my_images[index], x, y)
fill(background_color)
noStroke()

rect(0, image_frame["y1"], image_frame["x1"], \
image_frame["y2"] - image_frame["y1"])


rect(image_frame["x2"], image_frame["y1"], width, \
image_frame["y2"] - image_frame["y1"])




def mousePressed():
exit()
Benutzeravatar
__blackjack__
User
Beiträge: 14040
Registriert: Samstag 2. Juni 2018, 10:21
Wohnort: 127.0.0.1
Kontaktdaten:

@tebineisbe: Da sind ein Haufen Namen drin die nirgends definiert sind – vielleicht möchtest Du den Code erst einmal um die nötigen Definitionen (Importe?) ergänzen. Und dann bitte auch in Code-Tags setzen damit man das hier auch lesen kann.

Edit: Und bitte alle ``global`` entfernen und stattdessen Funktionen richtig verwenden – so mit Argumenten/Rückgabewerten. Es gibt da keine einzige richtige Funktion. Die werden als benannte Sprungmarken missbraucht. Python ist kein BASIC.
„A life is like a garden. Perfect moments can be had, but not preserved, except in memory. LLAP” — Leonard Nimoy's last tweet.
Benutzeravatar
ThomasL
User
Beiträge: 1378
Registriert: Montag 14. Mai 2018, 14:44
Wohnort: Kreis Unna NRW

Das kommt mir bekannt vor, hat das was mit The Coding Train und Processing zu tun?
Ich bin Pazifist und greife niemanden an, auch nicht mit Worten.
Für alle meine Code Beispiele gilt: "There is always a better way."
https://projecteuler.net/profile/Brotherluii.png
Antworten