'@ Compile Bacon Beta 2.5 :: see note alexfish
'@ note 2.4 does not pass *type unsigned char arrays
PRAGMA LDFLAGS `pkg-config --libs elementary cairo`
PRAGMA OPTIONS `pkg-config --cflags elementary cairo`
PRAGMA INCLUDE elementary-1/Elementary.h cairo/cairo.h
'@alexfish UFO-evas /cairo
'--- reduced size + red & white for demo
'---cairo
PROTO cairo_create
PROTO cairo_rectangle
PROTO cairo_set_source_rgb
PROTO cairo_fill
PROTO cairo_destroy
PROTO cairo_surface_destroy
PROTO cairo_scale
PROTO cairo_image_surface_create_for_data
PROTO cairo_surface_flush
PROTO cairo_image_surface_create
'---GUI
PROTO Ecore_Evas , Evas_Object
PROTO elm_policy_set
PROTO elm_win_util_standard_add
PROTO elm_win_autodel_set
PROTO evas_object_resize
PROTO evas_object_show
PROTO elm_run
PROTO elm_shutdown
PROTO elm_init
PROTO evas_object_rectangle_add, evas_object_color_set
PROTO evas_object_move
PROTO evas_object_evas_get
PROTO ecore_evas_get
PROTO evas_object_image_colorspace_set
PROTO evas_object_image_size_set
PROTO evas_object_image_data_set
'@ INIT
elm_init(0,0)
'@ Declares
DECLARE *img TYPE Evas_Object
DECLARE *pixy TYPE unsigned char
DECLARE *surface TYPE cairo_surface_t
DECLARE canvas1 TYPE Evas*
DECLARE *win TYPE Evas_Object
DECLARE *bg TYPE Evas_Object
REM ----CAIRO UF0--------------------------
FUNCTION UFO(cairo_surface_t *cs)
LOCAL *pixels TYPE unsigned char
color$="#ffffff"
DECLARE xs = 1 TYPE double
DECLARE ys = 1 TYPE double
DECLARE a = 500 TYPE double
b = (double)a * a
DECLARE c = 400 TYPE double
DECLARE q,r,y TYPE double
DECLARE i,m,n,p,x,st TYPE double
ia = (double)1/a
LOCAL *cr TYPE cairo_t
cr=cairo_create(cs)
'cairo_scale(cr,0.5,0.5)
cairo_set_source_rgb(cr,1.0, 0.0,0.0)
cairo_rectangle(cr, 0, 0,500, 500)
cairo_fill(cr)
cairo_scale(cr,0.5,0.5)
cairo_set_source_rgb(cr,DEC(MID$(color$, 2, 2)), DEC(MID$(color$, 4, 2)), DEC(MID$(color$, 6, 2)) )
FOR x = 0 TO a STEP 2
s = x * x
p = SQR(b - s)
st=6*ys
FOR i = -p TO p STEP st
r = SQR(s + i * i) /a
q = (r -1.0) * SIN(24 * r)
y = FLOOR(i/3 + q * c)
IF i=-p THEN
m=y
n=y
END IF
IF y > m THEN m = y
IF y < n THEN n = y
IF m = y OR n = y THEN
cairo_rectangle(cr, (double)-x+500, (double)y+500,2.0, 2.0)
cairo_fill(cr)
cairo_rectangle(cr, (double)x+500,(double)y+500,2.0, 2.0)
cairo_fill(cr)
END IF
NEXT
NEXT
cairo_surface_flush(cs)
pixels = cairo_image_surface_get_data(cs)
cairo_destroy(cr)
PRINT "Render Time ",TIMER-start , " mSec"
RETURN pixels
END FUNCTION
'@ END FUNCTIONS and SUBS
'--- test the GUI a simple window + find drawable + add rectangle
HEIGHT=500
WIDTH = 500
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
win = elm_win_util_standard_add("UFO-Evas", "UFO-Evas")
elm_win_autodel_set(win, EINA_TRUE)
evas_object_resize(win, WIDTH, HEIGHT)
evas_object_show(win)
'@ find drawable
canvas1 = evas_object_evas_get(win)
' @ create cairo image similar to evas image @ CAIRO_FORMAT_ARGB32
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT)
' @ create the ufo
pixy = UFO(surface)
' @ create evas image to match cairo @ EVAS_COLORSPACE_ARGB8888
img = evas_object_image_filled_add(canvas1)
evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888)
evas_object_image_size_set(img, WIDTH, HEIGHT)
evas_object_image_data_set(img, pixy)
evas_object_resize(img, WIDTH, HEIGHT)
evas_object_show(img)
elm_run()
elm_shutdown()
'@ note 2.4 does not pass *type unsigned char arrays
PRAGMA LDFLAGS `pkg-config --libs elementary cairo`
PRAGMA OPTIONS `pkg-config --cflags elementary cairo`
PRAGMA INCLUDE elementary-1/Elementary.h cairo/cairo.h
'@alexfish UFO-evas /cairo
'--- reduced size + red & white for demo
'---cairo
PROTO cairo_create
PROTO cairo_rectangle
PROTO cairo_set_source_rgb
PROTO cairo_fill
PROTO cairo_destroy
PROTO cairo_surface_destroy
PROTO cairo_scale
PROTO cairo_image_surface_create_for_data
PROTO cairo_surface_flush
PROTO cairo_image_surface_create
'---GUI
PROTO Ecore_Evas , Evas_Object
PROTO elm_policy_set
PROTO elm_win_util_standard_add
PROTO elm_win_autodel_set
PROTO evas_object_resize
PROTO evas_object_show
PROTO elm_run
PROTO elm_shutdown
PROTO elm_init
PROTO evas_object_rectangle_add, evas_object_color_set
PROTO evas_object_move
PROTO evas_object_evas_get
PROTO ecore_evas_get
PROTO evas_object_image_colorspace_set
PROTO evas_object_image_size_set
PROTO evas_object_image_data_set
'@ INIT
elm_init(0,0)
'@ Declares
DECLARE *img TYPE Evas_Object
DECLARE *pixy TYPE unsigned char
DECLARE *surface TYPE cairo_surface_t
DECLARE canvas1 TYPE Evas*
DECLARE *win TYPE Evas_Object
DECLARE *bg TYPE Evas_Object
REM ----CAIRO UF0--------------------------
FUNCTION UFO(cairo_surface_t *cs)
LOCAL *pixels TYPE unsigned char
color$="#ffffff"
DECLARE xs = 1 TYPE double
DECLARE ys = 1 TYPE double
DECLARE a = 500 TYPE double
b = (double)a * a
DECLARE c = 400 TYPE double
DECLARE q,r,y TYPE double
DECLARE i,m,n,p,x,st TYPE double
ia = (double)1/a
LOCAL *cr TYPE cairo_t
cr=cairo_create(cs)
'cairo_scale(cr,0.5,0.5)
cairo_set_source_rgb(cr,1.0, 0.0,0.0)
cairo_rectangle(cr, 0, 0,500, 500)
cairo_fill(cr)
cairo_scale(cr,0.5,0.5)
cairo_set_source_rgb(cr,DEC(MID$(color$, 2, 2)), DEC(MID$(color$, 4, 2)), DEC(MID$(color$, 6, 2)) )
FOR x = 0 TO a STEP 2
s = x * x
p = SQR(b - s)
st=6*ys
FOR i = -p TO p STEP st
r = SQR(s + i * i) /a
q = (r -1.0) * SIN(24 * r)
y = FLOOR(i/3 + q * c)
IF i=-p THEN
m=y
n=y
END IF
IF y > m THEN m = y
IF y < n THEN n = y
IF m = y OR n = y THEN
cairo_rectangle(cr, (double)-x+500, (double)y+500,2.0, 2.0)
cairo_fill(cr)
cairo_rectangle(cr, (double)x+500,(double)y+500,2.0, 2.0)
cairo_fill(cr)
END IF
NEXT
NEXT
cairo_surface_flush(cs)
pixels = cairo_image_surface_get_data(cs)
cairo_destroy(cr)
PRINT "Render Time ",TIMER-start , " mSec"
RETURN pixels
END FUNCTION
'@ END FUNCTIONS and SUBS
'--- test the GUI a simple window + find drawable + add rectangle
HEIGHT=500
WIDTH = 500
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
win = elm_win_util_standard_add("UFO-Evas", "UFO-Evas")
elm_win_autodel_set(win, EINA_TRUE)
evas_object_resize(win, WIDTH, HEIGHT)
evas_object_show(win)
'@ find drawable
canvas1 = evas_object_evas_get(win)
' @ create cairo image similar to evas image @ CAIRO_FORMAT_ARGB32
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT)
' @ create the ufo
pixy = UFO(surface)
' @ create evas image to match cairo @ EVAS_COLORSPACE_ARGB8888
img = evas_object_image_filled_add(canvas1)
evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888)
evas_object_image_size_set(img, WIDTH, HEIGHT)
evas_object_image_data_set(img, pixy)
evas_object_resize(img, WIDTH, HEIGHT)
evas_object_show(img)
elm_run()
elm_shutdown()