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

Messages - sf-in-sf

#61
Quote from: erico on 2013-Apr-18
I lost my mind :giveup:

Really amazing stuff!
No, Dude. The song states clearly "I lost my head, oh it wasn't easy". You MUST listen to this brilliant song by Gentle Giant. Enjoy!
#62
Thanks guys. See the last update I just posted, switch to the other 2 lines x= and y=.
#63
Hi! Here is a rough template to draw all sorts of stars, flowers, etc. Try, look, tweak, have fun!
Nightly EDIT:
drawthistle (outcommented) is an invitation to experiment. I'm surprised that 2 different functions for x and y still works. For non-integer multiples of beta, the thistle doesn't loop on itself in the worse case -nothing terrible.
Sorry, I haven't tried MEM2SPRITE yet, in the hope the plotting goes faster. Please let me know if anyone gets good results.
Code (glbasic) Select
// --------------------------------- //
// Project: cog_A1
// Start: Tuesday, May 07, 2013
// IDE Version: 10.244

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

SYSTEMPOINTER TRUE
GLOBAL scrx%=666, scry%=666 //your custom size please.
// For PC use menu;project;options;
GETSCREENSIZE scrx, scry
SETSCREEN scrx,scry,0
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 = 2.0 +13*RND(3)
LOCAL thickness=14*RND(3) // (0 means filled shape)

drawstars_a(RND(scrx), RND(scry), 4+RND(300), thickness, color, alpha, smoothedge,5+RND(7), 0.01+RND(44)*0.01)

USESCREEN -1
ALPHAMODE -1
DRAWSPRITE 1,0,0
SHOWSCREEN
INC cnt,1
IF cnt >7
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 drawstars_a: cx,cy,r,thick,col%,a,smoo,freq%,amp
// adjust the params to make a cog, a flower, some rounded n-gons, a star...
// with some luck I even got an accurate David's star. (freq=6 I guess).
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,d1,x,y,beta,sinbeta,cosbeta
LOCAL r2 =r*r
LOCAL w_out =ra-(r+th) +0.000001//r2_ -r2
LOCAL w_in  =(r-th)-rd +0.000001

FOR xxx=0 TO scrx
FOR yyy=0 TO scry
x=xxx ; y=yyy

d2=(x-cx)*(x-cx) +(y-cy)*(y-cy) //*2.0

IF d2>0
d1=SQR(d2)
cosbeta=(x-cx)/d1
sinbeta=(y-cy)/d1

IF cosbeta >= 0
beta=ASIN(sinbeta) // +90 -> -90
ELSE
beta=180-ASIN(sinbeta)
ENDIF
// IF x=300 ; DEBUG beta ; DEBUG "   \n" ; ENDIF

// Draw star:
x=cx +((x-cx)*(1+amp*SIN(freq*beta)))
y=cy +((y-cy)*(1+amp*SIN(freq*beta))) // wavy lens effect
//or Draw thistle:
//x=cx +((x-cx)*(1+amp*0.5*(SIN(freq*beta)+SIN(freq*beta*2))))
//y=cy +((y-cy)*(1+amp*0.5*(SIN(freq*beta)+SIN(freq*beta*5.42167)+SIN(freq*beta*1.5))))

d2=(x-cx)*(x-cx) +(y-cy)*(y-cy) //again, after lens.
ENDIF


IF d2 <= r2 //internal
IF thick>0
IF d2 >= rc2
//plot it plain.
ALPHAMODE a
SETPIXEL xxx,yyy,col
ELSEIF d2 <=  rd2
// ignore it
ELSE
// interpolate, blend it.
ALPHAMODE (SQR(d2) -rd)*a/w_in
SETPIXEL xxx,yyy,col
ENDIF
ELSE // thick<=0, fill the shape.
ALPHAMODE a
SETPIXEL xxx,yyy,col
ENDIF
ELSE //external

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

