Could you show me a sample? I tried getting this to work and always failed and you always say its possible.
#!/usr/bin/env python
import cairo
import pygame
import array
import math
import sys
import direct.directbase.DirectStart
from pandac.PandaModules import *
props = WindowProperties()
props.setSize(512,512)
base.win.requestProperties(props)
screen = loader.loadModel('plane.egg')
screen.setScale(2)
Width, Height = 512, 512
cairoTexture = Texture()
cairoTexture.setFormat(cairoTexture.FRgba8)
screen.setTexture(cairoTexture)
screen.reparentTo(render2d)
cairoTexture.setXSize(Width)
cairoTexture.setYSize(Height)
ptu_data = cairoTexture.newSimpleRamImage(Width,Height)
# start of the fail code?
array_data = array.array('c', ptu_data.getData())
print len(array_data)
for i in range(Width*Height):
array_data[i] = chr(200)
def draw(surface):
x,y, radius = (250,250, 200)
ctx = cairo.Context(surface)
ctx.set_line_width(15)
ctx.arc(x, y, radius, 0, 2.0 * math.pi)
ctx.set_source_rgb(0.8, 0.8, 0.8)
ctx.fill_preserve()
ctx.set_source_rgb(1, 1, 1)
ctx.stroke()
surface = cairo.ImageSurface.create_for_data (
array_data,
cairo.FORMAT_ARGB32,
Width,
Height,
Width*4)
def drawall(task):
draw(surface)
# fail code after this line::::
#print cairoTexture.getExpectedRamImageSize()
#cairoTexture.setRamImage(how(ptu_data))
return task.cont
taskMgr.add(drawall, 'draw')
run()