Windows Universal Menu Bar color - statusbar

I have looked on Windows Universal Apps documentation, but havent found. How to change the Menu Bar color on Universal Apps?
Example: the dark blue MenuBar on Windows 10 Mail App

Change the background color of title bar when the app launched.
code:
void InitializeTitleBar()
{
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
// Title bar colors. Alpha must be 255.
titleBar.BackgroundColor = new Color() { A = 255, R = 22, G = 100, B = 167 };
titleBar.ForegroundColor = new Color() { A = 255, R = 255, G = 255, B = 255 };
titleBar.ButtonBackgroundColor = new Color() { A = 255, R = 22, G = 100, B = 167 };
titleBar.ButtonForegroundColor = new Color() { A = 255, R = 255, G = 255, B = 255 };
}

Related

How to move the image as transparent after erasing background to other screen?

I'm developing a photo editing app, in that I have a feature to add the image to other image as transparent after editing in the app. So I can able to erase the background of the image. But I don't know how to move the background erased image to other screen , like how we do for the normal image. Now if I move the transparent part appeared as grey part. you can see that image. Help me to solve this. Thank you.
[
Canvas(
modifier = drawModifier
.onGloballyPositioned {
capturingViewBounds.value = it.boundsInWindow()
}
) {
val canvasWidth = size.width.roundToInt()
val canvasHeight = size.height.roundToInt()
val width = this.size.width
val height = this.size.height
val checkerWidth = 10.dp.toPx()
val checkerHeight = 10.dp.toPx()
val horizontalSteps = (width / checkerWidth).toInt()
val verticalSteps = (height / checkerHeight).toInt()
for (y in 0..verticalSteps) {
for (x in 0..horizontalSteps) {
val isGrayTile = ((x + y) % 2 == 1)
drawRect(
color = if (isGrayTile) Color.LightGray else Color.White,
topLeft = Offset(x * checkerWidth, y * checkerHeight),
size = Size(checkerWidth, checkerHeight)
)
}
}
val space = 20.dp.roundToPx()
with(drawContext.canvas.nativeCanvas) {
val checkPoint = saveLayer(null, null)
drawImage(
image = dstBitmap,
dstOffset = IntOffset(space / 2, space / 2),
dstSize = IntSize(canvasWidth - space, canvasHeight - space)
)
clipBounds
drawPath(
color = Color.Transparent,
path = erasePath,
style = Stroke(
width = 30f,
cap = StrokeCap.Round,
join = StrokeJoin.Round
),
blendMode = BlendMode.Clear
)
restoreToCount(checkPoint)
}
}

How i can animation or state change inside the Canvas in jetpack compose?

suppose i have simple composable fun which has Canvas.
Canvas(modifier = Modifier
.padding(start = 60.dp, end = 60.dp)
.fillMaxSize(),
onDraw = {
val w = size.width
val h = size.height
val s1LineOffset = w / 4 - 10
val s2LineOffset = w * 3 / 8 - 10
drawImage(
image = ImageBitmap.imageResource(
res = resources,
id = R.drawable.bttn
),
topLeft = Offset(
x = b1StartOffset,
y = 0f
)
)
}
)
I want to define the state of animation using the canvas sizes for initial and target value but i cant do so because i can't use this inside draw scope thats why i have to use it above the Canvas block, hence cant access Canvas size what should i do
val anim by ballAnim.animateFloat(
initialValue = ,
targetValue =,
animationSpec =
)
It is more of a simple job. Just create and remember a MutableState<T> value, then update it inside Canvas. For example,
var canvasSize by remember { mutableStateOf(IntSize()) }
Canvas(modifier = Modifier
.padding(start = 60.dp, end = 60.dp)
.fillMaxSize(),
onDraw = {
canvasSize = size //Assign it here
val w = size.width
val h = size.height
val s1LineOffset = w / 4 - 10
val s2LineOffset = w * 3 / 8 - 10
drawImage(
image = ImageBitmap.imageResource(
res = resources,
id = R.drawable.bttn
),
topLeft = Offset(
x = b1StartOffset,
y = 0f
)
)
}
)
val anim by ballAnim.animateFloat(
initialValue = canvasSize.width,
targetValue = canvasSize.height, //whatever
animationSpec = spring()
)
One of the options is animating some normalized value and denormalizing it using size inside onDraw, e.g.:
val animNormalized by ballAnim.animateFloat(
initialValue = 0.5,
targetValue = 0.8,
animationSpec =
)
Canvas(modifier = Modifier
.padding(start = 60.dp, end = 60.dp)
.fillMaxSize(),
onDraw = {
val w = size.width
val h = size.height
val anim = animNormalized * w
...
}
)

conditional plot shinydashboard

I would like to know why (in the following code) the graph does not display when I click on the checkbox "graph"? Below is an example of the code. I would also want to know if it is possible to do the same thing using a conditionalPanel instead of renderUI?
library(shinydashboard)
library(shiny)
library(plotly)
library(ggplot2)
# Can set box height from environment var
useboxheight <- Sys.getenv("USE_BOX_HEIGHT")
if (tolower(useboxheight) == "true") {
row1height <- 300
row2height <- 240
row3height <- 110
} else {
row1height <- row2height <- row3height <- NULL
}
body <- dashboardBody(
fluidRow(
box(
title = "Box title",
status = "primary",
plotOutput("plot1", height = 240),
height = row1height
),
uiOutput("ui")
),
# Boxes with solid headers
fluidRow(
box(
title = "Title 1", width = 4, solidHeader = TRUE, status = "primary",
height = row2height,
sliderInput("orders", "Orders", min = 1, max = 500, value = 120),
radioButtons("fill", "Fill", inline = TRUE,
c(None = "none", Blue = "blue", Black = "black", red = "red")
)
),
box(
title = "Title 2",
width = 4, solidHeader = TRUE,
height = row2height
),
box(
title = "Title 3",
width = 4, solidHeader = TRUE, status = "warning",
height = row2height,
selectInput("spread", "Spread",
choices = c("0%" = 0, "20%" = 20, "40%" = 40, "60%" = 60, "80%" = 80, "100%" = 100),
selected = "60"
)
)
),
# Solid backgrounds
fluidRow(
box(
width = 4,
height = row3height,
background = "black",
"A box with a solid black background"
),
box(
title = "Title 5",
width = 4,
height = row3height,
background = "light-blue",
"A box with a solid light-blue background"
),
box(
title = "Title 6",
width = 4,
height = row3height,
background = "maroon",
"A box with a solid maroon background"
)
)
)
ui <- dashboardPage(
dashboardHeader(title = "Row layout"),
dashboardSidebar(checkboxGroupInput(inputId="Graph", label = h4("Graph print"),
choices = list("graph" = "graph"),selected = NULL)),
body
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
if (is.null(input$orders) || is.null(input$fill))
return()
data <- histdata[seq(1, input$orders)]
color <- input$fill
if (color == "none")
color <- NULL
hist(data, col = color)
})
output$ui <- renderUI({
check1 <- input$Graph == "graph"
if(length(check1)==0){check1 <- F}
if(check1){
box(
status = "warning",
plotOutput("plot1", height = 240),
height = row1height
)
}
else{return(NULL)}
})
}
shinyApp(ui, server)
Cheers
Dave
I would start my taking a look at what happens underneath the output$plot1 <- renderPlot({ bracket. Be sure that your conditional function is sound.
Same goes for your renderUI code.

Setting SKLabelNode to centre of SKSpriteNode Swift

I'm trying to set a SKLabelNode's position to the center of a SKSpriteNode.
I've looked at other questions on this but none of these work with Swift 3.
This is my code:
var letter1background = SKSpriteNode(imageNamed: "letterbackground")
var letter1text = SKLabelNode()
override func didMove(to view: SKView) {
letter1background.position = CGPoint(x: self.size.width / 8, y: self.size.height / 7.5)
letter1background.size = CGSize(width: self.size.width / 8, height: self.size.width / 8)
letter1background.zPosition = -5
self.addChild(letter1background)
letter1text.text = "C"
letter1text.fontName = "Verdana-Bold "
letter1text.fontSize = 28
letter1text.fontColor = UIColor.white
letter1text.zPosition = 0
letter1text.horizontalAlignmentMode = letter1background.center
letter1text.verticalAlignmentMode = letter1background.center
self.letter1background.addChild(letter1text)
}
This code looks like it would work but in Swift 3 I now get this error:
Value of type 'SKSpriteNode' has no member 'center'
I have also tried:
self.letter1text.position = CGPoint(x: letter1background.frame.width/2 - (letter1text.frame.width/2), y: letter1background.frame.height/2 -(letter1text.frame.height/2))
&
letter1text.position = CGPoint(x:letter1background.frame.midX, y:letter1background.frame.midY)
But I still get results like this:
Any ideas?
Your calculations of label's position are wrong. You just have to add a label to the at 0,0 position and it will be centered because of SpriteKit's coordinate system rules (0,0 is at the center of the node).
override func didMove(to view: SKView) {
let label = SKLabelNode(fontNamed: "Arial")
label.text = "C"
label.fontColor = .black
label.verticalAlignmentMode = .center
label.fontSize = 29.0
label.zPosition = 1
let background = SKSpriteNode(color: .green, size: CGSize(width: 50, height: 50))
background.addChild(label)
addChild(background)
}
And you will get this:

Sk Physics Joint not working properly

I am creating a game and for my character his legs and torso have separate animations so they are separate nodes with separate physics bodies. I am having a lot of trouble linking the torso and the legs together however, linking them is not the problem, keeping them linked is. While moving around sometimes the hero's torso slides off of the legs. Kind of funny but not practical lol. Here is my physics coding
enum BodyType:UInt32 {
case bullet1 = 2
case enemy1 = 4
case enemy2 = 16
case enemy3 = 32
case desertForegroundCase = 64
case tank11 = 128
case tank12 = 256
case tank13 = 512
case tank21 = 1024
case tank22 = 2048
case tank23 = 4056
case tank31 = 8112
case tank32 = 16224
case tank33 = 32448
case cliff1 = 64856
case cliff2 = 129212
case soldierT = 258424
case soldierL = 516848
}
func CreateScene (){
desertBackground.position = CGPoint(x: frame.size.width / 2, y:
frame.size.height / 2)
desertBackground.size = CGSize (width: 1136, height: 640)
desertBackground.zPosition = -5
desertForegroundImage.position = CGPointMake(568, 100)
desertForegroundImage.zPosition = -1
let desertForeground = SKSpriteNode(texture:
desertForegroundTexture, size:CGSize(width: 1136, height: 200))
desertForeground.position = CGPointMake(568, 100)
let desertForegroundBody = SKPhysicsBody(texture:
desertForegroundTexture, size: CGSize(width: 1136, height: 200))
desertForegroundBody.dynamic = false
desertForegroundBody.affectedByGravity = false
desertForegroundBody.allowsRotation = false
desertForegroundBody.categoryBitMask =
BodyType.deserForegroundcase.rawValue
desertForegroundBody.contactTestBitMask = BodyType.enemy1.rawValue
| BodyType.enemy2.rawValue | BodyType.enemy3.rawValue |
BodyType.soldierL.rawValue | BodyType.soldierT.rawValue
desertForeground.physicsBody = desertForegroundBody
desertForeground.zPosition = -1
self.addChild(desertForegroundImage)
self.addChild(desertForeground)
self.addChild(desert gully)
}
func CreateHero (){
soldierLegs.position = CGPoint(x: 405 , y: 139)
soldierLegs.zPosition = 1
soldierLegs.anchorPoint.x = 0.6
soldierLegs.anchorPoint.y = 0.7
let soldierLegsBody:SKPhysicsBody = SKPhysicsBody(rectangleOfSize:
soldierLegs.size)
soldierLegsBody.dynamic = true
soldierLegsBody.affectedByGravity = true
soldierLegsBody.allowsRotation = false
//body.restitution = 0.4
soldierLegsBody.categoryBitMask = BodyType.soldierL.rawValue
soldierLegsBody.contactTestBitMask = BodyType.enemy1.rawValue |
BodyType.enemy2.rawValue | BodyType.enemy3.rawValue |
BodyType.desertForegroundCase.rawValue
soldierLegs.physicsBody = soldierLegsBody
soldierTorso.position = soldierLegs.position
soldierTorso.zPosition = 2
soldierTorso.anchorPoint.x = 0.25
soldierTorso.anchorPoint.y = 0.1
let soldierTorsoBody:SKPhysicsBody = SKPhysicsBody(rectangleOfSize:
soldierTorso.size)
soldierTorsoBody.dynamic = true
soldierTorsoBody.affectedByGravity = true
soldierTorsoBody.allowsRotation = false
soldierTorsoBody.categoryBitMask = BodyType.soldierT.rawValue
soldierTorsoBody.contactTestBitMask = BodyType.enemy1.rawValue |
BodyType.enemy2.rawValue | BodyType.enemy3.rawValue |
BodyType.desertForegroundCase.rawValue
soldierTorso.physicsBody = soldierTorsoBody
let joint =
SKPhysicsJointFixed.jointWithBodyA(soldierLegs.physicsBody!, bodyB:
soldierTorso.physicsBody!, anchor: soldierLegs.position)
self.addChild(soldierTorso)
self.addChild(soldierLegs)
self.physicsWorld.addJoint(joint)
}
That's about how far he will slide off. Is there a way to just code one physics body with 2 separate nodes? or am i just missing a little code? Any help is help, thank you.