(solved) canvas_arc doesn't work on device

Canvas specific discussion
Post Reply
shr3d
Newbie
Posts:10
Joined:30 Jun 2015 12:31
(solved) canvas_arc doesn't work on device

Post by shr3d » 09 Mar 2016 17:46

Hi all,

I have a very odd problem with the canvas_arc function.

I want to draw some circles together with two lines for the axes. While both are shown in the Lemur editor, the circles do not show up on the iPad air device (see attachment). I also tried to change the order of the function call (first draw axes, then the circles), but the circles never show up. What makes it even more strange is the fact that it worked 5 months ago.

Here comes the code.

Code: Select all

decl c = getobject();
decl rect = getobjectrect(c);
decl w = rect[2];
decl h = rect[3];
decl numberCircles = 5;
decl i;
decl radius = w/(2*numberCircles);

canvas_clear(c);
canvas_setStrokeStyle(c,{0.6, 0.6,0.6,0.6});
canvas_setLineWidth(c,2);

for(i = 0;i < numberCircles;i++)
{
	canvas_beginPath(c);
	canvas_arc(c,0.5*w,0.5*h,(radius * i + radius)-2,0,2*pi,2);
	canvas_closePath(c);
	canvas_stroke(c);
}

canvas_beginPath(c);
canvas_rect(c,0,0.5*h,w,1);
canvas_rect(c,0.5*w,0,1,h);
canvas_closePath(c);
canvas_stroke(c);

Any idea?

Thanks and best,
Dirk
canvas_arc_problem_small.jpg
Screenshot, iPad above, Editor below
canvas_arc_problem_small.jpg (135.15KiB)Viewed 13287 times
Last edited by shr3d on 09 Mar 2016 22:13, edited 1 time in total.

ndivuyo
Regular
Posts:279
Joined:23 May 2014 00:24

Re: canvas_arc doesn't work on device

Post by ndivuyo » 09 Mar 2016 21:05

Hard to say without seeing the project. Maybe double/triple check that the canvas is being refresh appropriately, unless is it always refreshing?

shr3d
Newbie
Posts:10
Joined:30 Jun 2015 12:31

Re: canvas_arc doesn't work on device

Post by shr3d » 09 Mar 2016 21:19

The code above is the complete function that is called on redraw to paint both the circles and the axes. The axes are shown, the circles not - which makes it so strange. Everything is drawn correctly in the Lemur editor, but when I upload it to the iPad, the circles are missing.

I actually wrote the app 5 months ago and everything was working correctly. I started to work on other stuff, but wanted to expand this app today and was very surprised when suddenly the cirles were missing. At the moment I'm wondering if it perhaps relates to an iOS update and that the function is missinterpreted now. I didn't check it on another device so far, but that's perhaps something to look into (but it would be quite frustrating if this is really the case :-/ )

shr3d
Newbie
Posts:10
Joined:30 Jun 2015 12:31

Re: canvas_arc doesn't work on device

Post by shr3d » 09 Mar 2016 21:41

whoop whoop. Problem solved.

I have changed the last parameter from 2 to 0, i.e.
canvas_arc(c,0.5*w,0.5*h,(radius * i + radius)-2,0,2*pi,0);

The API says however:
canvas_arc(c, x, y, r, start, end, ccw)
Create an Arc of center (x,y), radius r, from start to end in radians, couter-clockwise if ccw is 1, clockwise otherwise, and either connect it to the last point of the last Subpath, or in a new Subpath if none already exists
So, ccw is boolean and only 0 or 1 are accepted. Makes perfect sense and I'm wondering why I entered a 2 there (makes only little sense :) ). However, it would be nice to add this to the manual.

But isn't it strange then that it worked in the first place with the 2 as ccw parameter? And why is it shown correctly in the Lemur editor???

Anyway, happy that it works now!

Post Reply