Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import androidx.annotation.DrawableRes
import androidx.ink.brush.ExperimentalInkCustomBrushApi
import androidx.ink.brush.TextureBitmapStore
import com.example.cahier.R
import dagger.hilt.android.qualifiers.ApplicationContext
Expand All @@ -31,7 +30,6 @@ import kotlinx.coroutines.flow.update
import javax.inject.Inject
import javax.inject.Singleton

@OptIn(ExperimentalInkCustomBrushApi::class)
@Singleton
class CahierTextureBitmapStore @Inject constructor(@ApplicationContext context: Context) :
TextureBitmapStore {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.ink.brush.Brush
import androidx.ink.brush.ExperimentalInkCustomBrushApi
import androidx.ink.brush.StockBrushes
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.example.cahier.R
Expand All @@ -95,7 +94,6 @@ import ink.proto.BrushTip as ProtoBrushTip
ExperimentalMaterial3Api::class,
ExperimentalMaterial3WindowSizeClassApi::class,
ExperimentalMaterial3AdaptiveApi::class,
ExperimentalInkCustomBrushApi::class
)
@Composable
fun BrushDesignerScreen(
Expand Down Expand Up @@ -267,7 +265,7 @@ fun BrushDesignerScreen(
* Note: Still accepts ViewModel for delegation to tab content and input model
* sections. All state (activeProto, selectedCoatIndex) is hoisted from the screen.
*/
@OptIn(ExperimentalInkCustomBrushApi::class, ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ControlsPane(
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.ink.brush.Brush
import androidx.ink.brush.ExperimentalInkCustomBrushApi
import androidx.ink.rendering.android.canvas.CanvasStrokeRenderer
import androidx.ink.strokes.Stroke
import com.example.cahier.R
Expand All @@ -72,7 +71,6 @@ import ink.proto.BrushFamily as ProtoBrushFamily
*
* Stateless: receives all state and callbacks, does not access ViewModel.
*/
@OptIn(ExperimentalInkCustomBrushApi::class)
@Composable
internal fun PreviewPane(
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.ink.brush.Brush
import androidx.ink.brush.ExperimentalInkCustomBrushApi
import com.example.cahier.R
import ink.proto.BrushTip as ProtoBrushTip

Expand All @@ -46,7 +45,6 @@ import ink.proto.BrushTip as ProtoBrushTip
*
* Stateless: receives data and callbacks, does not access ViewModel.
*/
@OptIn(ExperimentalInkCustomBrushApi::class)
@Composable
internal fun TipShapeTabContent(
currentTip: ProtoBrushTip,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import android.net.Uri
import androidx.compose.ui.graphics.Color
import androidx.ink.brush.Brush
import androidx.ink.brush.BrushFamily
import androidx.ink.brush.ExperimentalInkCustomBrushApi
import androidx.ink.brush.Version
import androidx.ink.brush.compose.createWithComposeColor
import androidx.ink.storage.decode
Expand Down Expand Up @@ -65,7 +64,7 @@ import ink.proto.BrushFamily as ProtoBrushFamily
import ink.proto.BrushPaint as ProtoBrushPaint
import ink.proto.BrushTip as ProtoBrushTip

@OptIn(ExperimentalInkCustomBrushApi::class, FlowPreview::class)
@OptIn(FlowPreview::class)
@HiltViewModel
class BrushDesignerViewModel @Inject constructor(
@param:ApplicationContext private val context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(androidx.ink.brush.ExperimentalInkCustomBrushApi::class)

package com.example.cahier.developer.brushgraph.ui

Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
/*
* Copyright 2025 Google LLC. All rights reserved.
*
* *
* * * Copyright 2025 Google LLC. All rights reserved.
* * *
* * * Licensed under the Apache License, Version 2.0 (the "License");
* * * you may not use this file except in compliance with the License.
* * * You may obtain a copy of the License at
* * *
* * * http://www.apache.org/licenses/LICENSE-2.0
* * *
* * * Unless required by applicable law or agreed to in writing, software
* * * distributed under the License is distributed on an "AS IS" BASIS,
* * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * * See the License for the specific language governing permissions and
* * * limitations under the License.
* *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.cahier.features.drawing

import android.content.Context
import android.util.Log
import androidx.ink.brush.ExperimentalInkCustomBrushApi
import androidx.ink.brush.Version
import androidx.ink.storage.AndroidBrushFamilySerialization
import com.example.cahier.R
Expand All @@ -40,7 +35,6 @@ object CustomBrushes {
}
}

@OptIn(ExperimentalInkCustomBrushApi::class)
private fun loadCustomBrushes(
context: Context,
textureStore: CahierTextureBitmapStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import androidx.core.graphics.createBitmap
import androidx.core.net.toUri
import androidx.ink.brush.Brush
import androidx.ink.brush.BrushFamily
import androidx.ink.brush.ExperimentalInkCustomBrushApi
import androidx.ink.brush.StockBrushes
import androidx.ink.brush.Version
import androidx.ink.brush.compose.composeColor
Expand Down Expand Up @@ -92,9 +91,12 @@ class DrawingCanvasViewModel @Inject constructor(

private val currentNightMode = AppCompatDelegate.getDefaultNightMode()

private val heartHighlighter = StockBrushes.emojiHighlighter("emoji-heart", showMiniEmojiTrail = true)
private val poopHighlighter = StockBrushes.emojiHighlighter("emoji-poop", showMiniEmojiTrail = true)
private val starHighlighter = StockBrushes.emojiHighlighter("emoji-star", showMiniEmojiTrail = true)
private val heartHighlighter =
StockBrushes.emojiHighlighter("emoji-heart", showMiniEmojiTrail = true)
private val poopHighlighter =
StockBrushes.emojiHighlighter("emoji-poop", showMiniEmojiTrail = true)
private val starHighlighter =
StockBrushes.emojiHighlighter("emoji-star", showMiniEmojiTrail = true)
private val highlighter = StockBrushes.highlighter()

private val _defaultBrush = MutableStateFlow(
Expand Down Expand Up @@ -382,7 +384,7 @@ class DrawingCanvasViewModel @Inject constructor(
isBrushSelectedInSession = true
_selectedBrush.update { currentBrush ->
val newBrush = currentBrush.copy(family = brushFamily)
val colorToApply = when(newBrush.family) {
val colorToApply = when (newBrush.family) {
highlighter -> newBrush.composeColor.copy(alpha = HIGHLIGHTER_ALPHA)
heartHighlighter -> Color(0xFFFF45CA).copy(alpha = HIGHLIGHTER_ALPHA)
poopHighlighter -> Color(0xFF783013).copy(alpha = HIGHLIGHTER_ALPHA)
Expand All @@ -397,7 +399,7 @@ class DrawingCanvasViewModel @Inject constructor(
isBrushSelectedInSession = true
_selectedBrush.update { currentBrush ->
val newBrush = currentBrush.copy(family = brushFamily, size = size)
val colorToApply = when(newBrush.family) {
val colorToApply = when (newBrush.family) {
highlighter -> newBrush.composeColor.copy(alpha = HIGHLIGHTER_ALPHA)
heartHighlighter -> Color(0xFFFF45CA).copy(alpha = HIGHLIGHTER_ALPHA)
poopHighlighter -> Color(0xFF783013).copy(alpha = HIGHLIGHTER_ALPHA)
Expand All @@ -411,12 +413,14 @@ class DrawingCanvasViewModel @Inject constructor(
fun changeBrushColor(color: Color) {
isBrushSelectedInSession = true
_selectedBrush.update { currentBrush ->
val colorToApply = when(currentBrush.family) {
val colorToApply = when (currentBrush.family) {
heartHighlighter,
poopHighlighter,
starHighlighter,
highlighter -> color.copy(alpha = HIGHLIGHTER_ALPHA)
else -> color.copy(alpha = 1f)
highlighter,
-> color.copy(alpha = HIGHLIGHTER_ALPHA)

else -> color.copy(alpha = 1f)
}
currentBrush.copyWithComposeColor(color = colorToApply)
}
Expand Down Expand Up @@ -467,7 +471,6 @@ class DrawingCanvasViewModel @Inject constructor(
return _selectedBrush.value
}

@OptIn(ExperimentalInkCustomBrushApi::class)
suspend fun saveCurrentBrushToAutosave() {
withContext(Dispatchers.IO) {
try {
Expand All @@ -491,7 +494,6 @@ class DrawingCanvasViewModel @Inject constructor(
}
}

@OptIn(ExperimentalInkCustomBrushApi::class)
private fun loadCustomBrushes() {
viewModelScope.launch(Dispatchers.IO) {
val builtInBrushes = CustomBrushes.getBrushes(context, textureStore)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ coilCompose = "3.4.0"
foundation = "1.10.5"
hiltAndroid = "2.59.2"
hiltNavigationCompose = "1.3.0"
ink = "1.1.0-alpha02"
ink = "1.1.0-alpha03"
kotlin = "2.3.20"
coreKtx = "1.18.0"
junit = "4.13.2"
Expand Down
16 changes: 15 additions & 1 deletion ink-proto/src/main/proto/brush_family.proto
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ message BrushPaint {
// (self overlap is discarded). More complex examples may involve color or
// opacity variations (e.g. with
// `BrushBehavior::Target::HUE_OFFSET_IN_RADIANS`), or complex textures (e.g.
// with `TextureMapping::kStamping`).
// with `BrushPaint::StampingTexture`).
enum SelfOverlap {
SELF_OVERLAP_UNSPECIFIED = 0 [(ink.proto.enum_value_min_version) = 0];
SELF_OVERLAP_ANY = 1 [(ink.proto.enum_value_min_version) = 0];
Expand Down Expand Up @@ -1349,8 +1349,22 @@ message ColorFunction {
option (ink.proto.message_min_version) = 0;

oneof function {
// Applies a multiplier to the color's opacity. The multiplier must be
// finite and nonnegative. Typical multiplier values range between 0 and 1.
float opacity_multiplier = 1 [(ink.proto.field_min_version) = 0];
// Ignores the original color and replaces it with a fixed color.
Color replace_color = 2 [(ink.proto.field_min_version) = 0];
// Applies an additive offset to the color's hue angle. The offset angle
// must be finite, but can be positive or negative (or zero).
float hue_offset_radians = 3 [(ink.proto.field_min_version) = 2147483647];
// Applies a multiplier to the color's saturation. The multiplier must be
// finite and nonnegative. Typical multiplier values range between 0 and 1.
float saturation_multiplier = 4
[(ink.proto.field_min_version) = 2147483647];
// Applies an additive offset to the color's luminosity. The offset must be
// finite, but can be positive or negative (or zero). Typical offset values
// range between -1 and 1.
float luminosity_offset = 5 [(ink.proto.field_min_version) = 2147483647];
}
}

Expand Down
Loading