-
Notifications
You must be signed in to change notification settings - Fork 55
feat(spx-gui): infer generated sprite defaults for character collision and pivot #3161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cn0809
wants to merge
7
commits into
goplus:dev
Choose a base branch
from
cn0809:issue-2785
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
22fdf8c
refactor flushPendingSeek
cn0809 ae59795
infer generated sprite defaults for character collision and pivot
cn0809 4092e82
always expose sprite pivot settings and gate collision editing
cn0809 7f45edd
show pivot marker on sprite preview node
cn0809 fe693b8
keep sprite node pivot position when rotate or scale
cn0809 0457a13
optimize code
cn0809 81c3c47
pivot marker opacity
cn0809 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
| import type { CircleConfig } from 'konva/lib/shapes/Circle' | ||
| import type { GroupConfig } from 'konva/lib/Group' | ||
| import type { RectConfig } from 'konva/lib/shapes/Rect' | ||
|
|
||
| const props = withDefaults( | ||
| defineProps<{ | ||
| size?: number | ||
| primaryColor: string | ||
| opacity?: number | ||
| showHitArea?: boolean | ||
| }>(), | ||
| { | ||
| size: 16, | ||
| opacity: 1, | ||
| showHitArea: false | ||
| } | ||
| ) | ||
|
|
||
| const markerViewBoxSize = 24 | ||
|
|
||
| const drawingGroupConfig = computed<GroupConfig>(() => { | ||
| const scale = props.size / markerViewBoxSize | ||
| return { | ||
| x: (-markerViewBoxSize / 2) * scale, | ||
| y: (-markerViewBoxSize / 2) * scale, | ||
| scale: { | ||
| x: scale, | ||
| y: scale | ||
| }, | ||
| opacity: props.opacity, | ||
| listening: false | ||
| } | ||
| }) | ||
|
|
||
| const hitConfig = computed<CircleConfig>( | ||
| () => | ||
| ({ | ||
| radius: props.size / 2, | ||
| fill: 'rgba(0, 0, 0, 0.01)' | ||
| }) satisfies CircleConfig | ||
| ) | ||
|
|
||
| const circleConfig = computed<CircleConfig>( | ||
| () => | ||
| ({ | ||
| x: markerViewBoxSize / 2, | ||
| y: markerViewBoxSize / 2, | ||
| radius: 9, | ||
| fill: 'white', | ||
| listening: false | ||
| }) satisfies CircleConfig | ||
| ) | ||
|
|
||
| const outerTabConfigs = computed<RectConfig[]>( | ||
| () => | ||
| [ | ||
| { x: 0, y: 10, width: 4, height: 4, cornerRadius: 2, fill: 'white', listening: false }, | ||
| { x: 20, y: 10, width: 4, height: 4, cornerRadius: 2, fill: 'white', listening: false }, | ||
| { x: 10, y: 0, width: 4, height: 4, cornerRadius: 2, fill: 'white', listening: false }, | ||
| { x: 10, y: 20, width: 4, height: 4, cornerRadius: 2, fill: 'white', listening: false } | ||
| ] satisfies RectConfig[] | ||
| ) | ||
|
|
||
| const innerShapeConfigs = computed<RectConfig[]>( | ||
| () => | ||
| [ | ||
| { x: 1, y: 11, width: 4, height: 2, cornerRadius: 1, fill: props.primaryColor, listening: false }, | ||
| { x: 19, y: 11, width: 4, height: 2, cornerRadius: 1, fill: props.primaryColor, listening: false }, | ||
| { x: 11, y: 1, width: 2, height: 4, cornerRadius: 1, fill: props.primaryColor, listening: false }, | ||
| { x: 11, y: 19, width: 2, height: 4, cornerRadius: 1, fill: props.primaryColor, listening: false }, | ||
| { x: 9, y: 11, width: 6, height: 2, cornerRadius: 1, fill: props.primaryColor, listening: false }, | ||
| { x: 11, y: 9, width: 2, height: 6, cornerRadius: 1, fill: props.primaryColor, listening: false } | ||
| ] satisfies RectConfig[] | ||
| ) | ||
|
|
||
| const ringConfig = computed<CircleConfig>( | ||
| () => | ||
| ({ | ||
| x: markerViewBoxSize / 2, | ||
| y: markerViewBoxSize / 2, | ||
| radius: 7, | ||
| stroke: props.primaryColor, | ||
| strokeWidth: 2, | ||
| listening: false | ||
| }) satisfies CircleConfig | ||
| ) | ||
| </script> | ||
|
|
||
| <template> | ||
| <v-circle v-if="showHitArea" :config="hitConfig" /> | ||
| <v-group :config="drawingGroupConfig"> | ||
| <v-circle :config="circleConfig" /> | ||
| <v-rect v-for="(rectConfig, idx) in outerTabConfigs" :key="`pivot-outer-${idx}`" :config="rectConfig" /> | ||
| <v-rect v-for="(rectConfig, idx) in innerShapeConfigs" :key="`pivot-inner-${idx}`" :config="rectConfig" /> | ||
| <v-circle :config="ringConfig" /> | ||
| </v-group> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.