Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - sf-in-sf

#21
This prints 256 squares. Look which ones are dithered or not, the repeating patterns. A repeat every 4 means 6 bits for that channel, every 8 means 5 bits for the physical screen. click/touch to change the channels.
My android Archos tablet 10.1 G9 does rgb666, so 18 bits altogether.

Code (glbasic) Select
// --------------------------------- //
// Project: bands
// Start: Friday, January 11, 2013
// IDE Version: 10.244


// SETCURRENTDIR("Media") // go to media files

SETSCREEN 320,480,0
//LIMITFPS 2

GLOBAL hue% =1 // 1->7 only.

WHILE TRUE
plot(hue)
PRINT hue, 150,30
SHOWSCREEN
GOSUB changecolor
WEND
END // (?)

FUNCTION plot: hue%
LOCAL r%, g%, b%
LOCAL shade%, color%, t$
r=bAND(hue, 0x001)
g=bAND(hue, 2)
IF g>0 THEN g=1
b=bAND(hue, 4)
IF b>0 THEN b=1

FOR i% = 0 TO 7 // 8 columns.

// 256/8 = 32 -> 32 rows.
FOR j% =0 TO 31
shade = i*32 +j // like a memory linear position
// from a n-dimension table

color= RGB(r*shade, g*shade, b*shade)
DRAWRECT i*40,j*15,38,15, color

NEXT
NEXT

t$="R:"+r+"   G:"+g+"   b:"+b
PRINT t$, 150,60
ENDFUNCTION

SUB changecolor:
LOCAL mx%, my%, b1%, b2%
REPEAT
HIBERNATE
MOUSESTATE mx,my,b1,b2
UNTIL b1+b2 >0 // click down
REPEAT
HIBERNATE
MOUSESTATE mx,my,b1,b2
UNTIL b1+b2 =0 // click released
INC hue, 1
IF hue >7 THEN hue=1
ENDSUB
//
// P.S.
//How TO use your own icons FOR android:
//1) clean project, "trash" icon.
//2) remove all types of icons IN project folder.
//3) IF you want the white frame, put there "icon.png"
// IF you don't want it put there the same image,
// with name "androidicon.png"
// The image must be PNG format, 72x72.
// [PNG is great FOR transparency AND other things]
//4) Rebuild FOR android, AND voila.

#22
I'd like to share my 3 useful functions. Enjoy and experiment!
More on my artistic experimental programming: google 'artist F.P. Brixey saatchionline'. NEW: my collection is visible on deviant art.

Code (glbasic) Select

// --------------------------------- //
// Project: circle1
// Start: Sunday, February 03, 2013
// IDE Version: 10.244


// SETCURRENTDIR("Media") // go to media files
GLOBAL scrx%=666, scry%=666 //your custom size.
// For PC use menu;project;options;win32
GETSCREENSIZE scrx, scry
SETSCREEN scrx,scry,0    // Size matters.
CREATESCREEN 1,1,scrx,scry
// the drawing surface.
GLOBAL cnt%
//****************************************************
WHILE TRUE
//press F12 to view long lines of code.
LOCAL alpha=(RND(1999)/1000.0 -1.0)+0.00000003
// additive when >0
// interpolated when <0, ='mix' ='cross-fade'
// ...in my opinion.
LOCAL color%=RGB(128*RND(2)-1,128*RND(2)-1,128*RND(2)-1)
LOCAL smoothedge = 1.5+9*RND(2)
LOCAL thickness=1.5+11*RND(3)
// USESCREEN 1

IF RND(1) >0
drawdisc2(RND(scrx), RND(scry), 4+RND(300), color, alpha, smoothedge)   // yes smoothing.
ELSE
drawcircle2_(RND(scrx), RND(scry), 4+RND(300), thickness,color, alpha, smoothedge)   // yes smoothing.
ENDIF
//drawdisc1(RND(scrx), RND(scry), 4+RND(300), color, alpha) // no smoothing. // unused.

//USEASBMP // optional
USESCREEN -1
ALPHAMODE -1
DRAWSPRITE 1,0,0
SHOWSCREEN
INC cnt,1
IF cnt >4
cnt=0
SEEDRND (GETTIMERALL()) //shuffle the cards.
ENDIF

