Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

New library: ChipScene

This is the re­al out­come of my Py­Week fail­ure: a neat li­brary.

Take Chip­munk and Qt mash them up, and what do you get?

A OpenGL-ac­cel­er­at­ed, mul­ti­plat­for­m, easy-­to-use play­ground!

But watch the sil­ly video that shows no in­ter­est­ing fea­tures in­stead:

You can't see it but there are 29 bal­loon­s, num­bered, that bounce around hap­pi­ly.

Per­for­mance in the video sucks be­cause I had to dis­able OpenGL in or­der to cap­ture it cor­rect­ly (and video record­ing kills my note­book,any­way). That de­mo nor­mal­ly runs in 3 sec­ond­s, not 57.

Here's the non-boil­er­plate code for that de­mo:

def fillWorld(scene):
  items=[]
  for x in range(1, 29):
      b=cs.CPBodyItem(bpos=[0+13*random.randint(0,25), -50-30*random.randint(0,10)],m=10)
      s=cs.CPCircleShapeItem(10, b, e=.5, offset=[0, 0])
      t=QtGui.QGraphicsSimpleTextItem(str(x), s)
      t.setPos(-5, -5)
      items.append(b)
  items.append(cs.CPSegmentShapeItem([0, 50], [500, 450], 1, None, e=.7))
  items.append(cs.CPSegmentShapeItem([0, 450], [500, 50], 1, None, e=.7))

  for i in items:
      scene.addItem(i)

Neat, is­n't it?

You can get it at the Chip­Scene google code project in­clud­ing, of course, the source.


Contents © 2000-2024 Roberto Alsina