I have an activity (mainGame.kt and xml) with buttons. When a button is clicked a variable is decreased. From initialized with 2100 to 0.
And I have a CustomView with a Canvas to draw a circle. The layout from the CustomView is in the mainGame.xml.
The CustomView has its own customView.kt. With in the CustomView.kt is an onDraw Method for drawing the circle.
How can I get the actual value from the variable from the mainGame.kt and use in my CustomView to reduce the diameter from the circle?
I have tried to get the variable with: val circleDia = MainGame().circleDiameter.
But I always get the initialized value, not the value at "runtim".
I created a canvas and specified the height using (width, height), but when it comes to the GUI, it doesn't change the size at all.
atEdit=Frame(Attend,borderwidth=0)
atEdit.grid(row=2,column=0,columnspan=5,sticky='news',pady=(0,10),padx=10)
scrollbar = Scrollbar(atEdit)
scrollbar.grid(row=0,column=5,sticky='ns')
canvas = Canvas(atEdit,bg='black',height=20)
canvas.grid(row=0,column=0,columnspan=5,sticky='news')
scrollbar.config(command = canvas.yview)
left = Frame(canvas,borderwidth=0,bg='#dbdbdb',height=2)
left.grid(row=0,column=0,sticky='news')
right=Frame(canvas,borderwidth=0,bg='white',height=2)
right.grid(row=0,column=1,columnspan=4,sticky='news')
left.bind('<Configure>',lambda event,canvas=canvas:self.onFrameConfigure(canvas))
right.bind('<Configure>',lambda event,canvas=canvas:self.onFrameConfigure(canvas))
I add labels to the 'left' and 'right', which increases the size of the frames, but it shouldn't grow larger than the specified size. Is there anyway to make the canvas a fixed size, even if I add more labels to it, and be able to scroll through it using the scrollbar?
def onFrameConfigure(self,canvas):
canvas.configure(scrollregion=canvas.bbox("all"))
Everytime i refresh my page, i get this error in the console
Uncaught Error: Invalid dimensions for plot, width = 335, height = 0
The pie chart loads the first time, but on refresh, it throws this error and does not appear.
Any suggestions /solutions ?
Thanks
You probably forgot to specify the height for the div holder of the graph.
<div id="myGraph" style="height:500px;"></div>
This will probably solve your issue. :)
I am drawing a PDF page into a CGContext.
In order to properly draw it, I am applying some transformations to the context.
The pdf page rendered rect is smaller than the view's rect.
I want to create a third view that has exact same frame as the part of the view that has a pdf rendered.
My solution works, but not entirely. Sometimes (a lot of times) the rect is wrong.
This is what I am doing:
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context {
CGContextSaveGState(context);
// apply transforms to context
// draw pdf page
CGRect calculatedFromRect = CGRectApplyAffineTransform(pageRect, CGContextGetCTM(context));
CGContextRestoreGState(context);
// now draw a green rect to test the frame on a not transformed context
GContextSetFillColorWithColor(context, [UIColor greenColor].CGColor);
CGContextFillRect(context, calculatedFromRect);
self.thirdView.frame = calculatedFromRect;
}
The thirdView is red. When both rects (view and drawing) are equal, I see a brown rect on the screen (red with alpha on top of the green rect). But sometimes I can see they two separated from each other (offset and size difference...when this happens, the thirdView.frame is bigger than calcularedRect).
Since all the involved views have the same size and coordinates, not converting the coordinates with convertRect:fromView: shouldn't be a problem. But I tried this and the result was the same.
I want to get the height and width of the screen which I could draw objects on. It's the space which is other than the the MenuBar (the footer containing commands) and other than the TitleBar.
TIP: I know that Display.getInstance().getDisplayHeight() returns the height of the screen but this is for the full sceen. So how could I, at least, know the height of the MenuBar and TitleBar to substract them from this height ?
I found the answer for those who are interested:
To get the height of TitleBar: Form.getTitleComponent().getPreferredH()
To get the height of AddressBar: Form.getSoftButton(0).getParent().getPreferredH()
So the answer of my question is:
Display.getInstance().getDisplayHeight()
- form.getTitleComponent().getPreferredH()
- (getSoftbuttonCount() < 1) ? 0 : form.getSoftButton(0).getParent().getPreferredH()