//FOR more clarity:
DEBUG alpha ; DEBUG "\n"
// please activate the 'bug' icon
// SLEEP 2012 // additional time

SLEEP 800 +RND(3333)
//SLEEP 787// Merry dream, liner!
WEND
//****************************************************


FUNCTION drawdisc1:cx%,cy%,r%,col%,a //raw shape
// a fast function with no blending.
//would be nearly 4x faster using symetry, working on just 1/4circle.
LOCAL r2% = r*r
USESCREEN 1
//Only plot within the screen to save time:
LOCAL bx1%=cx-r
IF bx1 <0 THEN bx1=0
LOCAL by1%=cy-r
IF by1 <0 THEN by1=0
LOCAL bx2%=cx+r
IF bx2 >scrx THEN bx2=scrx
LOCAL by2%=cy+r
IF by2 >scry THEN by2=scry

ALPHAMODE a // same speed for a=0, a=-1, strangely. Any suggestion for more speed?

FOR x%=bx1 TO bx2
FOR y%=by1 TO by2
IF (x-cx)*(x-cx) +(y-cy)*(y-cy) <= r2 THEN SETPIXEL x,y,col
NEXT
NEXT
ENDFUNCTION

// On the day the atom is a cube I will start believing in the square pixel.

FUNCTION drawdisc2: cx,cy,r,col%,a,smoo //smoothed.
// Basic values are a=-1, smoo=1.
// N.B. a= -1...+1 but a=0 cancels the smoothing.
//   (if trouble try a permanent "INC a, 0.00000000000000042")
// Higher smoo values blur the edges. (Do try it at home!)
// Smoothing is symetrical across the circle position:
// blurring goes both inwards and outwards. It is done in a quick
// way as it doesn't calculate SQR(d^2), using directly the r^2
// values for interpolation. Not as nice as a proper bicubic one.
// Just feel free to try your own way to interpolate the alpha
// value for a nicer smoothing/halo.
USESCREEN 1
IF smoo <0 THEN smoo =0
LOCAL halfsmoo =smoo*0.5
LOCAL r2  = (r-halfsmoo)*(r-halfsmoo) //contracted
LOCAL r2_ = (r+halfsmoo)*(r+halfsmoo) //expanded
LOCAL d2
LOCAL w=r2_ -r2

//Only plot within the screen to save time:
LOCAL bx1%=cx-r-halfsmoo
IF bx1 <0 THEN bx1=0
LOCAL by1%=cy-r-halfsmoo
IF by1 <0 THEN by1=0
LOCAL bx2%=cx+r+halfsmoo
IF bx2 >scrx THEN bx2=scrx
LOCAL by2%=cy+r+halfsmoo
IF by2 >scry THEN by2=scry


FOR x%=bx1 TO bx2
FOR y%=by1 TO by2

d2=(x-cx)*(x-cx) +(y-cy)*(y-cy)
IF d2 <= r2
ALPHAMODE a
SETPIXEL x,y,col
ELSEIF d2 >= r2_
// leave it alone.
ELSE
//interpolation:
ALPHAMODE (r2_ -d2)*a/w
SETPIXEL x,y,col
ENDIF
NEXT
NEXT
ENDFUNCTION

// On the day the atom is a cube I will start believing in the square pixel.

FUNCTION drawcircle2_: cx,cy,r,thick,col%,a,smoo //smoothed.
// Same principle as drawdisc2( .
// using the real r value instead of r*r looks nicer but takes longer.
// This interpolation is linear but I believe a 'S' shape would
// be perfect. Also keep in mind that only an alpha interpolation is
// NOT enough; at the same time you should also interpolate the
// color into the next area. (Yes it's a bit bizarre.)
USESCREEN 1
IF smoo <0 THEN smoo =0
LOCAL halfsmoo =smoo*0.5
LOCAL th =thick*0.5
LOCAL ra  = (r+halfsmoo+th)
LOCAL ra2  = (r+halfsmoo+th)*(r+halfsmoo+th) //outermost
LOCAL rb2  = (r+th)*(r+th) //
LOCAL rc2  = (r-th)*(r-th) //
LOCAL rd2  = (r-th-halfsmoo)*(r-th-halfsmoo) //innermost
LOCAL rd  = (r-th-halfsmoo)

