Seite 1 von 1

Slideshow funktioniert nicht ganz

Verfasst: Mittwoch 27. März 2019, 15:10
von tebineisbe
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()

Re: Slideshow funktioniert nicht ganz

Verfasst: Mittwoch 27. März 2019, 15:39
von __blackjack__
@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.

Re: Slideshow funktioniert nicht ganz

Verfasst: Donnerstag 28. März 2019, 07:02
von ThomasL
Das kommt mir bekannt vor, hat das was mit The Coding Train und Processing zu tun?