// P.S. On the day the atom is a cube I will start believing in the square pixel.
#64
Quote from: MacReeg on 2012-Dec-12
Wurde das Problem mit dem Aufruf der virtuellen Tastatur bei tastaturlosen Android-Tablets oder -Handys (ohne irgendetwas Selbstgebautes verwenden zu müssen) schon angegangen?

Yep, it's happening with my archos tablet 10.1 G9, andro' 4.0
Problems with the virtual keyboard on android:
-only the first letter is allowed an UPPER case (what for? A waste of code)
-long before INPUT is called, right from the beginning of the app, until the end, the keyboard stays visible.  :(
-A white full background appears when INPUT is called, when it's time to type. :doubt: the "typing" function probably uses the broken "grabsprite" from android.
-Nice that kerning=1 does the job when typing,
Code (glbasic) Select
INPUT t$, 10,80,1 but alpha blending (shadows) doesn't work during typing, and
Code (glbasic) Select
ALPHAMODE -1 is refused by android before INPUT.

Any idea anyone? How to slide the keyboard in/out?

I'm on IDE 10.224 ...is it too old?
#65
So useful! So beautiful!
Whaaaaaaaaaaa!   <3
Fantastic, Dude!
#66
Quote from: spacefractal on 2012-Dec-26

Second, the GETJOYX(0), GETJOYY(0), GETJOYZ(0) functions don't seem to work for Android.
They do work for me and I used them a lot. Android 4.0 archos G9 10.1 tablet,  IDE v. 10.244. I get some strange values -0.917 to +0.917 after calibrating the tablet repeatedly, instead of 1.0
What you describe looks like you assign an int variable to the GETJOY... Fn. Try once:
Code (glbasic) Select
static jx# // float or so.
jx = GETJOYX(0)

#67
Quote from: Kitty Hello on 2011-Dec-23
Oh. I forgot that maybe. Will fix with the next update.
Hi gernot!
Which update version do you mean? It doesn't seem to work with IDE version 10.244 and my tablet Archos 10.1 G9, and I need it.
Code (glbasic) Select

FORCEFEEDBACK 1,200,1,1
//FORCEFEEDBACK 0,200,1,1// hope for rumbling.

Could this line be wrong?
Thank you!
#68
I find the alpha plotting too slow. To go fast, we would need to be more direct and use a pointer to the drawing surface memory location. Then the symetry trick would make sense, I think.
I don't know how to do it in practice. In GLb are we allowed to go down to such a low level C procedure? Would android -in java- accept it?
#69
Quote from: backslider on 2013-Mar-22
At the moment I'm developing a pipeline from Blender to GLBasic using the EntitySystem and the main thing is done I think.

Hi backslider!

Is there a way to get any Blender animation export into the ddd format for GLbasic?

I'm busy with my 2D project but would love to introduce some 3D into the next ones. I'm struggling with time and the ddd format.
#70
Hi CW,

Just run a test on 100-10000 pieces in a row, without randomness, with my method then with yours. compare the total time and see.

Addition to drawcircle() : on the line d2= ... you can multiply the x or y part with zz >=1 to see a pseudo ellipse.
I just posted a dedicated drawellipse() Fn. See and have fun!
#71
Read, use, enjoy! (I haven't tried your version yet, Gernot, you've been quicker than me.)
I'm surprised that the plotting with alpha seems to take much longer than the calculations and area scanning.
Any idea to improve that?

Code (glbasic) Select
// --------------------------------- //
// Project: ellipse1
// Start: Saturday, March 16, 2013
// IDE Version: 10.244


// SETCURRENTDIR("Media") // go to media files
// --------------------------------- //
// 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;
GETSCREENSIZE scrx, scry
SETSCREEN scrx,scry,0    // Size matters.
CREATESCREEN 1,1,scrx,scry
// the drawing surface.
GLOBAL cnt%
CONSTANT framing=0.12 // i.e. 12%
//****************************************************
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 = 2.2 +13*RND(3)
LOCAL thickness=3*RND(9) // (0 means filled ellipse, in 2nd Fn).
// USESCREEN 1

//define the x,y of the 2 centers:
GLOBAL c1x%=scrx*framing+RND(scrx*(1-framing-framing))
GLOBAL c2x%=scrx*framing+RND(scrx*(1-framing-framing))
GLOBAL c1y%=scry*framing+RND(scry*(1-framing-framing))
GLOBAL c2y%=scry*framing+RND(scry*(1-framing-framing))
GLOBAL rr_=SQR((c1x-c2x)*(c1x-c2x)+(c1y-c2y)*(c1y-c2y))*(1.03+RND(800)*0.001)
// rr_ is the length of the string stretched between the 2 centers.
// As you draw, keep the string tentioned with the pen.
// Try at home with 2 pins on a piece of cardboard.

IF TRUE //RND(1) >0
// Choose which Fn:
// drawellipse1(c1x,c1y,c2x,c2y,SQR((c1x-c2x)*(c1x-c2x)+(c1y-c2y)*(c1y-c2y))*(1.03+RND(800)*0.001),color, alpha)//, smoothedge)
drawellipse2(c1x,c1y,c2x,c2y,rr_, thickness,color, alpha, smoothedge)
ENDIF

//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 999
WEND
//****************************************************



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


//__________________________________________________________________________________

FUNCTION drawellipse1:c1x%,c1y%,c2x%,c2y%,r%,col%,a //raw, filled shape, fast Fn no smoothing.

LOCAL r2% = r*r //?
LOCAL bx1%,bx2%,by1%,by2%
IF r <SQR((c1x-c2x)*(c1x-c2x)+(c1y-c2y)*(c1y-c2y)) THEN RETURN 0
//impossible to draw, string is too short.
USESCREEN 1

IF c1x >=c2x
bx2 = c2x +r //(approx.)
bx1 = c1x -r
ELSE
bx2 = c1x +r
bx1 = c2x -r
ENDIF
IF c1y >=c2y
by2 = c2y +r
by1 = c1y -r
ELSE
by2 = c1y +r
by1 = c2y -r
ENDIF
ALPHAMODE a
FOR x%=bx1 TO bx2
FOR y%=by1 TO by2

IF SQR((x-c1x)*(x-c1x) +(y-c1y)*(y-c1y)) +SQR((x-c2x)*(x-c2x) +(y-c2y)*(y-c2y)) <= r THEN SETPIXEL x,y,col
NEXT
NEXT
RETURN 1
ENDFUNCTION


FUNCTION drawellipse2:c1x%,c1y%,c2x%,c2y%,r,thick,col%,a,smoo //raw shape

IF r <SQR((c1x-c2x)*(c1x-c2x)+(c1y-c2y)*(c1y-c2y)) THEN RETURN 0
//impossible to draw, string is too short.

IF smoo <0 THEN smoo =0
smoo=smoo*1.8 // approx.correction
LOCAL halfsmoo =smoo*0.5
LOCAL th =thick*0.5
LOCAL smoooo =smoo+smoo
LOCAL rs1 =r+smoooo
LOCAL ra  = (r+halfsmoo+th)
LOCAL rb  = (r+th) //
LOCAL rc  = (r-th) //
LOCAL rd  = (r-th-halfsmoo)

LOCAL d,d2
LOCAL r2 =r*r
LOCAL w_out =ra-(r+th) +0.000001//r2_ -r2
LOCAL w_in  =(r-th)-rd +0.000001
LOCAL w_out_plain =rs1-(r) +0.000001
LOCAL bx1%,by1%,bx2%,by2%
USESCREEN 1


IF c1x >=c2x
bx2 = c2x +r +th +smoooo //(approx.)
bx1 = c1x -r -th -smoooo
ELSE
bx2 = c1x +r +th+smoooo
bx1 = c2x -r -th-smoooo
ENDIF
IF c1y >=c2y
by2 = c2y +r +th+smoooo//(approx.)
by1 = c1y -r -th-smoooo
ELSE
by2 = c1y +r +th+smoooo
by1 = c2y -r -th-smoooo
ENDIF

FOR x%=bx1 TO bx2
FOR y%=by1 TO by2
//FOR x%=0 TO scrx
//FOR y%=0 TO scry
LOCAL d=SQR((x-c1x)*(x-c1x) +(y-c1y)*(y-c1y)) +SQR((x-c2x)*(x-c2x) +(y-c2y)*(y-c2y))
IF thick=0 // elliptic disc
IF d <= r
ALPHAMODE a
SETPIXEL x,y,col //print it plain
ELSEIF d <= rs1 // then interpolate the alpha.
ALPHAMODE (rs1-d)*a/smoooo
SETPIXEL x,y,col

ENDIF
ELSE // outlined ellipse
IF d <= r //internal

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

IF d < rb
//plot it plain.
ALPHAMODE a
SETPIXEL x,y,col
ELSEIF d >=  ra
// ignore it
ELSE
// interpolate, blend it.
ALPHAMODE (ra -d)*a/w_out
SETPIXEL x,y,col
ENDIF
ENDIF
ENDIF

NEXT
NEXT
RETURN 1 // Smooth operation hopefully
ENDFUNCTION

// P.S. On the day the atom is a cube I will believe in the square pixel.
#72



Q:\Compiler\platform\android\android-sdk-windows\tools\ant\build.xml:1114: exec returned: 1

Hi!
Sorry for the late reply.
I got the same problem and usually it's easy to fix.
The battery charging of the device starts and stops when i move the cable, so it's a faulty usb cable.

Other causes for that problem:
-no app icon in the project (some older 3D example projects). -> get a proper one and paste it in the project folder.
-problem when re-installing a fresher version of the same app, with same name. (don't know why). -> manually grab your older app icon on the device, hold for a long time, and slide it to the red thing in order to de-install it. Then rebuild etc.

Check:
-the bottom icons on the device: Connected as a media device, and USB debugging connected.
(allow USB debugging in settings/developer options, on the device).
- that the device remains awake and recognized by your computer during the whole build process. (sometimes the icon disappears for no obvious reason. Keep the "computer" window open to see its contents and your tablet icon.)
-your USB cable... is it as reliable as you think?

In case of doubt you can open a console on your computer and type "adb devices" to see if
your device is installed and recognized o.k. "adb usb"... what does it do, actually?
It's a good idea to install Android Debug Bridge on your machine, if the command "adb" is unknown. Google "adb for windows", i guess.
An alternate way is to transfer ...\distribute\Android\bin\glbasic-release-unsigned.apk into your "documents" inside your device, then go there and click it, and start the installation.
The "3G stick" must be activated on android if you want to use that socket for a usb stick.

Hope this can help. Good luck!
#73
Thanks for the hint, I will try soon.
I use an android tablet Archos 10.1 G9.
I just posted my fresh 16bit dither in the 'snippets'. It reduces banding but adds a bit of noise.
Hope it works o.k. for everyone.
#74

Hi everyone!
This program will nicely dither your images, for mobile apps. Enjoy!
It works in the free demo version of pure basic, a nice IDE though not suited for mobile devices.
Please read and season to taste.

Code (glbasic) Select
; Dither to RGB565 by Artist F.P.Brixey
;Please note: source file must be 32bit PNG with alpha.
;No alpha chanel produces a black image.
;If so, please process your source image:
;GIMP->Layer->transparency->add alpha chanel

InitSprite() : InitKeyboard()
Procedure.c rand_()
    ;write here your favorite hand-crafted chaos generator
  a.c= Random(1)
  a= Random(787) ; (let's shuffle!)
  a=(Random(9955) & $00ff)
  ProcedureReturn a ; type is char, unsigned byte please.
EndProcedure

Procedure.c from8to6(n.c) ; c is char, unsigned byte.
  ; We want to chop and dither the 2 LSB
  ;ProcedureReturn (n & $00fc) ; for special effects?
  n2.c= n & ($00ff-$0003)
  If n2 <$00fc And n & $0003 > rand_() & $0003
    n2=n2+$0004
  EndIf
  ProcedureReturn n2
EndProcedure

Procedure.c from8to5(n.c)
  ; We want to chop and dither the 3 LSB
  ; You get the traditional careless banding by adding here:
  ;ProcedureReturn (n & $00f8) ; for special effects?
  n2.c= n & ($00ff-$0007)
  If n2 <$00f8 And n & $0007 > rand_() & $0007
    n2=n2+$0008
  EndIf
  ProcedureReturn n2
EndProcedure

Procedure show(ima)
scrnum=OpenScreen(1024,768,32,"")
StartDrawing(ScreenOutput())
DrawAlphaImage(ImageID(ima),0,0)
;Box(20,20,40,20,RGB(122,122,255))
StopDrawing()
FlipBuffers()
Repeat
  Delay(80) : ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
CloseScreen() ; was a quick check
EndProcedure

sourcename$=OpenFileRequester("Open a source image (PNG format)","","*.*", 0)
UsePNGImageDecoder()
imnum_src=LoadImage(#PB_Any,sourcename$)
; BMP is default (leave the last argument empty). for other formats, use
;UseJPEGImageDecoder() UseJPEG2000ImageDecoder() UsePNGImageDecoder()
;UseTIFFImageDecoder() UseTGAImageDecoder()

imW=ImageWidth(imnum_src)
imH=ImageHeight(imnum_src)
If imnum_src =0 : MessageRequester ("Problem","Image is not loaded.") : End
EndIf

;show(imnum_src) ; Press escape
imnum_target = CreateImage(#PB_Any,imW,imH,32)

For j=0 To imH-1
  For i=0 To imW-1
    StartDrawing(ImageOutput(imnum_src))
    DrawingMode(#PB_2DDrawing_AllChannels)
    Rp=Red(Point(i,j))
    Gp=Green(Point(i,j))
    Bp=Blue(Point(i,j))
    Ap=Alpha(Point(i,j))
    ; alpha remains unchanged. Up to you.
    StopDrawing()
   
    rr=from8to5(Rp)
    gg=from8to6(Gp)
    bb=from8to5(Bp)
   
    StartDrawing(ImageOutput(imnum_target))
    DrawingMode(#PB_2DDrawing_AllChannels)   
    Plot(i,j,RGBA(rr,gg,bb,Ap)) ; with undithered alpha.
    StopDrawing()
  Next
Next


target$=sourcename$+"_dith565.png" ; change it freely.
; possibly: saveimagerequester(...

UsePNGImageEncoder()
s_i=SaveImage(imnum_target,target$, #PB_ImagePlugin_PNG,0,32) ;
    ;file format is still 32 bits RGBA.

If s_i <>0
  i=MessageRequester("Right", "Image was saved o.k.",#PB_MessageRequester_Ok )
Else
  i=MessageRequester("Sorry", "Image is not saved.",#PB_MessageRequester_Ok )
  End
EndIf

;show(imnum_target) ;now check the result. Reclaim your freedom by pressing 'escape'.
End

#75
Right, spacefractal.
A good design trick is to ban color shades or dither everything down to 16 bits, RGB565, in a clean way. Or at least use directly a 16-bit restricted palette. Transparency can add problems too.

Gernot, I seem to make progress on the subject but I still need your help to succeed.
I found /distribute/Android/src/com/glbasic/test/SDLActivity.java . I wanted to make a short test with other settings but the new ****.java got crushed and automatically re-generated to the original setting. What is the way to change that and introduce new settings?
I wanted to try:
- remove the 4 out-commented lines EGL10.EGL_RED_SIZE, 8 and so on.
- change the next line to EGL10.EGL_DEPTH_SIZE, 32 (or 24)
in the initEGL function, 80% near the end.

Thank you!