LOCAL d2
LOCAL r2 =r*r
LOCAL w_out =ra-(r+th) +0.000001//r2_ -r2
LOCAL w_in  =(r-th)-rd +0.000001

//Only plot within the screen to save time:
LOCAL bx1%=cx-r-halfsmoo-th
IF bx1 <0 THEN bx1=0
LOCAL by1%=cy-r-halfsmoo-th
IF by1 <0 THEN by1=0
LOCAL bx2%=cx+r+halfsmoo+th
IF bx2 >scrx THEN bx2=scrx
LOCAL by2%=cy+r+halfsmoo+th
IF by2 >scry THEN by2=scry


FOR x%=bx1 TO bx2
FOR y%=by1 TO by2

d2=(x-cx)*(x-cx) +(y-cy)*(y-cy) //distance to center
IF d2 <= r2 //internal

IF d2 >= rc2
//plot it plain.
ALPHAMODE a
SETPIXEL x,y,col
ELSEIF d2 <=  rd2
// ignore it
ELSE
// interpolate, blend it.
ALPHAMODE (SQR(d2) -rd)*a/w_in
SETPIXEL x,y,col
ENDIF
ELSE //external

IF d2 < rb2
//plot it plain.
ALPHAMODE a
SETPIXEL x,y,col
ELSEIF d2 >=  ra2
// ignore it
ELSE
// interpolate, blend it.
ALPHAMODE (ra -SQR(d2))*a/w_out
SETPIXEL x,y,col
ENDIF
ENDIF
NEXT
NEXT
ENDFUNCTION

//__________________________________________________________________________________

// P.S. On the day the atom is a cube I will start believing in the square pixel.

#23
Code (glbasic) Select

// --------------------------------- //
// Project: objtestA0
// Start: Thursday, November 29, 2012
// IDE Version: 10.244


// SETCURRENTDIR("Media") // go to media files
SETSCREEN 400,400,0
LIMITFPS 25
mymain() // call your own 'main Function' here.



//____________________________________
// quit GLb's main function like this:
FUNCTION foo:
// keep it empty.
ENDFUNCTION



//LOCAL z%
// this 'z' declaration doesn't work here any more,
// because it's outside a function.
INLINE

class Koto{
public:
int fish;
Koto(){}; // constructor
~Koto(){}; // destructor
void ppprint()
{ for (int z=3; z<=13; z++)
{ PRINT( z, 30+2*z,25*z);
PRINT( z+2, 60+2*z,25*z);
}

// F***
// // //ENDINLIN* // ADDING THE 'E' => ERROR.
// although it's printed in yellow like a comment.
// it's a 7-leg bug.
// INLINE ... is ignored properly.

/*
F***
other out-comments work o.k. otherwise.
*/

};
protected:
private: // ad libitum

};
ENDINLINE




FUNCTION mymain:
INLINE
Koto k; // instanciation.
k.ppprint(); // run the Fn.
ENDINLINE

SHOWSCREEN
MOUSEWAIT // please click to quit.
END

ENDFUNCTION // it works fine.

#24
How is it possible?   :'( Inside a function, a static variable has useful properties but how can DIM or DIMDATA be used only once to define the array size -typical for static variables-, when they must be located inside the function? Is it possible to locate them outside the function, and be called only once so the values of the array remain STATIC? Or must all arrays be only GLOBAL or LOCAL?

One more array trouble: when i pause the program to debug, only the 1st element var[0] shows a realistic value in the debug window. Did i miss an update?

Thanks everyone!
#25
Hi!
Someone already asked how to open a web browser with given url in iOS.
I have the same question for android.
Here are some guidelines, but they are written in java:
Code (glbasic) Select
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

or:
Code (glbasic) Select
startActivity(new Intent(Intent.ACTION_VIEW,
    Uri.parse("http://www.google.com")));

