Entradas

Mostrando las entradas etiquetadas como Graficacion

Estrellita

Imagen
import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * verticies = (     (0,2.5,0),     (1,1,0),     (3,1,0),     (1.5,-.5,0),     (2.5,-3,0),     (0,-2,0),     (-2.5,-3,0),     (-1.5,-.5,0),     (-3,1,0),     (-1,1,0),     (0,0,.5),     (0,0,-.5) ) edges = ( (0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,8),(8,9),(9,0), (0,10),(1,10),(2,10),(3,10),(4,10),(5,10),(6,10),(7,10),(8,10),(9,10), (0,11),(1,11),(2,11),(3,11),(4,11),(5,11),(6,11),(7,11),(8,11),(9,11)     ) def Cube():     glBegin(GL_LINES)     for edge in edges:         for vertex in edge:             glVertex3fv(verticies[vertex])     glEnd() def main():     pygame.init()     display = (800,600)     pygame.display.set_m...

Cubito de colores

import sys, math, pygame from operator import itemgetter class Point3D: def __init__(self, x=0, y=0, z=0): self.x, self.y, self.z = float(x), float(y), float(z) def rotateX(self, angle): """ Rotates the point around the X axis by the given angle in degrees. """ rad = angle * math.pi / 180 cosa = math.cos(rad) sina = math.sin(rad) y = self.y * cosa - self.z * sina z = self.y * sina + self.z * cosa return Point3D(self.x, y, z) def rotateY(self, angle): """ Rotates the point around the Y axis by the given angle in degrees. """ rad = angle * math.pi / 180 cosa = math.cos(rad) sina = math.sin(rad) z = self.z * cosa - self.x * sina x = self.z * sina + self.x * cosa return Point3D(x, self.y, z) def rotateZ(self, angle): """ Rotates the point around the Z axis by the given angle in degrees. """ rad = angle * math.pi / 180 cosa = math.cos(rad) sina = math.sin(rad) x = self.x ...

Cubito y Triangulito

import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * verticies = ( (1, -1, -1), (1, 1, -1), (-1, 1, -1), (-1, -1, -1), (1, -1, 1), (1, 1, 1), (-1, -1, 1), (-1, 1, 1), ) edges = ( (0,1), (0,3), (0,4), (2,1), (2,3), (2,7), (6,3), (6,4), (6,7), (5,1), (5,4), (5,7), ) def Cube(): glBegin(GL_LINES) for edge in edges: for vertex in edge: glVertex3fv(verticies[vertex]) glEnd() def main(): pygame.init() display = (800,600) pygame.display.set_mode(display, DOUBLEBUF|OPENGL) gluPerspective(45, (display[0]/display[1]), 0.1, 50.0) glTranslatef(0.0,0.0, -5) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() glRotatef(1, 3, 1, 1) glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) Cube() pygame.display.flip() pygame.time.wait(10) main() ---------------------------------------------------------------------------------------------- import pygame from pyga...

Python gráficos 3D

Phython-blender http://piziadas.com/2015/10/programando-con-python-en-blender.html Libreria Matplotlib http://webs.ucm.es/info/aocg/python/modulos_cientificos/matplotlib/index.html http://programacion.net/articulo/introduccion_a_la_libreria_matplotlib_de_python_1599 Tutorial de Matplotlib https://pybonacci.org/wp-content/uploads/2012/08/tutorial-de-matplotlib-pyplotv0-1-201208311.pdf

