from gl import Render, color

r = Render(600, 600)

r.glViewport(100, 100, 400, 400)

r.glClearColor(0, 0, 0)
r.glColor(0.45, 0.5, 0)
r.glClear()

r.glLine(-1, 0, 0, 1)
r.glLine(0, 1, 1, 0)
r.glLine(1, 0, 0, -1)
r.glLine(0, -1, -1, 0)
r.glLine(-1, 0, 1, 0)
r.glLine(0, -1, 0, 1)
r.glLine(-1, -1, -1, 1)
r.glLine(-1, 1, 1, 1)
r.glLine(1, 1, 1, -1)
r.glLine(1, -1, -1, -1)
r.glLine(-1, -1, 1, 1)
r.glLine(1, -1, -1, 1)

r.glFinish('output.bmp')
예제 #2
0
18398
"""
from gl import Render, changecolor

posX = 250
posY = 250
width = 1000
height = 1000

bitmap = Render(width, height) #los ultimos tres son los colores son los del background

bitmap.glViewPort(posX, posY, width - 500 , height - 500)
bitmap.glClearColor(0, 0, 0)
bitmap.glclear()

#principales (t)
bitmap.glColor(1, 1, 1) #estos colores son los que se usaran en Vertex
bitmap.glLine(0, -1, 0, 1)
bitmap.glLine(-1, 0, 1, 0)

bitmap.glColor(0, 1, 0) 
bitmap.glLine(1, -1, -1, 1)
bitmap.glLine(-1, -1, 1, 1)
#margen
bitmap.glColor(1, 0, 0) 
bitmap.glLine(-1, 1, 1, 1)
bitmap.glLine(1, -1, 1, 1)
bitmap.glLine(1, -1, -1, -1)
bitmap.glLine(-1, -1, -1, 1)

bitmap.finish('out.bmp')
예제 #3
0
            'Ingrese el valor entre -1 y 1 en x relativo al viewPort para el punto: ',
            True))
        vertexY = (askForNumberBetween0and1(
            'Ingrese el valor entre -1 y 1 en y relativo al viewPort para el punto: ',
            True))
        mainGl.glVertexColorRelative(vertexX, vertexY)
        continue
    #glVertex create line
    elif (mainOption == "5"):
        vertexX0 = (askForNumberBetween0and1(
            'Ingrese el valor entre -1 y 1 en x relativo al viewPort para el punto x0: ',
            True))
        vertexY0 = (askForNumberBetween0and1(
            'Ingrese el valor entre -1 y 1 en y relativo al viewPort para el punto y0: ',
            True))
        vertexX1 = (askForNumberBetween0and1(
            'Ingrese el valor entre -1 y 1 en x relativo al viewPort para el punto x1: ',
            True))
        vertexY1 = (askForNumberBetween0and1(
            'Ingrese el valor entre -1 y 1 en y relativo al viewPort para el punto y1: ',
            True))
        mainGl.glLine(vertexX0, vertexY0, vertexX1, vertexY1)
        continue
    #glFinish save
    elif (mainOption == "6"):
        mainGl.glFinish('graphic.bmp')
        continue
    #exit
    else:
        break
예제 #4
0
파일: srtwo.py 프로젝트: gera1013/SR2
from gl import Render, color

r = Render()

r.glCreateWindow(800, 800)
r.glClearColor(0, 0, 0)
r.glColor(1, 0, 0.9843)
r.glClear()

r.glLine(0, 0, 1, 1)
r.glLine(0, 0, 1, 0.5)
r.glLine(0, 0, 1, 0)
r.glLine(0, 0, 1, -0.5)
r.glLine(0, 0, 1, -1)
r.glLine(0, 0, 0.5, -1)
r.glLine(0, 0, 0, -1)
r.glLine(0, 0, -0.5, -1)
r.glLine(0, 0, -1, -1)
r.glLine(0, 0, -1, -0.5)
r.glLine(0, 0, -1, 0)
r.glLine(0, 0, -1, 0.5)
r.glLine(0, 0, -1, 1)
r.glLine(0, 0, -0.5, 1)
r.glLine(0, 0, 0, 1)
r.glLine(0, 0, 0.5, 1)

r.glFinish()
예제 #5
0
from gl import Render, glColor

r = Render()
r.glInit(800, 600)

#Figura 1
r.glLine(165, 380, 185, 360)
r.glLine(185,360,180,330)
r.glLine(180,330,207,345)
r.glLine(207,345,233,330)
r.glLine(233,330,230,360)
r.glLine(230,360,250,380)
r.glLine(250,380,220,385)
r.glLine(220,385,205,410)
r.glLine(205,410,193,383)
r.glLine(193,383,165,380)

#Figura 2
r.glLine(321, 335, 288, 286)
r.glLine(288, 286, 339, 251)
r.glLine(339, 251, 374, 302)
r.glLine(374, 302, 321, 335)

#Figura 3
r.glLine(377, 249, 411, 197)
r.glLine(411, 197, 436, 249)
r.glLine(436, 249, 377, 249)

#Figura 4
r.glLine(413, 177, 448, 159) 
r.glLine(448, 159, 502, 88) 
예제 #6
0
파일: main.py 프로젝트: lpcuellar/SR2-Lines
                )
                x1 = float(x1)
                y1 = input(
                    "Ingrese un valor final en y relativo al  ViewPort (entre -1 y 1): "
                )
                y1 = float(y1)

                ##  it validates the coordinates given above
                if ((x0 < -1 or x0 > 1) or (y0 < -1 or y0 > 1)
                        or (x1 < -1 or x1 > 1) or (y1 < -1 or y1 > 1)):
                    print("\nPor favor escoger valores entre -1 y 1\n")
                else:
                    is_values_ok = True

                    ##  this function draws the line into the image
                    render.glLine(x0, y0, x1, y1)
        else:
            print("Por favor escoja una opción válida!")

    ##      this function saves all the data edited above and writes all the changes into the image
    elif (option == 5):
        render.glFinish(filename)

    ##  this option will let you quit the program, it has a warnin message before quitting
    elif (option == 6):
        print(
            "Si se sale del programa y no ha guardado la imagen no se notará ningún cambio!"
        )
        exit = input("Desea salir del programa? (Si o No): ")

        if (exit.upper() == "SI"):