(http://stackoverflow.com/questions/3004515/android-sending-an-intent-to-browser-to-open-specific-url)
How can we adapt that for some C inline code in GLbasic?
Many thanks in advance!
#26
Help! What is wrong with my configuration? (win7 + Xubuntu on asus A53SV, archos android tablet 101G9)

The android SDK looks like it's installed o.k. since i get my pgm compiled.  =D
The tablet looks like it is installed o.k. as i can transfer ...\distribute\Android\bin\*name*-glbasic-debug-unaligned.apk into the tablet's directory "Computer\ARCHOS 101G9\Internal Storage\Download"   and then install and run it.  :happy:
(it's the only *.apk file that can be installed o.k. inside the tablet)  :S

By running AVD i get my 3 versions of android o.s. running ok inside the simulator.
However when AVD is open and running, compiling for android in GLbasic doesn't install and run the pgm in the simulator, as described in the help files.
(MoSync did it... if you have the patience to use the tedious C++)  :sick:

:zzz: At command prompt i type "adb devices" and get the reply:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached

[2 empty lines]
C:\Users\Ra>_

// then//
"adb usb" replies:
error: device not found  :blink:

I tried to update the tablet driver:
computer Rclick -> computer management -> device manager -> portable devices -> archos 101G9
list of driver files:
...system32\DRIVERS\UMDF\WpdMtpDr.dll
...system32\DRIVERS\winusb.sys
...system32\DRIVERS\WUDFRd.sys
...system32\WpdMtp.dll
...system32\WpdMtpUS.dll   :glare:

Win7 doesn't allow me to update to the manufacturer's driver that contains
android_winusb.inf
WdfCoInstaller01009.dll
winusbcoinstaller2.dll
WUDFUpdate_01009.dll
   ...saying the installed drivers are already up-to-date.
Should i force do it manually?  :whip:

As Archos says, i added the line
echo 0x0e79 >> "%USERPROFILE%\.android\adb_usb.ini"
in c:\Users\Ra\.android\adb_usb.ini
without results.  :(

I can see two "BUILD FAILED" message in the ouput console (is it bad Doctor?):
Quote____________________________________
*** Configuration: ANDROID ***
precompiling:
GPC - GLBasic Precompiler V.10.104 SN:cc8796c9 - 3D, NET
Wordcount:1139 commands
compile+link:
running Android build-script...
BUILD STAGE 1: Compile and pack RELEASE
     [echo] Gathering info for glbasic...
     [echo] Creating output directories if needed...
     [echo] ----------
     [echo] Handling aidl files...
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...

BUILD FAILED
Q:\Compiler\platform\android\android-sdk-windows\tools\ant\build.xml:539: The following error occurred while executing this line:
Q:\Compiler\platform\android\android-sdk-windows\tools\ant\build.xml:568: null returned: 1

Total time: 2 seconds
.
BUILD STAGE 2: Build DEBUG and install on device
     [echo] Gathering info for glbasic...
     [echo] Creating output directories if needed...
     [echo] ----------
     [echo] Handling aidl files...
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...

BUILD FAILED
Q:\Compiler\platform\android\android-sdk-windows\tools\ant\build.xml:539: The following error occurred while executing this line:
Q:\Compiler\platform\android\android-sdk-windows\tools\ant\build.xml:568: null returned: 1

Total time: 2 seconds
finished Android build-script.
Android=C:\Users\Ra\Myfuk-GLbasic\GLBasic\GLBasic\AppName004\distribute\Android
success
_______________________________________
*** Finished ***
Elapsed: 17.9 sec. Time: 04:29
Build: 1 succeeded.
:whistle:

Here is a useful link to archos:
http://www.archos.com/support/support_tech/updates_adb.html?country=ws&lang=en

Finally the pictures used for sprites in GLb' are placed in the app folder and loaded o.k.  :-* (hope the transparency will be fine).
On the local machine the program works  :coke:. When i transfer it (manually) into the tablet, all the images/sprites appear as a white square instead.
I couldn't find where to place the images for them to be included in the apk file. Anyone with some experience there?

Many thanks in advance,  <3

   sf-in-sf