La niña y la pinta(?

from turtle import * setup( 500 , 500 , 200 , 200 ) title( 'Barquito' ) penup() hideturtle() fillcolor( 'brown' ) begin_fill() goto( 15 , 20 ) pendown() goto( 25 , 5 ) goto( 55 , 5 ) goto( 65 , 20 ) goto( 15 , 20 ) end_fill() penup() goto( 40 , 20 ) pendown() goto( 40 , 55 ) fillcolor( 'aquamarine' ) begin_fill() goto( 25 , 25 ) goto( 40 , 55 ) goto( 55 , 25 ) goto( 25 , 25 ) end_fill() penup() goto(- 40 , 5 ) pendown() fillcolor( 'brown' ) begin_fill() goto(- 10 , 5 ) goto(- 5 , 15 ) goto(- 45 , 15 ) goto(- 40 , 5 ) end_fill() penup() goto(- 25 , 15 ) pendown() goto(- 25 , 40 ) fillcolor( 'aquamarine' ) begin_fill() goto(- 35 , 20 ) goto(- 15 , 20 ) goto(- 25 , 40 ) end_fill() done()

Pinito

from turtle import * setup( 450 , 500 , 0 , 0 ) screensize( 300 , 150 ) title( "www.mclibre.org" ) hideturtle() pensize( 1 ) fillcolor( "green" ) begin_fill() goto(- 20 , 0 ) goto( 20 , 0 ) goto( 0 , 20 ) goto(- 20 , 0 ) penup() goto( 0 ,- 0 ) pendown() goto(- 40 ,- 20 ) goto( 40 ,- 20 ) goto( 0 , 0 ) penup() goto( 0 ,- 20 ) pendown() goto(- 60 ,- 40 ) goto( 60 ,- 40 ) goto( 0 ,- 20 ) end_fill() penup() goto(- 10 ,- 40 ) pendown() fillcolor( "brown" ) begin_fill() goto(- 10 ,- 55 ) goto( 10 ,- 55 ) goto( 10 ,- 40 ) end_fill() done()

Morido x.x

from turtle import * setup( 500 , 400 , 100 , 100 ) title( 'OwO' ) colormode( 255 ) pencolor( 'black' ) pensize( 10 ) goto( 0 , 150 ) goto( 80 , 150 ) goto( 80 , 120 ) penup() goto( 50 , 0 ) pendown() goto(- 50 , 0 ) penup() goto( 80 , 120 ) pendown() pensize( 20 ) dot( 'black' ) pensize( 9 ) goto( 80 , 35 ) goto( 60 , 25 ) penup() goto( 80 , 80 ) pendown() goto( 60 , 60 ) penup() goto( 80 , 80 ) pendown() goto( 100 , 60 ) penup() goto( 80 , 35 ) pendown() goto( 100 , 25 ) pensize( 3 ) penup() hideturtle() goto( 70 , 122 ) pendown() pencolor( 'white' ) goto( 75 , 112 ) penup() goto( 75 , 122 ) pendown() goto( 70 , 112 ) penup() goto( 90 , 122 ) pendown() goto( 85 , 112 ) penup() goto( 85 , 122 ) pendown() goto( 90 , 112 ) penup() goto(- 400 , - 5 ) pendown() pencolor( 'black' ) fillcolor( "pink" ) begin_fill() goto( 400 ,- 5 ) goto( 400 ,- 200 ) goto(- 400 ,- 200 ) goto(- 400 ,- 5 ) end_fill() done()

Figuras con if

# -*- coding: utf-8 -*- from Tkinter import * v0 = Tk() v0.title("OwO") v0.config(bg="aquamarine") v0.geometry("450x200") def mostrar(num): v1 = Toplevel(v0) v1.title("Ventana hija") v1.protocol("WM_DELETE_WINDOW", "onexit") v1.config(bg="black") v1.geometry("300x300") if num==1: hola = Canvas(v1, width=400, heigh=400, bg='pink') hola.pack(expand=YES, fill=BOTH) hola.create_oval(10, 10, 200, 200, width=5, fill='gray') b3 = Button(hola, text="ocultar", command=lambda: ejecutar(ocultar(v1))) b3.pack() elif num == 2: canvas = Canvas(v1,width=300, height=210, bg='blue') canvas.pack(expand=YES, fill=BOTH) canvas.create_rectangle(10, 10, 200, 200, width=5, fill='red') b3 = Button(canvas, text="ocultar", command=lambda: ejecutar(ocultar(v1))) b3.pack() elif num == 3: canvas2 = Canvas(v1,width=300, height=210, bg='gray') canvas2.p...

Todas las figuras

from Tkinter import * # -*- coding: utf-8 -*-from tkinter import * VentanaPrincipal = Tk() VH = Toplevel(VentanaPrincipal) VH2 = Toplevel(VentanaPrincipal) VH3 = Toplevel(VentanaPrincipal) VH4 = Toplevel(VentanaPrincipal) VH5 = Toplevel(VentanaPrincipal) VH6 = Toplevel(VentanaPrincipal) VH7 = Toplevel(VentanaPrincipal) VH8 = Toplevel(VentanaPrincipal) VH9 = Toplevel(VentanaPrincipal) VH10 = Toplevel(VentanaPrincipal) VH11 = Toplevel(VentanaPrincipal) VH12 = Toplevel(VentanaPrincipal) VH13 = Toplevel(VentanaPrincipal) VH14 = Toplevel(VentanaPrincipal) VH15 = Toplevel(VentanaPrincipal) VH16 = Toplevel(VentanaPrincipal) VH17 = Toplevel(VentanaPrincipal) def mostrar(ventana): ventana.deiconify() def ocultar(ventana): ventana.withdraw() def ejecutar(f): VentanaPrincipal.after(200, f) VentanaPrincipal.config(bg="green") VentanaPrincipal.geometry("1920x1080") def Circulo(ventana):     VH.deiconify()     Circulo = Canvas(VH, width=210, ...

Spiderman o0o

from Tkinter import * VentanaP = Tk() VentanaP.title("Spiderman o0o") poly = Canvas(VentanaP, width=400, heigh=400, bg='yellow') poly.pack() poly.create_polygon(100,0, 110,0, 110,30, 120,30, 120,40, 130,40, 130,50, 140,50, 140,60, 150,60, 150,70, 170,70, 170,80, 180,80, 180,90, 190,90, 190,100, 200,100, 200,120, 190,120, 190,130, 170,130,170,140,180,140,180,160,170,160,170,170,160,170,160,180,140,180,140,190,150,190,150,200,160,200,160,210,170,210,170,280,160,280,160,290,150,290,150,300,130,300,130,310,80,310,80,300,60,300,60,290,50,290,50,280,40,280,40,210,50,210,50,200,60,200,60,190,70,190,70,180,50,180,50,170,40,170,40,160,30,160,30,140,40,140,40,130,20,130,20,120,10,120,10,100,20,100,20,90,30,90,30,80,40,80,40,70,60,70,60,60,70,60,70,50,80,50,80,40,90,40,90,30,100,30, fill="black", outline='black') poly.create_polygon( 100,40,90,40,90,50,80,50,80,60,70,60,70,70,60,70,60,80,40,80,40,90,30,90,30,100,20,100,     20,120,...